landstac.utils¶
Utility helpers for geometry conversion and normalization.
Functions¶
- bbox_tuple(min_lon, min_lat, max_lon, max_lat)
Return a strict (min_lon, min_lat, max_lon, max_lat) tuple of floats.
- bbox_to_geojson(bbox)
Convert a bbox tuple to a GeoJSON Polygon suitable for STAC searches.
- ee_polygon_to_bbox(ee_coords)
Convert an Earth Engine style polygon coordinate array to a bbox tuple.
Notes
All longitudes and latitudes are treated as WGS84 degrees.
The GeoJSON Polygon returned by bbox_to_geojson is closed, with the last coordinate repeating the first.
Functions
|
Convert a bbox to a GeoJSON Polygon. |
|
Normalize and return a bounding box tuple. |
|
Convert an Earth Engine style polygon to a bbox tuple. |
- landstac.utils.bbox_to_geojson(bbox)[source]¶
Convert a bbox to a GeoJSON Polygon.
- Parameters:
bbox (BBox) – Tuple in (min_lon, min_lat, max_lon, max_lat) order.
- Returns:
GeoJSON Polygon mapping.
- Return type:
GeoJSON
Examples
>>> bbox_to_geojson((-1.0, -2.0, 3.0, 4.0))["type"] 'Polygon'
- landstac.utils.bbox_tuple(min_lon, min_lat, max_lon, max_lat)[source]¶
Normalize and return a bounding box tuple.
- Parameters:
- Returns:
(min_lon, min_lat, max_lon, max_lat) as floats.
- Return type:
BBox
Examples
>>> bbox_tuple(-115.359, 35.6763, -113.6548, 36.4831) (-115.359, 35.6763, -113.6548, 36.4831)
- landstac.utils.ee_polygon_to_bbox(ee_coords)[source]¶
Convert an Earth Engine style polygon to a bbox tuple.
- Parameters:
ee_coords (list) – Coordinates in the form [[ [lon, lat], [lon, lat], … ]]. Only the exterior ring is required, but additional rings are ignored safely.
- Returns:
(min_lon, min_lat, max_lon, max_lat)
- Return type:
BBox
Examples
>>> ring = [[-52.7897, -10.7120], [-52.7897, -10.7200], [-52.7813, -10.7200], [-52.7813, -10.7120]] >>> ee_polygon_to_bbox([ring]) (-52.7897, -10.72, -52.7813, -10.712)