rasterio / rasterio

Rasterio reads and writes geospatial raster datasets
https://rasterio.readthedocs.io/
Other
2.28k stars 534 forks source link

crs.is_epsg_code returns different things between version 1.3.10 and 1.4.2 #3248

Open remicres opened 1 week ago

remicres commented 1 week ago

Expected behavior and actual behavior.

I expected that the following code would result in the same outcome for rasterio 1.3.10 and 1.4.2. But no :cry:

Steps to reproduce the problem.

import rasterio
img = "https://gitlab.orfeo-toolbox.org/orfeotoolbox/otb/-/raw/develop/Data/Input/SP67_FR_subset_1.tif"
with rasterio.open(img) as src:
    print(src.crs.is_epsg_code)

Output:

Strangely calling to_epsg() gives the correct EPSG code (2154) for both considered rasterio versions.

Environment Information

rasterio info:
  rasterio: 1.4.2
      GDAL: 3.9.3
      PROJ: 9.4.1
      GEOS: 3.11.1
 PROJ DATA: /usr/local/lib/python3.10/dist-packages/rasterio/proj_data
 GDAL DATA: None

System:
    python: 3.10.12 (main, Nov 20 2023, 15:14:05) [GCC 11.4.0]
executable: /usr/local/bin/python
   machine: Linux-6.8.0-45-generic-x86_64-with-glibc2.35

Python deps:
    affine: 2.4.0
     attrs: 24.2.0
   certifi: 2023.11.17
     click: 8.1.7
     cligj: 0.7.2
    cython: None
     numpy: 1.26.2
click-plugins: None
setuptools: 59.6.0

Installation Method

pip install from an ubuntu 22.04 docker image

sgillies commented 1 week ago

@remicres thanks for the report! On my Macbook, I don't see a problem.

rio insp https://gitlab.orfeo-toolbox.org/orfeotoolbox/otb/-/raw/develop/Data/Input/SP67_FR_subset_1.tif
Rasterio 1.4.2 Interactive Inspector (Python 3.11.6)
Type "src.meta", "src.read(1)", or "help(src)" for more information.
>>> src.crs
CRS.from_wkt('PROJCS["RGF93 v1 / Lambert-93",GEOGCS["RGF93 v1",DATUM["Reseau_Geodesique_Francais_1993_v1",SPHEROID["GRS 1980",6378137,298.257222101,AUTHORITY["EPSG","7019"]],AUTHORITY["EPSG","6171"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.0174532925199433,AUTHORITY["EPSG","9122"]],AUTHORITY["EPSG","4171"]],PROJECTION["Lambert_Conformal_Conic_2SP"],PARAMETER["latitude_of_origin",46.5],PARAMETER["central_meridian",3],PARAMETER["standard_parallel_1",49],PARAMETER["standard_parallel_2",44],PARAMETER["false_easting",700000],PARAMETER["false_northing",6600000],UNIT["metre",1,AUTHORITY["EPSG","9001"]],AXIS["Easting",EAST],AXIS["Northing",NORTH],AUTHORITY["EPSG","2154"]]')
>>> src.crs.to_epsg()
2154
>>> src.crs.is_epsg_code
True

But in an ubuntu-small-3.9.3 GDAL container I do see almost the same thing you report.

rio insp https://gitlab.orfeo-toolbox.org/orfeotoolbox/otb/-/raw/develop/Data/Input/SP67_FR_subset_1.tif
Rasterio 1.4.3dev Interactive Inspector (Python 3.9.20)
Type "src.meta", "src.read(1)", or "help(src)" for more information.
>>> src.crs
CRS.from_wkt('PROJCS["RGF93 v1 / Lambert-93",GEOGCS["RGF93 v1",DATUM["Reseau_Geodesique_Francais_1993_v1",SPHEROID["GRS 1980",6378137,298.257222101,AUTHORITY["EPSG","7019"]],AUTHORITY["EPSG","6171"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.0174532925199433,AUTHORITY["EPSG","9122"]],AUTHORITY["EPSG","4171"]],PROJECTION["Lambert_Conformal_Conic_2SP"],PARAMETER["latitude_of_origin",46.5],PARAMETER["central_meridian",3],PARAMETER["standard_parallel_1",49],PARAMETER["standard_parallel_2",44],PARAMETER["false_easting",700000],PARAMETER["false_northing",6600000],UNIT["metre",1,AUTHORITY["EPSG","9001"]],AXIS["Easting",EAST],AXIS["Northing",NORTH],AUTHORITY["EPSG","2154"]]')
>>> src.crs.to_epsg()
>>> src.crs.is_epsg_code
False
remicres commented 1 week ago

On ubuntu 22.04 the change seems to occur between versions 1.4.1 and 1.4.2