Import order for fiona and rasterio
See original GitHub issueWith the current binary wheels on PyPI, the order that fiona and rasterio are imported into a script/module is important.
Good:
import fiona
import rasterio
Bad:
import rasterio
import fiona
Steps to reproduce
To reproduce the issue (on linux), use a virtual environment to install the current binary wheels from pip:
$ python3 -m venv /tmp/venv
$ . /tmp/venv/bin/activate
(venv) $ pip install fiona rasterio
(installs Fiona-1.8.18-cp36-cp36m-manylinux1_x86_64.whl
, rasterio-1.2.1-cp36-cp36m-manylinux1_x86_64.whl
, and dependancies)
Importing rasterio before fiona is no good
(venv) $ python -c "import rasterio; import fiona"
ERROR 4: Unable to open EPSG support file gcs.csv. Try setting the GDAL_DATA environment variable to point to the directory containing EPSG csv files.
The transform module does not work well:
(venv) $ python -c "import rasterio; from fiona.transform import transform; print(transform('EPSG:3857', 'EPSG:4326', [19455906], [-5026598]))"
ERROR 4: Unable to open EPSG support file gcs.csv. Try setting the GDAL_DATA environment variable to point to the directory containing EPSG csv files.
ERROR 4: Unable to open EPSG support file gcs.csv. Try setting the GDAL_DATA environment variable to point to the directory containing EPSG csv files.
ERROR 4: Unable to open EPSG support file gcs.csv. Try setting the GDAL_DATA environment variable to point to the directory containing EPSG csv files.
ERROR 6: No translation for an empty SRS to PROJ.4 format is known.
ERROR 10: Pointer 'hTransform' is NULL in 'OCTTransform'.
([19455906.0], [-5026598.0])
these are the same coordinates as the input, as it’s a failed operation.
Importing fiona before rasterio is OK
(venv) $ python -c "import fiona; import rasterio"
shows no error message, and the transform module works as expected:
(venv) $ python -c "from fiona.transform import transform; import rasterio; print(transform('EPSG:3857', 'EPSG:4326', [19455906], [-5026598]))"
([174.77537726192696], [-41.09658239799418])
these are the expected long, lat coords.
Other discussion
This does not seem to be an issue with packages installed via conda (with conda-forge), testing with rasterio-1.2.1
and fiona-1.8.18
. This appears to be an issue while setting GDAL_DATA within the pip package directory. There are some similarities to #673.
Issue Analytics
- State:
- Created 2 years ago
- Comments:11 (11 by maintainers)
Top GitHub Comments
Fixed in 1.8.19.
Also fiona edits the environment variables:
https://github.com/Toblerity/Fiona/blob/885dbd11c5dcb2c61862faefc28bfbbff99954de/fiona/env.py#L590-L601
That could maybe also be changed?