eoio.readers.footprint_utils module#
eoio.readers.footprint_utils#
Utilities for normalizing and working with spatial footprint data across readers. Provides canonical footprint structure with standardized geometry and CRS.
Functions#
normalize_footprint : Convert various spatial formats to canonical form normalize_crs : Convert CRS codes to standard “EPSG:XXXXX” format wkt_to_geometry : Convert WKT string to Shapely geometry bbox_to_geometry : Convert bbox list to Shapely Polygon get_bounds_from_geometry : Extract (minx, miny, maxx, maxy) from geometry
- eoio.readers.footprint_utils.bbox_to_geometry(bbox: list | tuple | None) Polygon | None[source]#
Convert bounding box [minx, miny, maxx, maxy] to Shapely Polygon.
- Parameters:
bbox (list, tuple, or None) – Bounding box as [minx, miny, maxx, maxy] or (minx, miny, maxx, maxy)
- Returns:
Shapely Polygon representing the bounding box, or None if invalid
- Return type:
Polygon or None
- eoio.readers.footprint_utils.dict_geometry_to_shapely(geom_dict: Dict[str, Any] | None) Polygon | Point | None[source]#
Convert dict geometry (from xmltodict or GeoJSON-like) to Shapely object.
Handles: - GeoJSON-like dicts with “coordinates” key - xmltodict Polygon dicts with vertex lists
- Parameters:
geom_dict (dict or None) – Dictionary with geometry data
- Returns:
Shapely geometry or None if conversion fails
- Return type:
Polygon, Point, or None
- eoio.readers.footprint_utils.get_bounds_from_geometry(geometry: Polygon | Point | None) Tuple[float, float, float, float] | None[source]#
Extract bounds tuple (minx, miny, maxx, maxy) from Shapely geometry.
- Parameters:
geometry (Polygon, Point, or None) – Shapely geometry object
- Returns:
(minx, miny, maxx, maxy) or None if geometry is None
- Return type:
tuple or None
- eoio.readers.footprint_utils.normalize_crs(crs_value: str | int | Dict | None) str | None[source]#
Normalize various CRS representations to standardized “EPSG:XXXXX” format.
- Parameters:
crs_value (str, int, dict, or None) – CRS code in various formats: - “EPSG:32630” → “EPSG:32630” - “32630” → “EPSG:32630” - 32630 → “EPSG:32630” - None → None - Dict with numeric value → “EPSG:XXXXX”
- Returns:
Normalized CRS string “EPSG:XXXXX” or None if input is None/invalid
- Return type:
str or None
- eoio.readers.footprint_utils.normalize_footprint(geometry_input: str | Dict | list | Polygon | Point | None = None, crs_input: str | int | Dict | None = None) Dict[str, Any] | None[source]#
Create canonical footprint dictionary from various input formats.
Converts various geometry and CRS representations to a standardized format.
- Parameters:
geometry_input (str, dict, list, Polygon, Point, or None) – Geometry in various formats: - WKT string: “POLYGON(…)” - Shapely object: Polygon or Point - Bbox list: [minx, miny, maxx, maxy] - Dict (xmltodict): from XML parsing
crs_input (str, int, dict, or None) – CRS code in various formats (see normalize_crs for details)
- Returns:
Canonical footprint dict with keys: - ‘geometry’: Shapely Polygon or Point (or None) - ‘crs’: str “EPSG:XXXXX” (or None) - ‘bounds’: tuple (minx, miny, maxx, maxy) (or None)
Returns None if no valid geometry or CRS could be extracted.
- Return type:
dict or None
- eoio.readers.footprint_utils.wkt_to_geometry(wkt_string: str | None) Polygon | Point | None[source]#
Convert WKT string to Shapely geometry object.
- Parameters:
wkt_string (str or None) – WKT representation of geometry (e.g., “POLYGON(…)” or “POINT(…)”)
- Returns:
Shapely geometry object or None if parsing fails
- Return type:
Polygon, Point, or None