Skip to content

Commit

Permalink
feat: default num_patches as setting
Browse files Browse the repository at this point in the history
  • Loading branch information
martibosch committed Aug 3, 2023
1 parent 223718b commit 729e6f2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
13 changes: 9 additions & 4 deletions urban_footprinter/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@

__version__ = "0.2.0"

__all__ = ["UrbanFootprinter", "urban_footprint_mask", "urban_footprint_mask_shp"]
__all__ = [
"UrbanFootprinter",
"urban_footprint_mask",
"urban_footprint_mask_shp",
]

KERNEL_MOORE = ndi.generate_binary_structure(2, 2)

Expand Down Expand Up @@ -136,7 +140,7 @@ def get_convolution_result(self, kernel_radius):
return urban_mask

def compute_footprint_mask(
self, kernel_radius, urban_threshold, num_patches=1, buffer_dist=None
self, kernel_radius, urban_threshold, num_patches=None, buffer_dist=None
):
"""Compute a boolean mask of the urban footprint of a given raster.
Expand All @@ -149,8 +153,9 @@ def compute_footprint_mask(
given pixel is considered urban.
num_patches : int, default 1
The number of urban patches that should be featured in the returned
urban/non-urban mask. If `None` or a value lower than one is provided, the
returned urban/non-urban mask will featuer all the urban patches.
urban/non-urban mask. If a value lower than one is provided, the returned
urban/non-urban mask will featuer all the urban patches. If no value is
provided, the default value from `settings.DEFAULT_NUM_PATCHES` is used.
buffer_dist : numeric, optional
Distance to be buffered around the urban/non-urban mask. If no value is
provided, no buffer is applied.
Expand Down
1 change: 1 addition & 0 deletions urban_footprinter/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@
DEFAULT_LULC_DTYPE = np.int32
DEFAULT_MASK_DTYPE = np.uint8
DEFAULT_CONV_BORDER_TYPE = cv2.BORDER_REFLECT
DEFAULT_NUM_PATCHES = 1

0 comments on commit 729e6f2

Please sign in to comment.