geopandas: Error using to_crs() -- no such file or directory - ONLY on windows

Hi Colleagues. Some of my students are running into errors when they reproject using this code:

object.to_crs(another_object.crs)

---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
<ipython-input-5-eb6d1da3880a> in <module>()
----> 1 sjer_aoi_wgs84  = sjer_aoi.to_crs(sjer_roads.crs)

~\Anaconda3\envs\earth-analytics-python\lib\site-packages\geopandas\geodataframe.py in to_crs(self, crs, epsg, inplace)
    441         else:
    442             df = self.copy()
--> 443         geom = df.geometry.to_crs(crs=crs, epsg=epsg)
    444         df.geometry = geom
    445         df.crs = geom.crs

~\Anaconda3\envs\earth-analytics-python\lib\site-packages\geopandas\geoseries.py in to_crs(self, crs, epsg)
    302             except TypeError:
    303                 raise TypeError('Must set either crs or epsg for output.')
--> 304         proj_in = pyproj.Proj(self.crs, preserve_units=True)
    305         proj_out = pyproj.Proj(crs, preserve_units=True)
    306         project = partial(pyproj.transform, proj_in, proj_out)

~\Anaconda3\envs\earth-analytics-python\lib\site-packages\pyproj\__init__.py in __new__(self, projparams, preserve_units, **kwargs)
    356         # on case-insensitive filesystems).
    357         projstring = projstring.replace('EPSG','epsg')
--> 358         return _proj.Proj.__new__(self, projstring)
    359 
    360     def __call__(self, *args, **kw):

_proj.pyx in _proj.Proj.__cinit__()

RuntimeError: b'No such file or directory'

i have not been able to recreate it on my mac but can on windows 10. I found this issue which looks related: https://github.com/jswhit/pyproj/issues/101

and this SE post

https://gis.stackexchange.com/questions/295914/error-in-coordinate-transformation-with-geopandas

to which @jorisvandenbossche suggested removing proj4 and pyproj. i tried that but it did not fix the issue. also when you remove proj4 you have to remove gdal and rasterio and cartopy… so all of a sudden my environment is gone. I also did a full fresh reinstall of the environment.

Any ideas how I can resolve this issue? And why is it so windows specific!? note - i’m on a pretty fresh windows install and do not have arcgis or anything else here. just git, python / conda and a few other basic tools for text editins and such. im using python 3.x.

Many thanks for any suggestions.

About this issue

  • Original URL
  • State: open
  • Created 6 years ago
  • Comments: 20 (17 by maintainers)

Most upvoted comments

On my machines I got it working via:

import os
os.environ["PROJ_LIB"] = "C:\Anaconda\envs\env_name\Library\share" #windows
os.environ["PROJ_LIB"] = ".../Anaconda/envs/env_name/Library/share" #linux

On my machines I got it working via:

import os
os.environ["PROJ_LIB"] = "C:\Anaconda\envs\env_name\Library\share" #windows
os.environ["PROJ_LIB"] = ".../Anaconda/envs/env_name/Library/share" #linux

This worked for me. Thanks @gboeing !

@lwasser You should be able to lock the pyproj version to 1.9.4 or specifically using this build for your students case.

This actually looks related, though distinct, to what @jwilson8767’s PR in https://github.com/geopandas/geopandas/pull/678 is seeing on our AppVeyor build. Fresh install on windows, and the pyproj_datadir isn’t being found (or at least the epsg sub-directory), though it is not returning an empty string, and all the reprojection tests actually are passing.

BINGO!! i updated my envt and ran the above and it worked like a charm!! thank you again @gboeing @jorisvandenbossche i much prefer this solution as it allows me to keep my envt in tact and up to date!!

On linux this is located in .../Anaconda3/envs/env_name/share/proj, not sure by heart what the windows equivalent is exactly

So I poked back through conda-forge builds of pyproj for win64 and found that builds since this commit have lacked the data directory entirely (where they were present in builds prior to that commit). It appears that this commit 3 days ago may have fixed this issue, but I’m not sure as there are no conda-forge builds since then.

I don’t know conda-forge, is that something we can just conda smithy rerender to get a new build out for this version of pyproj?