pythonpostgiswkb

WKBReadingError: Could not create geometry because of errors while reading input


I want to upload data with postgis using an sql query. See below the code

df = gpd.GeoDataFrame.from_postgis('select ST_ASTEXT(point_sm) as geom from df.df' , con=engine, geom_col='geom')

I get this error:

ParseException: Invalid HEX char

WKBReadingError: Could not create geometry because of errors while reading input.

I haven't tried much to be honest. I am new to this and couldn't figure out where to start.


Solution

  • You are requesting a text but the function expects a geometry expressed in WKB.

    Try changing the query to

    select point_sm as geom from df.df