1

I cant get GeoPandas to work properly on my new laptop, with windows 10.

Installation:

  1. https://repo.anaconda.com/archive/Anaconda3-2022.10-Windows-x86_64.exe, executed as admin
  2. Anaconda prompt (as admin) and conda install geopandas

I can import geopandas fine but:

import geopandas as gpd
from shapely.geometry import Point

coords = [[15.97, 57.9], [15.92, 57.87], [15.96, 57.87], [15.99, 57.89], [15.95, 57.86], [15.92, 57.87], [15.91, 57.89], [15.96, 57.89], [15.95, 57.87], [15.96, 57.89], [15.97, 57.87], [15.93, 57.9], [15.99, 57.9], [15.92, 57.89], [15.96, 57.89], [15.94, 57.88], [15.95, 57.88], [15.92, 57.88], [15.99, 57.88], [15.96, 57.88], [15.92, 57.89], [15.99, 57.87], [15.94, 57.86], [15.98, 57.87], [15.97, 57.88], [15.97, 57.9], [15.93, 57.9], [15.94, 57.86], [16.0, 57.88], [15.93, 57.9], [15.96, 57.89], [15.99, 57.88]]
points = [Point(c) for c in coords]

df = gpd.GeoDataFrame(geometry=points, crs="epsg:4326")

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)

Without crs="epsg:4326" it is working.

I've read:

But they do not help me. It seems anaconda is using PostGIS:s pyproj, I dont know if that can be an issue?

import pyproj
pyproj.datadir.get_data_dir()
'C:\\Program Files\\PostgreSQL\\15\\share\\contrib\\postgis-3.3\\proj'

Update: I have multiple proj.db's

C:/OSGeo4W\share\proj\proj.db
C:/Program Files\PostgreSQL\15\share\contrib\postgis-3.3\proj\proj.db
C:/ProgramData\Anaconda3\Library\share\proj\proj.db
C:/ProgramData\Anaconda3\pkgs\proj-6.2.1-h3758d61_0\Library\share\proj\proj.db

Update 2:

I tried uninstalling Anaconda, OSGeo4W and PostgreSQL+PostGIS. And reinstalled Anaconda. And the code works. Installed OSGeo4W and the code works. After installing PostgreSQL 15.2 and PostGIS 3.3 Bundle 3.3.2 the error comes back.

So it seems that it is PostgreSQL and PostGIS that cause geopandas to break.

6
  • Did you install from the defaults channel or conda-forge? For best results, start with a fresh conda environment and install every package in that environment from conda-forge.
    – Paul H
    Feb 28, 2023 at 21:19
  • I have tried both conda-forge and the default, same error
    – BERA
    Mar 1, 2023 at 6:28
  • did you create a new environment or try conda-forge in an existing environment?
    – Paul H
    Mar 1, 2023 at 23:05
  • I did not create a new
    – BERA
    Mar 2, 2023 at 7:32
  • Like my answer states, you have to start with a fresh environment and every package in it needs to come from conda-forge
    – Paul H
    Mar 2, 2023 at 17:25

2 Answers 2

2

Sounds like you mixed conda channels in your environment. The best way to get the GIS stack working on any platform with conda is to create a new environment and be sure that every single package in that environment comes from the same channel. In my experience over the past 7-ish of using conda, the conda-forge channel is the better choice over the defaults channel.

So, outside of your python session:

conda create --name=gis python=3.10 geopandas rasterio --channel=conda-forge --yes
conda activate gis
python gis-script.py

Where gis-script.py is something like:

import geopandas as gpd
from shapely.geometry import Point

coords = [
    [15.97, 57.9], [15.92, 57.87], [15.96, 57.87], [15.99, 57.89], 
    [15.95, 57.86], [15.92, 57.87], [15.91, 57.89], [15.96, 57.89], 
    [15.95, 57.87], [15.96, 57.89], [15.97, 57.87], [15.93, 57.9]
]
df = gpd.GeoDataFrame(geometry=[Point(c) for c in coords], crs="epsg:4326")
2

Do you have file "proj.db" in your system? Proj reads the parameters of the coordinate systems and transformations from there. For example OSGeo4W is placing that file into \OSGeo4W\share\proj.

If you do have that file, as I suppose, then it is obviously of different version than the one that your version of the Proj library awaits. The difference is in either having or not having the attribute "area_of_use_auth_name" in the table "geodetic_crs".

The proj.db file is a SQLite database and you can open it for example with DB Browser for SQLite. The table named "metadata" stores the information about the proj.db file itself.

enter image description here

My version of proj.db does not have that certain attribute and by this mail https://lists.osgeo.org/pipermail/gdal-dev/2020-December/053177.html current Proj versions should not be asking for it. Maybe this analysis is correct also for you, perhaps with different version numbers.

This smells like a misconfiguration of your [OSGeo4W] environment. You're likely using a PROJ < 8 library with a proj.db from PROJ 7.2 or 8. Check PROJ_LIB

https://github.com/OSGeo/PROJ/search?q=area_of_use_auth_name shows there's no longer any occurence of area_of_use_auth_name in PROJ master

GDAL does not directly issue SQL requests on proj.db. It hardly knows about its existence. This is done by the PROJ.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.