Skip to content

Commit b6a9084

Browse files
authored
fix raster crs fallback in exclusion container (#500)
* fix raster crs fallback in exclusion container * add release notes and improve error message
1 parent 6300162 commit b6a9084

2 files changed

Lines changed: 12 additions & 3 deletions

File tree

RELEASE_NOTES.rst

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,13 @@ Upcoming Release
2121
* Add ``aggregate_time={"sum", "mean", None}`` to ``convert_and_aggregate`` for temporal
2222
aggregation with and without spatial aggregation, and deprecate ``capacity_factor``/``capacity_factor_timeseries``
2323
in favor of it
24-
24+
25+
**Bug fixes**
26+
27+
* Fix regression when ``ExclusionContainer`` encounters a raster with an invalid CRS
28+
(https://github.com/PyPSA/atlite/pull/500).
29+
30+
2531
`v0.5.0 <https://github.com/PyPSA/atlite/releases/tag/v0.5.0>`__ (13th March 2026)
2632
=======================================================================================
2733

atlite/gis.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -479,11 +479,14 @@ def open_files(self):
479479
assert isinstance(raster, rio.DatasetReader)
480480

481481
# Check if the raster has a valid CRS
482-
if not raster.crs:
482+
if not (raster.crs.is_geographic or raster.crs.is_projected):
483483
if d["crs"]:
484484
raster._crs = CRS(d["crs"])
485485
else:
486-
raise ValueError(f"CRS of {raster} is invalid, please provide it.")
486+
raise ValueError(
487+
f"CRS of {raster} is neither geographic nor projected, "
488+
f"please provide it manually:\n{raster.crs}"
489+
)
487490
d["raster"] = raster
488491

489492
for d in self.geometries:

0 commit comments

Comments
 (0)