krackmoe
krackmoe

Reputation: 1763

Can I check whether a multipolygon contains point in PostGIS?

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?

Upvotes: 18

Views: 22784

Answers (2)

cavila
cavila

Reputation: 7942

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.

Upvotes: 3

krackmoe
krackmoe

Reputation: 1763

it worked like this:

SELECT name, st_contains(latlon, ST_GeomFromText('POINT(16.391944 48.218056)', 4326))  FROM bezirks

Upvotes: 23

Related Questions