Skip to content

Commit 322a9d3

Browse files
committed
Add check for lat in get_gridcellarea
1 parent 2a1f9b1 commit 322a9d3

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

climada/util/coordinates.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -468,7 +468,12 @@ def get_gridcellarea(lat, resolution=0.5, unit="ha"):
468468
unit: string, optional
469469
unit of the output area (default: ha, alternatives: m2, km2)
470470
"""
471-
471+
# first check that lat is in geographic coordinates
472+
if not check_if_geo_coords(lat, 0):
473+
raise ValueError(
474+
"Input lat and lon coordinates are not geographic "
475+
"or have total extents > 180° for lat or > 360° for lon."
476+
)
472477
if unit == "m2":
473478
area = (ONE_LAT_KM * resolution) ** 2 * np.cos(np.deg2rad(lat)) * 1000000
474479
elif unit == "km2":

0 commit comments

Comments
 (0)