Source code for hestia_earth.validation.geojson
from area import area
GEOMETRY_BY_TYPE = {
'FeatureCollection': lambda x: _get_geometry_by_type(x.get('features')[0]),
'GeometryCollection': lambda x: _get_geometry_by_type(x.get('geometries')[0]),
'Feature': lambda x: x.get('geometry'),
'Polygon': lambda x: x,
'MultiPolygon': lambda x: x
}
def _get_geometry_by_type(geojson): return GEOMETRY_BY_TYPE[geojson.get('type')](geojson)
[docs]def get_geojson_area(geojson: dict): return round(area(_get_geometry_by_type(geojson)) / 10000, 1)