⚠️ Our 0.1 release refactored several early-development functions for long-term stability, to update your code see here. ⚠️
Future changes will come with deprecation warnings! 🙂




Mask.proximity(vector=None, target_values=None, geometry_type='boundary', in_or_out='both', distance_unit='georeferenced')[source]#

Compute proximity distances to the raster target pixels, or to a vector geometry on the raster grid.

Match-reference: a raster can be passed to match its resolution, bounds and CRS for computing proximity distances.

When passing a vector, by default, the boundary of the geometry will be used. The full geometry can be used by passing “geometry”, or any lower dimensional geometry attribute such as “centroid”, “envelope” or “convex_hull”. See all geometry attributes in the Shapely documentation at https://shapely.readthedocs.io/.

  • vector (Vector | None) – Vector for which to compute the proximity to geometry, if not provided computed on this raster target pixels.

  • target_values (list[float] | None) – (Only with raster) List of target values to use for the proximity, defaults to all non-zero values.

  • geometry_type (str) – (Only with a vector) Type of geometry to use for the proximity, defaults to ‘boundary’.

  • in_or_out (Union[Literal['in'], Literal['out'], Literal['both']]) – (Only with a vector) Compute proximity only ‘in’ or ‘out’-side the geometry, or ‘both’.

  • distance_unit (Union[Literal['pixel'], Literal['georeferenced']]) – Distance unit, either ‘georeferenced’ or ‘pixel’.

Return type:



Proximity distances raster.