Kabrüggen
Kabrüggen

Reputation: 1

geopandas.GeoPandasDataFrame.from_postgis() raises "Unknown WKB type 41"

I am struggeling with the following issue:

While running my Python3.8.10 interpreter with Jupyter Notebook (setting A), I can successfully connect to my Postgis database and query the data while writing it to geopandas.GeoDataFrame. For that, I use the following snippet:

from sqlalchemy import create_engine
import geopandas as gpd

print(gpd.__version__)
>>> 0.12.2


# Connection settings
db_connection_url = "postgresql://%s:%s@%s:%s/%s"%(settings.database.user, settings.database.pw, 
                                                   settings.database.url, str(settings.database.port), 
                                                   settings.database.table)

# Get data
data = gpd.GeoDataFrame.from_postgis(sql="select * from curvature", con=create_engine(db_connection_url), geom_col='geometry',
crs="EPSG:25833")

However, when I switch from the Notebook implementation to the native Python file (setting B), I get the following error message:

File "C:\Users\ABC\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\shapely\io.py", line 325, in from_wkb return lib.from_wkb(geometry, invalid_handler, **kwargs) shapely.errors.GEOSException: ParseException: Unknown WKB type 41

which cames from:

File "C:\Users\ABC\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\geopandas\io\sql.py", line 87, in _df_to_geodf df[geom_col] = geoms = geoms.apply(load_geom)

I ensured that I use the same packages by comparingos.path. It points in both settings to:

'C:\\Program Files\\WindowsApps\\PythonSoftwareFoundation.Python.3.8_3.8.2800.0_x64__qbz5n2kfra8p0\\lib\\stat.py'

To doublecheck my connection, I tried to query the data with the connection and store it in an pandas.DataFrame in setting B:

import pandas as pd

df = pd.read_sql_query('''SELECT * from curvature''', create_engine(db_connection_url))

with print(df.head(2)) I can access my data as expected:

   geometry                    id, name, type radius curvature
0  LINESTRING((47.XX 15.XX    130.0    130.0  XXX [0.0, ...  [inf, ...
1  LINESTRING((47.XX XX...  46624.0  46624.0  XXX [0.0, ...  [inf, ...

Has anyone observed the same behavior and has already solved this problem, as I can not find anything specific about WKB type 41.

Best Daniel

Upvotes: 0

Views: 471

Answers (0)

Related Questions