Skip to content

Commit df439a5

Browse files
committed
Add check for geo coords in get_country_code
1 parent f27c4aa commit df439a5

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

climada/util/coordinates.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1624,6 +1624,12 @@ def get_country_code(lat, lon, gridded=False):
16241624
return np.empty((0,), dtype=int)
16251625
LOGGER.info("Setting region_id %s points.", str(lat.size))
16261626
if gridded:
1627+
# first check that input lat lon are geographic
1628+
if not check_if_geo_coords(lat, lon):
1629+
raise ValueError(
1630+
"Input lat and lon coordinates are not geographic "
1631+
"or have total extents > 180° for lat or > 360° for lon."
1632+
)
16271633
base_file = u_hdf5.read(NATEARTH_CENTROIDS[150])
16281634
meta, region_id = base_file["meta"], base_file["region_id"]
16291635
transform = rasterio.Affine(*meta["transform"])

0 commit comments

Comments
 (0)