raster_tools.line_stats.length#

raster_tools.line_stats.length(features, like_rast, radius, weighting_field=None)[source]#

Calculate a raster where each cell is the net length of all features within a given radius.

This function returns a raster where each cell contains the sum of the lengths of all features that fall within a radius of the cell’s center. The features are clipped to the circular neighborhood before the length is computed. Optional weighting can be added with weighting_field.

Parameters
  • features (Vector, str) – The line features to compute lengths from. Only line geometry types (LineString, MultiLineString, LinearRing) are supported; other geometry types raise TypeError.

  • like_rast (Raster, str) – A raster to use as a reference grid and CRS. The output raster will be on the same grid.

  • radius (scalar) – The radius around each grid cell’s center to use. Features that fall within the radius are clipped to the resulting circle and their resulting lengths are summed. Additional weighting of the sum can be done using weighting_field. This should be in the same units as like_rast’s CRS.

  • weighting_field (str, optional) – If not None, this selects a field in features to use as a weighting factor in the sum of lengths.

Returns

The resulting raster where each cell contains the sum of all feature lengths in the circular neighborhood determined by radius.

Return type

Raster