Rasterio: CRS & upper case EPSG with init issues

Created on 4 Mar 2019  路  12Comments  路  Source: mapbox/rasterio

>>> import rasterio
>>> rasterio.__version__
'1.0.21'
>>> from rasterio.crs import CRS
>>> crs = CRS.from_user_input("EPSG:4326")
>>> crs
CRS.from_dict(init='epsg:4326')
>>> crs = CRS.from_user_input("+init=epsg:4326")
>>> crs
CRS.from_dict(init='epsg:4326')
>>> crs = CRS.from_user_input("+init=EPSG:4326")
Traceback (most recent call last):
  File "rasterio/_crs.pyx", line 323, in rasterio._crs._CRS.from_user_input
  File "rasterio/_err.pyx", line 194, in rasterio._err.exc_wrap_ogrerr
rasterio._err.CPLE_BaseError: OGR Error code 5

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/snowal/miniconda/envs/gail/lib/python3.6/site-packages/rasterio/crs.py", line 434, in from_user_input
    obj._crs = _CRS.from_user_input(value, morph_from_esri_dialect=morph_from_esri_dialect)
  File "rasterio/_crs.pyx", line 327, in rasterio._crs._CRS.from_user_input
rasterio.errors.CRSError: The WKT could not be parsed. OGR Error code 5
wontfix

All 12 comments

OS: Ubuntu 18.04.2 LTS

$ rio --gdal-version
2.4.0

Issue is non-existent with rasterio==1.0.12

With rasterio==1.0.14:

$ python
Python 3.6.7 | packaged by conda-forge | (default, Feb 20 2019, 02:51:38) 
[GCC 7.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from rasterio.crs import CRS
>>> crs = CRS.from_user_input("+init=EPSG:4326")
Traceback (most recent call last):
  File "rasterio/_crs.pyx", line 177, in rasterio._crs._CRS.from_proj4
  File "rasterio/_err.pyx", line 194, in rasterio._err.exc_wrap_ogrerr
rasterio._err.CPLE_BaseError: OGR Error code 5

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/snowal/miniconda/envs/gail/lib/python3.6/site-packages/rasterio/crs.py", line 407, in from_user_input
    return cls.from_string(value, morph_from_esri_dialect=morph_from_esri_dialect)
  File "/home/snowal/miniconda/envs/gail/lib/python3.6/site-packages/rasterio/crs.py", line 317, in from_string
    return cls.from_proj4(string)
  File "/home/snowal/miniconda/envs/gail/lib/python3.6/site-packages/rasterio/crs.py", line 337, in from_proj4
    obj._crs = _CRS.from_proj4(proj)
  File "rasterio/_crs.pyx", line 180, in rasterio._crs._CRS.from_proj4
rasterio.errors.CRSError: The PROJ4 dict could not be understood. OGR Error code 5

Note: Not a high priority issue on my end. Mostly just something I found recently.

@snowman2 in previous versions, we lowercased instances of "EPSG" in proj strings, but that was misguided: Rasterio users should almost always create CRS objects from "EPSG:xxxx" instead of "+init=epsg:xxxx". I'm going to mark this one as a wontfix.

Sounds good 馃憤

I am trying to use rio-rgbify to create some MapBox tiles following this comment, but I crash to the above mentioned error. I also tried to go back to rasterio 1.0.12, but it results to another CRS error:

rasterio.errors.CRSError: CRS is empty or invalid: ''

The (reprojected) raster CRS is "EPSG:3857"

with rasterio.open('/home/hriihimaki/raster_3857.tif') as dataset:
    print(dataset.crs)

EPSG:3857

Any ideas how to get forward? I am using rasterio 1.1.8, rio-rgbify 0.3.2. rio gdal is 2.4.4

I would try installing the latest rasterio with pip install rasterio --no-binary rasterio

That results to

rasterio.errors.CRSError: The PROJ4 dict could not be understood. PROJ: proj_create: cannot expand init='epsg:3857' +type=crs

init='epsg:3857' +type=crs this can only be understood by GDAL 3+ PROJ 6+. Also, it seems like the init= is missing the + before it.

I'm going to lock this issue because it is going off topic. Please use the rasterio user discussion group we've linked in the project README.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

sgillies picture sgillies  路  5Comments

ungarj picture ungarj  路  4Comments

lwasser picture lwasser  路  3Comments

vincentsarago picture vincentsarago  路  3Comments

astrojuanlu picture astrojuanlu  路  4Comments