I am extracting a geometry (type geometry(Geometry,4326)
) from a PostGIS database. I managed to plot them from a GeoPandas GeoDataFrame using the following code :
cursor.execute("SELECT id, ST_asText(wkb_geometry) FROM mydb")
rows=[]
for id, geom in cursor:
data = {'id': id, 'geometry': shapely.wkt.loads(geom)}
rows.append(data)
geopandas.GeoDataFrame(rows,crs='epsg:4326').plot()
Figuring WKB would be more efficient than WKT, I was expecting querying with ST_Binary()/ST_AsEWKB()/ST_AsTWKB()
and loading with shapely.wkb.loads(geom)
to be equivalent to the above, but it throws a
TypeError: bytes or integer address expected instead of memoryview instance
Why ?