1

I have a vector file (in this case shp file) and I read it with GeoPandas (gpd).

vector_folder = r'C:\poly'
vector_file = 'poly.shp'
df = gpd.read_file(os.path.join(vector_folder,vector_file))
df

    id  geometry
0   1   POLYGON ((169628.5983266232 620402.5901412303,...
1   2   POLYGON ((169533.9289514195 620036.5352237758,...
2   3   POLYGON ((169066.8933670809 619834.5738900078,...

The crs is:

df.crs
{'init': 'epsg:2039'}

I would like to reproject it to espg=32636. According to GeoPandas page this should work:

df = df.to_crs({'init': 'epsg:32636'})
df = df.to_crs(epsg=32636)

However, I get this error:

RuntimeError                              Traceback (most recent call last)
<ipython-input-39-1fa06f642778> in <module>
----> 1 df = df.to_crs({'init': 'epsg:32636'})

~\Anaconda2\envs\python3\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

~\Anaconda2\envs\python3\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)

~\Anaconda2\envs\python3\lib\site-packages\pyproj\__init__.py in __new__(self, projparams, preserve_units, **kwargs)
    360         # on case-insensitive filesystems).
    361         projstring = projstring.replace('EPSG','epsg')
--> 362         return _proj.Proj.__new__(self, projstring)
    363 
    364     def __call__(self, *args, **kw):

_proj.pyx in _proj.Proj.__cinit__()

RuntimeError: b'no arguments in initialization list'

I also tried:

epsg_code = 32636
srs = osr.SpatialReference()
srs.ImportFromEPSG(epsg_code)
new = srs.ExportToProj4()
new

'+proj=utm +zone=36 +datum=WGS84 +units=m +no_defs '

df.to_crs(crs=new)

But I get the same error. I get the same error also with GeoJSON formats.

System specifications: anaconda, Python 3, Windows 10, geopandas=0.4.0, proj4=5.2.0

  • you might need to update proj4 – Paul H Mar 20 at 21:43
  • (proj4 v6 is available in conda-forge) – Paul H Mar 20 at 21:44
  • @PaulH I tried to update via conda update proj4 and also to do conda install -c conda-forge proj4 but the version stayed the same (5.2.0) – user88484 Mar 21 at 6:49
  • i think you need conda update proj4 --channel=conda-forge – Paul H Mar 21 at 15:58
  • No.. I get: All requested packages already installed. and the version is still 5.2.0 – user88484 Mar 21 at 18:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.