Skip to content

Commit

Permalink
Merge pull request #511 from kartoza/cell-size
Browse files Browse the repository at this point in the history
Cell size user configurable
  • Loading branch information
timlinux authored Oct 29, 2024
2 parents 86c9460 + 6b905f1 commit 0094a1e
Show file tree
Hide file tree
Showing 50 changed files with 284 additions and 2,010 deletions.
5 changes: 2 additions & 3 deletions geest/core/algorithms/ors_multibuffer_processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -742,8 +742,8 @@ def rasterize(
)

# Ensure resolution parameters are properly formatted as float values
x_res = 100.0 # 100m pixel size in X direction
y_res = 100.0 # 100m pixel size in Y direction
x_res = self.cell_size_m # pixel size in X direction
y_res = self.cell_size_m # pixel size in Y direction
bbox = bbox.boundingBox()
# Define rasterization parameters for the temporary layer
params = {
Expand All @@ -755,7 +755,6 @@ def rasterize(
"WIDTH": x_res,
"HEIGHT": y_res,
"EXTENT": f"{bbox.xMinimum()},{bbox.xMaximum()},{bbox.yMinimum()},{bbox.yMaximum()} [{self.target_crs.authid()}]",
#'EXTENT':'280518.114000000,296308.326900000,3998456.316800000,4003763.812500000 [EPSG:32630]',
"NODATA": 0,
"OPTIONS": "",
"DATA_TYPE": 0,
Expand Down
17 changes: 15 additions & 2 deletions geest/core/algorithms/safety_polygon_processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,23 @@ class SafetyPerCellProcessor:
- Assigning values based on perceived safety.
- Rasterizing the results.
- Combining rasterized results into a single VRT file.
Args:
output_prefix (str): Prefix for the output files.
cell_size_m (float): The cell size in meters for the analysis.
safety_layer (QgsVectorLayer): The input layer containing safety data.
safety_field (str): The field in the safety layer containing perceived safety values.
workflow_directory (str): Directory where output files will be stored.
gpkg_path (str): Path to the GeoPackage with study areas.
context (QgsProcessingContext): The processing context to pass objects to the thread.
Returns:
str: The path to the created VRT file.
"""

def __init__(
self,
output_prefix: str,
cell_size_m: float,
safety_layer: QgsVectorLayer,
safety_field: str,
workflow_directory: str,
Expand All @@ -54,6 +66,7 @@ def __init__(
gpkg_path (str): Path to the GeoPackage with study areas.
"""
self.output_prefix = output_prefix
self.cell_size_m = cell_size_m
self.safety_layer = safety_layer
self.workflow_directory = workflow_directory
self.gpkg_path = gpkg_path
Expand Down Expand Up @@ -187,8 +200,8 @@ def _rasterize_safety(
"BURN": None,
"USE_Z": False,
"UNITS": 1,
"WIDTH": 100.0,
"HEIGHT": 100.0,
"WIDTH": self.cell_size_m,
"HEIGHT": self.cell_size_m,
"EXTENT": f"{bbox.xMinimum()},{bbox.xMaximum()},{bbox.yMinimum()},{bbox.yMaximum()}",
"NODATA": 255,
"DATA_TYPE": 0,
Expand Down
11 changes: 7 additions & 4 deletions geest/core/algorithms/single_point_buffer_processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ class SinglePointBufferProcessor:
def __init__(
self,
output_prefix: str,
cell_size_m: float,
input_layer: QgsVectorLayer,
buffer_distance: float,
workflow_directory: str,
Expand All @@ -34,12 +35,14 @@ def __init__(
Args:
output_prefix (str): Prefix for naming output files.
cell_size_m (float): The cell size in meters for the analysis.
input_layer (QgsVectorLayer): The input layer containing the points to buffer.
buffer_distance (float): The distance in meters to buffer the points.
workflow_directory (str): Directory where temporary and output files will be stored.
gpkg_path (str): Path to the GeoPackage containing study areas and bounding boxes.
"""
self.output_prefix = output_prefix
self.cell_size_m = cell_size_m
self.features_layer = input_layer
self.buffer_distance = buffer_distance
self.workflow_directory = workflow_directory
Expand Down Expand Up @@ -287,8 +290,8 @@ def _rasterize(
QgsMessageLog.logMessage(f"Rasterizing {input_layer}", "Geest", Qgis.Info)

# Ensure resolution parameters are properly formatted as float values
x_res = 100.0 # 100m pixel size in X direction
y_res = 100.0 # 100m pixel size in Y direction
x_res = self.cell_size_m # pixel size in X direction
y_res = self.cell_size_m # pixel size in Y direction
bbox = bbox.boundingBox()
# Define rasterization parameters for the temporary layer
params = {
Expand Down Expand Up @@ -386,8 +389,8 @@ def _mask_raster(
"CROP_TO_CUTLINE": True,
"KEEP_RESOLUTION": False,
"SET_RESOLUTION": True,
"X_RESOLUTION": 100,
"Y_RESOLUTION": 100,
"X_RESOLUTION": self.cell_size_m,
"Y_RESOLUTION": self.cell_size_m,
"MULTITHREADING": True,
"DATA_TYPE": 0, # byte
"EXTRA": "",
Expand Down
96 changes: 0 additions & 96 deletions geest/core/buffering.py

This file was deleted.

57 changes: 0 additions & 57 deletions geest/core/convert_to_8bit.py

This file was deleted.

Loading

0 comments on commit 0094a1e

Please sign in to comment.