Skip to content

Commit 07a4a73

Browse files
committed
Simplify crs check in match_centroids
1 parent 16bcc84 commit 07a4a73

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

climada/util/coordinates.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1245,20 +1245,17 @@ def match_centroids(
12451245

12461246
try:
12471247
if not equal_crs(coord_gdf.crs, centroids.crs):
1248-
raise ValueError("Set hazard and GeoDataFrame to same CRS first!")
1249-
if coord_gdf.crs is None:
12501248
raise ValueError(
1251-
"Please provide a coord_gdf (coordinate GeoDataFrame)"
1252-
"object with a valid crs attribute."
1249+
"Please provide coord_gdf and centroids defined in" " a common CRS."
12531250
)
1254-
if centroids.crs is None:
1251+
if coord_gdf.crs is None or centroids.crs is None:
12551252
raise ValueError(
1256-
"Please provide centroids " "object with a valid crs attribute."
1253+
"Please provide coord_gdf and centroids with valid crs attributes."
12571254
)
12581255
except AttributeError as exc:
12591256
# a crs attribute is needed for unit inference
12601257
raise ValueError(
1261-
"Please provide coordinate GeoDataFrame and Hazard object with a valid crs attribute."
1258+
"Please provide coord_gdf and centroids with valid crs attributes."
12621259
) from exc
12631260

12641261
# get unit of coordinate systems from axis of crs

0 commit comments

Comments
 (0)