stems.gis.convert module

GIS variable conversion library

Functions here are convenient ways of going from various representations of GIS information used in this stack (e.g., WKT) to the following representations:

stems.gis.convert.to_bbox(value)[source]

Convert input a bounding box shapely.geometry.Polygon

Parameters

value (BoundingBox) – Object representing a bounding box, or an xarray object with coords we can use to calculate one from

Returns

BoundingBox as a polygon

Return type

shapely.geometry.Polygon

stems.gis.convert.to_bounds(value)[source]

Convert input to a rasterio.coords.BoundingBox

Parameters

value (iterable, or Polygon) – Input containing some geographic information

Returns

Bounding box (left, bottom, right, top). Also described as (minx, miny, maxx, maxy)

Return type

BoundingBox

stems.gis.convert.to_crs(value)[source]

Convert a CRS representation to a rasterio.crs.CRS

Parameters

value (str, int, dict, or osr.SpatialReference) – Coordinate reference system as WKT, Proj.4 string, EPSG code, rasterio-compatible proj4 attributes in a dict, or OSR definition

Returns

CRS

Return type

rasterio.crs.CRS

stems.gis.convert.to_transform(value, from_gdal=False)[source]

Convert input into an affine.Affine transform

Parameters
  • value (Affine or iterable) – 6 numbers representing affine transform

  • from_gdal (bool, optional) – If value is a tuple or list, specifies if transform is GDAL variety (True) or rasterio/affine (False)

Returns

Affine transform

Return type

affine.Affine