How do I know if a point (or a coordinate lon-lat) is inside of a MULTIPOLYGON using PostGIS?

I tried with ST_Contains(), but being a MULTIPOLYGON always return False.

Also I tried with ST_Dump() for transform to a simple POLYGON but I didn't get that to work.

I used:

SELECT ST_GeomFromText(the_geom,900913)

and then:

SELECT ST_Contains("previous select result", ST_GeomFromText('POINT(lon lat)',4326))
  • Did you actually create a new table with single part polygons using ST_Dump?
    – Micha
    Commented Aug 31, 2016 at 10:37
  • Make sure your geometries are valid Commented Aug 31, 2016 at 10:42
  • I use: SELECT ST_GeomFromText(the_geom,900913), and next: SELECT ST_Contains("previous select result", ST_GeomFromText(\'POINT(lon lat)\',4326))
    – josemi
    Commented Aug 31, 2016 at 10:49
  • Please edit the question to include clarifications. It's not fair to those who would answer to need to mine the comments for critical information.
    – Vince
    Commented Aug 31, 2016 at 11:07
  • 2
    ST_Contains will always return false when the point and polygon do not share a coordinate system. You need to project (ST_Transform) one or the other (or both, thought that seems wasteful).
    – Vince
    Commented Aug 31, 2016 at 11:43

1 Answer 1


The problem is that the point and the shape are not projected to the same coordinate system; one or the other needs to be converted, using ST_Transform() like this:

SELECT ST_Contains('the_geom',ST_Transform(ST_GeomFromText('POINT(lon lat)',4326),900913))

Thanks to Vince for the hint.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.