5

I am using anaconda for geopandas. However, everytime I try to use epsg:4326:, it gives an error.

CRSError: Invalid projection: epsg:4326: (Internal Proj Error: proj_create: SQLite error on SELECT name, type, coordinate_system_auth_name, coordinate_system_code, datum_auth_name, datum_code, area_of_use_auth_name, area_of_use_code, text_definition, deprecated FROM geodetic_crs WHERE auth_name = ? AND code = ?: no such column: area_of_use_auth_name)

How can I solve this problem?

I tried:

from functools import partial
from pyproj import Proj, transform
proj_4326 = Proj(init="epsg:4326")
proj_3857 = Proj(init="epsg:3857")

I also tried to reset the environment:

conda update anaconda

but they both gave the same CRSError

My versions are:

import sys
import pyproj
import geopandas
print(sys.version)
print(pyproj.__version__)
print(geopandas.__version__)
3.8.5 (default, Sep  4 2020, 02:22:02) 
[Clang 10.0.0 ]
2.6.1.post1
0.8.2

How can I resolve this?

Lyliie
  • 115
  • 1
  • 2
  • 7

8 Answers8

3

I had the same problem. After a bit of a research I found out that anaconda will have a specific directory for geopandas and once it looks for pyproj there it won't find because in my case it was installed with pip as it was an ordeal to install geopandas in Windows(I usually work with Linux). The solution was remove geopandas with conda, then remove pyproj with pip. After it all is clean(try conda list to double check) I just use conda install -c conda-forge geopandas and voilà! I decided to share in case someone faces this annoyance. There is no point to look for the right format for your geodata.

ReinholdN
  • 526
  • 5
  • 22
1

The correct syntax is as the following:

proj_4326 = Proj("epsg:4326")
proj_3857 = Proj("epsg:3857")
swatchai
  • 17,400
  • 3
  • 39
  • 58
1

On Windows 10, I finally had crs=CRS("epsg:3857) recognized by installing geopandas version 0.9.0 instead of the version installed by default (0.6.X both on Anaconda and pip from the OS). I had also to assign a crs on a shapefile this way :

prov_shp=geopandas.read_file(fichier_dist )
prov_shp.set_crs(epsg=4326, inplace=True)

...to be able to reproject from EPSG:4326 to EPSG:3857 :

crs=CRS("epsg:3857")
prov_shp = prov_shp.to_crs(crs)
0

This code give you basic projection, known as WGS84:

from pyproj import CRS

crs=CRS('EPSG:4326')

if you need proj4, do this:

from pyproj import CRS

crs=CRS('EPSG:4326').to_proj4()
tonysdev
  • 126
  • 5
  • 2
    Please don't post only code as an answer, but also provide an explanation of what your code does and how it solves the problem of the question. Answers with an explanation are usually more helpful and of better quality, and are more likely to attract upvotes – Ran Marciano Apr 05 '21 at 11:27
0

https://github.com/geopandas/geopandas/issues/1887

I've found this:

Specifically in your case, it seems that you installed pyproj using pip (as a wheel, because it looks for PROJ data inside the pyproj package), and not with conda (although you are using a conda environment). It's best to install all those packages with conda (especially for non-pure python packages such as pyproj)

Jeremy Caney
  • 7,102
  • 69
  • 48
  • 77
  • While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. - [From Review](/review/late-answers/31583993) – Scott Boston Apr 24 '22 at 02:33
0

this is a version issue, re-installed pyproj to 3.31 is able to solve problems

pip install pyproj==3.31 --user

xing zeng
  • 1
  • 1
0

Following ReinholdN's advice, I simply set the directory to the pyproj directory, as per the documentation. In my case, it was in a different env, so anaconda3\envs\{env name}\Library\share\proj.

And I set it like this:

pyproj.datadir.set_data_dir('directory')

pyproj.datadir.get_data_dir() #check that it was set correctly

Ignacio
  • 53
  • 6
-1

conda create -n pyproj

conda activate pyproj

conda config --add channels conda-forge

conda config --set channel_priority strict

conda install pyproj

update: answer (y)

conda deactivate

conda env remove -n pyproj