Skip to content

Commit d2d7e09

Browse files
authored
Fix reproject_shapes() to avoid flipped coordinats (#462)
* Fix reproject_shapes() to avoid flipped coordinats Fix reproject_shapes() by enforcing always_xy=True in Transformer Previously, reprojections involving EPSG:4326 could produce flipped coordinates because pyproj defaults to EPSG axis order (lat, lon). This caused inconsistent results when transforming from projected CRS (e.g. UTM) to geographic CRS. The fix explicitly sets always_xy=True in Transformer.from_crs, ensuring that all transformations consistently interpret coordinates as (x=longitude, y=latitude). * Add release note
1 parent f97896b commit d2d7e09

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

RELEASE_NOTES.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ Upcoming Release
2929
* Raise a `FileNotFoundError` if the `temp_dir` explicitly specified for cutout preparation does not exist instead of failing with an obfuscated error message (https://github.com/PyPSA/atlite/pull/445).
3030
* Addressed `rasterio` DeprecationWarning on `crs.is_valid`.
3131
* Fix calls to `cdsapi` for ERA5 to be compliant with current API syntax (https://github.com/PyPSA/atlite/pull/414 and https://github.com/PyPSA/atlite/pull/454).
32+
* Fix `reproject_shapes()` to preserve coordinate order by enforcing (x=lon, y=lat) with `always_xy=True` when transforming from one CRS to another (https://github.com/PyPSA/atlite/pull/462).
3233

3334
`v0.4.1 <https://github.com/PyPSA/atlite/releases/tag/v0.4.1>`__ (12th May 2025)
3435
=======================================================================================

atlite/gis.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ def reproject_shapes(shapes, crs1, crs2):
8888
"""
8989
Project a collection of shapes from one crs to another.
9090
"""
91-
transformer = Transformer.from_crs(crs1, crs2)
91+
transformer = Transformer.from_crs(crs1, crs2, always_xy=True)
9292

9393
def _reproject_shape(shape):
9494
return transform(transformer.transform, shape)

0 commit comments

Comments
 (0)