energy_methods.mapping#
Reusable rectilinear geographic mapping, alignment, area and GeoJSON utilities.
- energy_methods.mapping.normalize_grid(data)[source]#
Return sorted lat/lon coordinates, lon in [-180,180), rejecting duplicate seams.
- Parameters:
data (DataArray)
- Return type:
DataArray
- energy_methods.mapping.regrid(data, latitude, longitude, *, method='linear', categorical=False)[source]#
Bilinear/nearest interpolation of a rectilinear grid; no extrapolation.
Categorical layers require nearest neighbour. Missing source cells are not filled. There is no cyclic seam interpolation; targets outside the source centre extent remain NaN. Regrid climate inputs before classification.
- Parameters:
data (DataArray)
latitude (Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | complex | bytes | str | _NestedSequence[complex | bytes | str])
longitude (Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | complex | bytes | str | _NestedSequence[complex | bytes | str])
method (Literal['linear', 'nearest'])
categorical (bool)
- Return type:
DataArray
- energy_methods.mapping.cell_areas_km2(data)[source]#
Spherical cell areas from regular centre coordinates; Earth radius 6371.0088 km.
- Parameters:
data (DataArray)
- Return type:
DataArray
- energy_methods.mapping.class_area_summary(data, *, nodata=0)[source]#
Area by numeric class, excluding nodata/NaN; not a count of equally sized cells.
- Parameters:
data (DataArray)
nodata (int)
- Return type:
dict[int, float]
- energy_methods.mapping.write_geojson(data, path, *, nodata=None, labels=None, maximum_features=100000)[source]#
Export bounded regular grid cell polygons in EPSG:4326 for GIS/web maps.
Missing cells are omitted; boundaries are cell midpoints clipped at the poles and antimeridian. Use NetCDF for large global layers; GeoJSON is for subsets.
- Parameters:
data (DataArray)
path (Path)
nodata (float | None)
labels (dict[int, str] | None)
maximum_features (int)
- Return type:
Path