geopandas: CRSError: Invalid projection: EPSG:4326
Hi, I’m working in a jupyter notebook and trying to specify the CRS of a geopandas dataframe, like so:
import geopandas as gpd
import pyproj
coords = df[['latitude','longitude']]
raw_gpspoints_gdf = gpd.GeoDataFrame(
coords, geometry=gpd.points_from_xy(coords['longitude'], coords['latitude']), crs="EPSG:4326")
However, every time I get the 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)
My versions are:
import sys
import pyproj
import geopandas
print(sys.version)
print(pyproj.__version__)
print(geopandas.__version__)
3.8.6 | packaged by conda-forge | (default, Oct 7 2020, 19:08:05)
[GCC 7.5.0]
2.6.1.post1
0.8.1
and my pyproj directory is
pyproj.datadir.get_data_dir()
'/opt/conda/lib/python3.8/site-packages/pyproj/proj_dir/share/proj'
How do I resolve this issue?
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 6
- Comments: 23 (9 by maintainers)
This is an issue with
pyproj
package. They even cover this exact error in their documentation: https://pyproj4.github.io/pyproj/stable/gotchas.html#internal-proj-error-sqlite-error-on-select. Yourpyproj
points to a database created for a different version. You need to specify the path to a correct data directory (see the docs). Proper reinstallation also often helps.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)
@jeanbaptisteb You can use
conda
withoutAnaconda
withminiconda
or its alternatives likeminiforge
ormambaforge
. You can also usemicromamba
and use mamba instead of conda.This is false.
@WaelJRD it seems you have a mixture of pip and conda packages. If you are using Anaconda, we strongly recommend installing geopandas and all its dependencies (pyproj, fiona, shapely) using conda from conda-forge (see https://geopandas.org/en/stable/getting_started/install.html#using-the-conda-forge-channel). In your case, I can see that pyproj is installed as a wheel, but based on the GDAL version, that is installed using conda (and thus also PROJ is installed using conda).
And to be clear, you don’t have to use conda, you can use pip. In this specific issue however it’s mixing of conda and pip that gave problems.
@basillatif this StackExchange thread may help you. https://gis.stackexchange.com/questions/383883/pyproj-invalid-projection-init-epsg25832/431688#431688
Hi. On Windows 10, I finally had
crs=CRS("epsg:3857)
recognized by installing geopandas version 0.9.0 instead of the version (0.6.X both on Anaconda and pip from the OS). I had also to assign a crs on a shapefile this way…to be able to reproject from “epsg:4326” to “epsg:3857”. With version 0.9.0 it wasn’t needed to link geopandas to an external Proj4 database…