Skip to content

Commit

Permalink
fix: fix docstring formating, removed unused param
Browse files Browse the repository at this point in the history
  • Loading branch information
nmaarnio committed Oct 18, 2024
1 parent 112002a commit 9419dfa
Showing 1 changed file with 20 additions and 21 deletions.
41 changes: 20 additions & 21 deletions eis_toolkit/vector_processing/proximity_computation.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)

Expand All @@ -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)
Expand Down

0 comments on commit 9419dfa

Please sign in to comment.