Skip to content

Commit

Permalink
Fix polygon mask test
Browse files Browse the repository at this point in the history
  • Loading branch information
timlinux committed Dec 27, 2024
1 parent 6963a37 commit 928c090
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 8 deletions.
12 changes: 6 additions & 6 deletions geest/core/algorithms/opportunities_polygon_mask.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,19 +125,19 @@ def __init__(
log_message(f"{self.study_area_gpkg_path}|ayername=study_area_clip_polygon")
del layer

log_message("Initialized WEE Subnational Area Aggregation Processing Task")
log_message("Initialized WEE Opportunities Polygon Mask Processing Task")

def run(self) -> bool:
"""
Executes the WEE Subnational Area Aggregation Processing Task calculation task.
Executes the WEE Opportunities Polygon Mask Processing Task calculation task.
"""
try:
self.mask()
self.apply_qml_style(
source_qml=resources_path(
"resources", "qml", "wee_by_population_vector_score.qml"
"resources", "qml", "wee_by_population_score.qml"
),
qml_path=os.path.join(self.output_dir, "subnational_aggregation.qml"),
qml_path=os.path.join(self.output_dir, "wee_by_population_score.qml"),
)
return True
except Exception as e:
Expand All @@ -149,7 +149,7 @@ def mask(self) -> None:
"""Fix geometries then use mask vector to calculate masked WEE SCORE or WEE x Population Score layer."""

params = {
"INPUT": self.aggregation_layer,
"INPUT": self.mask_areas_layer,
"METHOD": 1, # Structure method
"OUTPUT": "TEMPORARY_OUTPUT",
}
Expand All @@ -163,7 +163,7 @@ def mask(self) -> None:
"RASTER_BAND": 1,
"COLUMN_PREFIX": "_",
"STATISTICS": [9], # Majority
"OUTPUT": os.path.join(self.output_dir, "subnational_aggregation.gpkg"),
"OUTPUT": os.path.join(self.output_dir, "polygon_mask.gpkg"),
}
processing.run("native:zonalstatisticsfb", params)

Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified test/test_data/wee_score/wee_score.qgz
Binary file not shown.
4 changes: 2 additions & 2 deletions test/test_polygon_opportunities_mask.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def setUpClass(cls):
cls.context = QgsProcessingContext()
cls.feedback = QgsFeedback()
cls.mask_areas_path = os.path.join(
cls.working_directory, "mask", "mask.gpkg|layername=mask"
cls.working_directory, "masks", "polygon_mask.gpkg|layername=polygon_mask"
)
cls.study_area_gpkg_path = os.path.join(
cls.working_directory, "study_area", "study_area.gpkg"
Expand All @@ -41,7 +41,7 @@ def setUp(self):

def test_initialization(self):
self.assertTrue(
self.task.output_dir.endswith("wee_masks"),
self.task.output_dir.endswith("opportunity_masks"),
msg=f"Output directory is {self.task.output_dir}",
)
self.assertEqual(self.task.target_crs.authid(), "EPSG:32620")
Expand Down

0 comments on commit 928c090

Please sign in to comment.