stems.gis.geom module

Geometry related functions

stems.gis.geom.bounds_intersection(*bounds)[source]

Return the intersection of some BoundingBox(s)

Parameters

bounds (BoundingBox) – Bounding boxes

Returns

The intersection of all input BoundingBox

Return type

BoundingBox

stems.gis.geom.bounds_transform_union(bounds, transform)[source]

Calculate union of bounds for some transform

Parameters
  • bounds (Sequence[BoundingBox]) – Bounding boxes

  • transform (Affine) – Affine transform to use

Returns

  • rasterio.coords.BoundingBox – Union of BoundingBox

  • affine.Affine – Unified affine transform

  • tuple[int, int] – Shape of union (nrow, ncol)

stems.gis.geom.bounds_union(*bounds)[source]

Return the union of some BoundingBox(s)

Parameters

bounds (BoundingBox) – Bounding boxes

Returns

The union of all input BoundingBox

Return type

BoundingBox

stems.gis.geom.calculate_dst_window(src_bounds, dst_transform)[source]

Calculate the rounded source window for some other transform

Parameters
  • src_bounds (rasterio.coords.BoundingBox) – Input bounds for the source raster image

  • dst_transform (affine.Affine) – Destination Affine transform

Returns

Window of source that conforms (pixel size, upper left) to dst_tranform

Return type

rasterio.windows.Window

stems.gis.geom.calculate_src_window(src_bounds, src_transform, dst_bounds)[source]

Calculate the source window for some output bounds

Parameters
Returns

  • rasterio.windows.Window – Window of source that contains dst_bounds

  • rasterio.coords.BoundingBox – The BoundingBox representing the destination window for the source

stems.gis.geom.fix_geojson_rfc7946(geojson)[source]

Fixes issues with dateline and meridian cutting

Parameters

geojson (dict) – GeoJSON as a dict

Returns

Fixed up GeoJSON

Return type

dict

stems.gis.geom.is_null(geom)[source]

Return True if a geometry is not valid / null

Parameters

shapely.geometry.BaseGeometry – Some shapely geometry (or something that supports __geo_interface__)

Returns

Null or not

Return type

bool