Closed micahcochran closed 5 years ago
FWIW, I can reproduce this issue.
I've retesting this on a Linux box and the results are the same.
Fiona 1.8.4 works fine, but in Fiona 1.8.5 and above exhibit the same crs
issue. (And the crs_wkt
behavior also occurs.)
I've made it into a script that is easier to run on the command line instead of the console:
import fiona
with fiona.open('amb.shp') as amb:
print('CRS {}'.format(amb.crs))
with fiona.open('amb.shp') as amb:
print('CRS {}'.format(amb.crs))
Ubuntu Linux 18.04 GDAL version 2.3.2.
I retested on the Linux box with the repo version and it fixed the problem (and the strange behavior with crs_wkt
).
Interesting. I wonder if it has to do with the wheel. Does the behavior persist with: pip install fiona --no-binary fiona --ignore-installed
?
I can't reproduce this issue. I suspect that missing or unlocated projection data files are the cause. Closing, hope that's okay.
Does the behavior persist with:
pip install fiona --no-binary fiona --ignore-installed
?
I performed that install, which installed Fiona 1.8.6 from source (--verbose
). (This is on my Linux box.) In this installation, crs
behaved normally.
I bet it has to do with having GDAL installed on the system mixed with the binary wheel. If you have GDAL already installed on the system, I usually install from source as I have seen weird behavior if I don't.
Another observation: if GDAL's SRS cache at ~/.gdal/X.Y/srs_cache
does not exist, amb.crs
is always empty, not just on first read.
I just got this bug as well, on Fiona 1.8.6, GDAL 2.4.0
root@bcef0d1a5373:/code# ls -a ~/.gdal/2.4/srs_cache/
ls: cannot access '/root/.gdal/2.4/srs_cache/': No such file or directory
root@bcef0d1a5373:/code# ./manage.py test -vv -t uf_api/dataset/importer_test.py::TestImportShapeFile::test_invalid_testdata
root@bcef0d1a5373:/code# ls -a ~/.gdal/2.4/srs_cache/
. .. pcs.esri.gz pcs.wkt.gz
It appears that you need to attempt to access a file's CRS first to force GDAL to create the cache.
This SRS cache is news to me!
Expected behavior and actual behavior.
crs is empty when reading a file (for the first time). If file is opened to read a 2nd time, the crs appears normally.
Steps to reproduce the problem.
Note: I also tried it with the preferred
with fiona.open
syntax and the problem is unchanged by that.amb.zip shapefile
Also, strangely enough the
crs_wkt
changes when the file is reopened. I'm just reporting strange (potentially related) behavior.crs_wkt
is not something that I necessarily care if it is fixed.When the file is reopened,
crs_wkt
appears to be the same as the contents of the .PRJ file.Operating system
Windows 7
Fiona and GDAL version and provenance
Fiona 1.8.6 installed via binaries from https://www.lfd.uci.edu/~gohlke/pythonlibs/#fiona.
GDAL 2.4.1 installed via OSGeo4W
Note: I tested this on an older setup on Linux (using Fiona 1.7.7 and GDAL 1.11.3), when that was tested it gave the same results for
crs
andcrs_wkt
when opened and reopened. This was discovered when updating an old ETL process script that uses geopandas.