From 9419dfae9619cebf6b6bd6c20afa9ee4396ce8ad Mon Sep 17 00:00:00 2001 From: Niko Aarnio Date: Fri, 18 Oct 2024 20:20:56 +0300 Subject: [PATCH] fix: fix docstring formating, removed unused param --- .../proximity_computation.py | 41 +++++++++---------- 1 file changed, 20 insertions(+), 21 deletions(-) diff --git a/eis_toolkit/vector_processing/proximity_computation.py b/eis_toolkit/vector_processing/proximity_computation.py index 00f17ee2..472faf6a 100644 --- a/eis_toolkit/vector_processing/proximity_computation.py +++ b/eis_toolkit/vector_processing/proximity_computation.py @@ -3,7 +3,7 @@ import geopandas as gpd import numpy as np from beartype import beartype -from beartype.typing import Literal, Tuple, Union +from beartype.typing import Tuple, Union from rasterio import profiles from eis_toolkit.transformations.linear import _min_max_scaling @@ -15,26 +15,26 @@ def proximity_computation( geodataframe: gpd.GeoDataFrame, raster_profile: Union[profiles.Profile, dict], maximum_distance: Number, - scaling_method: Literal["linear"] = "linear", scale_range: Tuple[Number, Number] = (1, 0), ) -> np.ndarray: """Compute proximity to the nearest geometries. + Scales proximity values linearly in the given range. The first number in scale_range + denotes the value at geometries, the second at given maximum_distance. + Args: - geodataframe: The GeoDataFrame with geometries to determine proximity to. - raster_profile: The raster profile of the raster in which the distances - to the nearest geometry are determined. - max_distance: The maximum distance in the output array beyond which proximity is considered 0. - scaling_method: Scaling method used to produce the proximity values. Defaults to 'linear' - scaling_range: Min and max values used for scaling the proximity values. Defaults to (1,0). + geodataframe: The GeoDataFrame with geometries to determine proximity to. + raster_profile: The raster profile of the raster in which the distances to the + nearest geometry are determined. + max_distance: The maximum distance in the output array beyond which proximity is considered 0. + scaling_range: Min and max values used for scaling the proximity values. Defaults to (1,0). Returns: - A 2D numpy array with the scaled values. + A 2D numpy array with the scaled values. Raises: - NonMatchingCrsException: The input raster profile and geodataframe have mismatching CRS. - EmptyDataFrameException: The input geodataframe is empty. - + NonMatchingCrsException: The input raster profile and geodataframe have mismatching CRS. + EmptyDataFrameException: The input geodataframe is empty. """ out_matrix = _linear_proximity_computation(geodataframe, raster_profile, maximum_distance, scale_range) @@ -51,20 +51,19 @@ def _linear_proximity_computation( """Compute proximity to the nearest geometries. Args: - geodataframe: The GeoDataFrame with geometries to determine proximity to. - raster_profile: The raster profile of the raster in which the distances - to the nearest geometry are determined. - max_distance: The maximum distance in the output array. - scaling_range: a tuple of maximum value in the scaling and minimum value. + geodataframe: The GeoDataFrame with geometries to determine proximity to. + raster_profile: The raster profile of the raster in which the distances + to the nearest geometry are determined. + max_distance: The maximum distance in the output array. + scaling_range: a tuple of maximum value in the scaling and minimum value. Returns: - A 2D numpy array with the linearly scaled values. + A 2D numpy array with the linearly scaled values. Raises: - NonMatchingCrsException: The input raster profile and geodataframe have mismatching CRS. - EmptyDataFrameException: The input geodataframe is empty. + NonMatchingCrsException: The input raster profile and geodataframe have mismatching CRS. + EmptyDataFrameException: The input geodataframe is empty. """ - out_matrix = distance_computation(geodataframe, raster_profile, maximum_distance) out_matrix = _min_max_scaling(out_matrix, scaling_range)