Skip to content

Commit

Permalink
DEP: Update to pyproj 3.3+
Browse files Browse the repository at this point in the history
  • Loading branch information
snowman2 committed Dec 22, 2023
1 parent 50183ba commit d5b6630
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 26 deletions.
2 changes: 1 addition & 1 deletion .pylintrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[MASTER]
extension-pkg-whitelist=rasterio.crs
extension-pkg-whitelist=rasterio.crs,pyproj.database

[MESSAGES CONTROL]
disable=logging-fstring-interpolation,
Expand Down
9 changes: 2 additions & 7 deletions rioxarray/rioxarray.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
import rasterio.windows
import xarray
from affine import Affine
from pyproj.aoi import AreaOfInterest
from pyproj.database import query_utm_crs_info
from rasterio.control import GroundControlPoint
from rasterio.crs import CRS

Expand Down Expand Up @@ -531,13 +533,6 @@ def estimate_utm_crs(self, datum_name: str = "WGS 84") -> rasterio.crs.CRS:
-------
rasterio.crs.CRS
"""
# pylint: disable=import-outside-toplevel
try:
from pyproj.aoi import AreaOfInterest
from pyproj.database import query_utm_crs_info
except ImportError:
raise RuntimeError("pyproj 3+ required for estimate_utm_crs.") from None

if self.crs is None:
raise RuntimeError("crs must be set to estimate UTM CRS.")

Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ install_requires =
packaging
rasterio>=1.3
xarray>=0.17
pyproj>=2.2
pyproj>=3.3
numpy>=1.21

[options.package_data]
Expand Down
24 changes: 7 additions & 17 deletions test/integration/test_integration_rioxarray.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
from rioxarray.rioxarray import _make_coords
from test.conftest import (
GDAL_GE_361,
PYPROJ_LT_3,
TEST_COMPARE_DATA_DIR,
TEST_INPUT_DATA_DIR,
_assert_xarrays_equal,
Expand Down Expand Up @@ -2852,18 +2851,13 @@ def test_estimate_utm_crs():
with rioxarray.open_rasterio(
os.path.join(TEST_INPUT_DATA_DIR, "cog.tif"),
) as xds:
if PYPROJ_LT_3:
with pytest.raises(RuntimeError, match=r"pyproj 3\+ required"):
xds.rio.estimate_utm_crs()
else:
assert xds.rio.estimate_utm_crs().to_epsg() in (32618, 32655)
assert xds.rio.reproject(
"EPSG:4326"
).rio.estimate_utm_crs() == CRS.from_epsg(32618)
assert xds.rio.estimate_utm_crs("WGS 72") in (32218, 32255)
assert xds.rio.estimate_utm_crs().to_epsg() in (32618, 32655)
assert xds.rio.reproject("EPSG:4326").rio.estimate_utm_crs() == CRS.from_epsg(
32618
)
assert xds.rio.estimate_utm_crs("WGS 72") in (32218, 32255)


@pytest.mark.skipif(PYPROJ_LT_3, reason="pyproj 3+ required")
def test_estimate_utm_crs__missing_crs():
with pytest.raises(RuntimeError, match=r"crs must be set to estimate UTM CRS"):
xarray.Dataset().rio.estimate_utm_crs("NAD83")
Expand All @@ -2879,12 +2873,8 @@ def test_estimate_utm_crs__out_of_bounds():
},
)
xds.rio.write_crs("EPSG:4326", inplace=True)
if PYPROJ_LT_3:
with pytest.raises(RuntimeError, match=r"pyproj 3\+ required"):
xds.rio.estimate_utm_crs()
else:
with pytest.raises(RuntimeError, match=r"Unable to determine UTM CRS"):
xds.rio.estimate_utm_crs()
with pytest.raises(RuntimeError, match=r"Unable to determine UTM CRS"):
xds.rio.estimate_utm_crs()


def test_interpolate_na_missing_nodata():
Expand Down

0 comments on commit d5b6630

Please sign in to comment.