hello

I have a problem loading with shapely a geometry returned by a query in postgis.

the system I use return the geometry as it is stored in postgis, something like this:

01060000E0155500000100000001030000C00100000008000000018A91D517D91E41016E16EFCB4201410000000000000000FFFFFFFFFFFFEFFFB2D82685BAD91E413B8BDEA9BE4101410000000000000000FFFFFFFFFFFFEFFF19726C7D72D91E410229B10B0D4101410000000000000000FFFFFFFFFFFFEFFF8B51D77A2FD91E414CA8E0308D4101410000000000000000FFFFFFFFFFFFEFFFC45DBDBAFBD81E41B83CD60CFA4101410000000000000000FFFFFFFFFFFFEFFF5C72DCE9EFD81E416B64577A354201410000000000000000FFFFFFFFFFFFEFFFBB421F0CFAD81E41B7B41A92914201410000000000000000FFFFFFFFFFFFEFFF018A91D517D91E41016E16EFCB4201410000000000000000FFFFFFFFFFFFEFFF

I have found on the web an example of loading such string in shapely using:

from shapely.wkb import loads
geo=loads(data.decode('hex'))

but this only result in the error:
shapely.geos.ReadingError: Could not create geometry because of errors while
reading input.

loads should receive a wkb and data.decode('hex') does not seem to produce a valid wkb

data.decode('hex') produce something like this:

\x01\x06\x00\x00\xe0\x15U\x00\x00\x01\x00\x00\x00\x01\x03\x00\x00\xc0\x01\x00\x00\x00\x08\x00\x00\x00\x01\x8a\x91\xd5\x17\xd9\x1eA\x01n\x16\xef\xcbB\x01A\x00\x00\x00\x00\x00\x00\x00\x00\xff\xff\xff\xff\xff\xff\xef\xff\xb2\xd8&\x85\xba\xd9\x1eA;\x8b\xde\xa9\xbeA\x01A\x00\x00\x00\x00\x00\x00\x00\x00\xff\xff\xff\xff\xff\xff\xef\xff\x19rl}r\xd9\x1eA\x02)\xb1\x0b\rA\x01A\x00\x00\x00\x00\x00\x00\x00\x00\xff\xff\xff\xff\xff\xff\xef\xff\x8bQ\xd7z/\xd9\x1eAL\xa8\xe00\x8dA\x01A\x00\x00\x00\x00\x00\x00\x00\x00\xff\xff\xff\xff\xff\xff\xef\xff\xc4]\xbd\xba\xfb\xd8\x1eA\xb8<\xd6\x0c\xfaA\x01A\x00\x00\x00\x00\x00\x00\x00\x00\xff\xff\xff\xff\xff\xff\xef\xff\\r\xdc\xe9\xef\xd8\x1eAkdWz5B\x01A\x00\x00\x00\x00\x00\x00\x00\x00\xff\xff\xff\xff\xff\xff\xef\xff\xbbB\x1f\x0c\xfa\xd8\x1eA\xb7\xb4\x1a\x92\x91B\x01A\x00\x00\x00\x00\x00\x00\x00\x00\xff\xff\xff\xff\xff\xff\xef\xff\x01\x8a\x91\xd5\x17\xd9\x1eA\x01n\x16\xef\xcbB\x01A\x00\x00\x00\x00\x00\x00\x00\x00\xff\xff\xff\xff\xff\xff\xef\xff

but if I use ST_AsBinary(the_geom) in postgres to generate a wkb, I get something like this:

001\006\000\000\000\001\000\000\000\001\003\000\000\000\001\000\000\000\010\000\000\000\001\212\221\325\027\331\036A\001n\026\357\313B\001A\262\330&\205\272\331\036A;\213\336\251\276A\001A\031rl}r\331\036A\002)\261\013\015A\001A\213Q\327z/\331\036AL\250\3400\215A\001A\304]\275\272\373\330\036A\270<\326\014\372A\001A\\r\334\351\357\330\036AkdWz5B\001A\273B\037\014\372\330\036A\267\264\032\222\221B\001A\001\212\221\325\027\331\036A\001n\026\357\313B\001A

if I try to load that string with loads in shapely.wkb, it works perfectly and the geometry is correct

decode('hex') doesnt not seem to be the correct way to convert postgis geom string into wkb, so what python command should I use to produce a valid wtb from the postgis geom string ?

thanks in advance
best regards
Oliver
_______________________________________________
Community mailing list
[email protected]
http://lists.gispython.org/mailman/listinfo/community

Reply via email to