-
Notifications
You must be signed in to change notification settings - Fork 32
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update to use WKT vs WKB #54
base: main
Are you sure you want to change the base?
Conversation
Currently the geometry is converted to WKB, but this does not convert correctly when executing the sql statement. By using WKT, we no longer see this issue occur.
Thanks for the contribution! Which DB backend are you using? All major backends I checked support this method, so I'm a bit surprised. One thing you could do is to subclass the |
PostgreSQL |
@mkeller3 I'm a bit confused: https://postgis.net/docs/ST_GeomFromWKB.html |
PostgreSQL does support that method, but the way shapely is converting the input to bytes is not compatible with PostgreSQL. I provided the example above to show what happens if you try to use the WKB method in PostgreSQL. It returns an error. |
Right, now I understand. I will look at how we can format the WKB to be loadable in Postgres |
Do you want to continue to try and use shapely, or would you be open to other options? |
Hi both, thanks for working on this. I was also just running in this issue. Another option could be changing the passed WKB-String to this. SELECT ST_GeomFromWKB(E'\\x0101000000FB2477D8444056C06C4084B872404440') |
Currently the geometry is converted to WKB, but this does not convert correctly when executing the sql statement. By using WKT, we no longer see this issue occur.
Example:
INTERSECTS(geom, POINT(-89.004202 40.503501))
Converts to:
ST_Intersects("geom",ST_GeomFromWKB(x'0101000000FB2477D8444056C06C4084B872404440'))
Running the following SQL:
SELECT ST_GeomFromWKB(x'0101000000FB2477D8444056C06C4084B872404440')
You receive the following error:
ERROR: function st_geomfromwkb(bit) does not exist LINE 1: SELECT ST_GeomFromWKB(x'0101000000FB2477D8444056C06C4084B872... ^ HINT: No function matches the given name and argument types. You might need to add explicit type casts. SQL state: 42883 Character: 8
After converting to use
ST_GeomFromText
this issue no longer occurs.