17

I got one column (latlon) which is a ST_MultiPolygon.

The other geometry is a point which I just want to check if it is inside one of my MultiPolygons.

I tried:

SELECT ST_CONTAINS(latlon, ST_GeometryFromText('POINT(48.208417 16.372472)')
FROM districts

It always returns false; why can't I check if a point is within a multipolygon with ST_Contains?

Toby Speight
  • 27,591
  • 48
  • 66
  • 103
krackmoe
  • 1,743
  • 7
  • 29
  • 53

2 Answers2

23

it worked like this:

SELECT name, st_contains(latlon, ST_GeomFromText('POINT(16.391944 48.218056)', 4326))  FROM bezirks
krackmoe
  • 1,743
  • 7
  • 29
  • 53
  • Also, you can use a sub query to specify the B geometry. SELECT name,ST_Contains(latLon,(SELECT geom FROM b WHERE id = 3)) FROM bezirks – DirtyBirdNJ Aug 28 '13 at 20:17
3

The st_contains works with multi geometries. You must ensure that the point is on the same coordinate system of polygon geometry.

Also you must know that if the point falls into boundary of your multipolygon it will not be considered contained. In this case it will return false since no point inside of polygon geometry.

cavila
  • 7,834
  • 5
  • 21
  • 19