`fiona.transform.transform_geom(...)` missing gcs.csv


René Buffat
 

You are using Fiona pip wheels with conda which is not supported. If you use conda you should use the fiona-feedstock package: https://github.com/conda-forge/fiona-feedstock

lg rene


calebrob6@...
 

Hi all,
 
Some methods of installing fiona in a conda environment that also has GDAL result in `fiona.transform.transform_geom(src_crs, dst_crs, geom)` throwing an error, e.g.:
```
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.
```
When this happens, `geom` is returned unmodified and no Python exceptions are raised (this may be a separate problem -- it seems like this should be caught/raised).
 
I think this is related to two things:
1. Installing GDAL>=2.5 through conda will set GDAL_DATA to a directory that does not contain "gcs.csv", see https://github.com/OSGeo/gdal/issues/1471.
2. If GDAL_DATA is not set when fiona (or rasterio) are imported, then a directory packaged with the library will be used instead (which will contain "gcs.csv"). See https://github.com/Toblerity/Fiona/issues/731.
 
If you install GDAL through conda, then GDAL_DATA will be set, but will not contain "gcs.csv". This is not the entire picture though, as it does not explain why Case 2 below passes.
 
 
# Reproducing
 
The following is a test script and three methods for installing fiona (all of which I expect to result in the test script passing).
 
```test_script.py
import fiona.transform
geom = {'type': 'Polygon', 'coordinates': [[(440115.0, 4317302.0), (446180.0, 4317302.0), (446180.0, 4309726.0), (440115.0, 4309726.0), (440115.0, 4317302.0)]]}
geom = fiona.transform.transform_geom("EPSG:26918", "EPSG:4326", geom)
# The expected result is approximately `{'type': 'Polygon', 'coordinates': [[(-75.69160116601654, 39.00268487761508), (-75.62156162389587, 39.00307904086472), (-75.62096527634455, 38.9348126572227), (-75.69093763250096, 38.93441944712403), (-75.69160116601654, 39.00268487761508)]]}`
```
 
 
Installation **Case 1**
```
conda create -n testfiona1 "gdal=3.1.4" "python<3.9" -c conda-forge
conda activate testfiona1
pip install fiona
python test_script.py
conda deactivate
```
This doesn't work, installing gdal through conda sets GDAL_DATA to something that doesn't have the files that fiona needs.
 
 
Installation **Case 2**
```
conda create -n testfiona2 "gdal=3.1.4" "python<3.9" fiona -c conda-forge
conda activate testfiona2
python test_script.py
conda deactivate
```
This does work, but I'm not sure why.
 
 
Installation **Case 3**
```
conda create -n testfiona3 "python<3.9" -c conda-forge
conda activate testfiona3
pip install fiona
python test_script.py
conda deactivate
```
This also works, GDAL_DATA is never set.
 
 
Can anyone shed some light on what is happening here?
 
Best,
Caleb