onstove.VectorLayer.proximity#

VectorLayer.proximity(base_layer: str | RasterLayer | None, output_path: str | None = None, create_raster: bool | None = True) RasterLayer[source]#

Calculates a euclidean proximity distance raster based on the given vector layer.

It uses the scipy.ndimage.distance_transform_edt function to calculate an exact Euclidean distance transform.

Parameters:
base_layer: str or RasterLayer

Raster layer used as a template to calculate the proximity of the vectors to each grid cell in the base layer. The base_layer must be either a str of the path to a raster file or a RasterLayer object. The metadata of the base layer will become the metadata of the proximity raster.

output_path: str, optional

A folder path where to save the output dataset. If not defined then the proximity dataset is not saved.

create_raster: bool, default True

Boolean condition. If True, a RasterLayer will be created and stored in the distance_raster attribute of the class. If False, a RasterLayer with the proximity distance calculation is returned.

Returns:
RasterLayer

RasterLayer containing the distance to the nearest point of the current VectorLayer.