'CRSError: Invalid projection: epsg:4326: for geopandas

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?



Solution 1:[1]

The correct syntax is as the following:

proj_4326 = Proj("epsg:4326")
proj_3857 = Proj("epsg:3857")

Solution 2:[2]

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)

Solution 3:[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.

Solution 4:[4]

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()

Solution 5:[5]

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)

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 swatchai
Solution 2
Solution 3 ReinholdN
Solution 4
Solution 5 Jeremy Caney