rughimire
rughimire

Reputation: 384

Unable to use ST_Intersects on geometry field

I have converted the Personal Geodatabase of ESRI (*.mdb file) into the PostGIS enabled PostgreSQL database using FWTools. On which I get my geometry field named as wkb_geometry as follows

wkb_geometry geometry(Geometry, 3148),

While querying the database using ST_Intersects on where I get following error

SQL

SELECT <other fields>, 
"wkb_geometry" AS "_smtmp_" FROM parcel WHERE  <condition>  
AND ST_Intersects(((E'\\001\\003\\000\\000 L\\014\\000\\000\\001\\000\\000\\000\\005\\000\\000\\000\\020\\2625\\334i\\032\\034A\\273n\\256E\\033\\340GA\\020\\2625\\334i\\032\\034A\\017\\261\\014\\353\\037\\340GA\\262\\304\\047\\007\\217\\032\\034A\\017\\261\\014\\353\\037\\340GA\\262\\304\\047\\007\\217\\032\\034A\\273n\\256E\\033\\340GA\\020\\2625\\334i\\032\\034A\\273n\\256E\\033\\340GA')) 
                    ,"wkb_geometry")

Error

ERROR: parse error - invalid geometry
LINE 1: ... parcel WHERE parcelno < 50 AND ST_Intersects(((E'\001\0... HINT: "\0" <-- parse error at position 2 within geometry

ERROR: parse error - invalid geometry
SQL state: XX000
Hint: "\0" <-- parse error at position 2 within geometry
Character: 245

I am using SharpMap in front end.

Upvotes: 0

Views: 317

Answers (1)

fradal83
fradal83

Reputation: 2022

The problem here is not with the geometry field, but with the query.

You should use the ST_GeomFromEWKB function like this

SELECT <other fields>, 
"wkb_geometry" AS "_smtmp_" FROM parcel WHERE  <condition>  
AND ST_Intersects(ST_GeomFromEWKB(E'\\001\\003\\000\\000 L\\014\\000\\000\\001\\000\\000\\000\\005\\000\\000\\000\\020\\2625\\334i\\032\\034A\\273n\\256E\\033\\340GA\\020\\2625\\334i\\032\\034A\\017\\261\\014\\353\\037\\340GA\\262\\304\\047\\007\\217\\032\\034A\\017\\261\\014\\353\\037\\340GA\\262\\304\\047\\007\\217\\032\\034A\\273n\\256E\\033\\340GA\\020\\2625\\334i\\032\\034A\\273n\\256E\\033\\340GA') 
                    ,"wkb_geometry")

Upvotes: 1

Related Questions