From 890299b4b7ca66d733b65326a5de30e5ccb3d12f Mon Sep 17 00:00:00 2001 From: jpfleischer Date: Mon, 21 Oct 2024 17:50:10 -0400 Subject: [PATCH] Fix egrid data if name not in properties --- src/emcommon/metrics/footprint/util.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/emcommon/metrics/footprint/util.py b/src/emcommon/metrics/footprint/util.py index 183dc6b..049068d 100644 --- a/src/emcommon/metrics/footprint/util.py +++ b/src/emcommon/metrics/footprint/util.py @@ -101,7 +101,10 @@ async def get_egrid_region(coords: list[float, float], year: int) -> str | None: return None region_feature = get_feature_containing_point(coords, geojson) if region_feature is not None: - return region_feature['properties']['name'] + properties = region_feature['properties'] + region_name = properties.get('name') or properties.get('SUBRGN') + if region_name: + return region_name Log.warn(f"An eGRID region was not found for coords {coords} in year {year}.") return None