TransWikia.com

Result of ST_Contains gives false positive

Geographic Information Systems Asked on May 15, 2021

I am trying to figure out the state that Berlin is in. So now my query SELECT * FROM states WHERE ST_Contains(Geo, Point(13.383068, 52.530644)); return two results. One for Berlin which is correct, but also Brandenburg which is surrounding Berlin. See the attached graphics.
So it seems that ST_Contains does not account for the hole inside.

Currently the geospatial column is of datatype MulitPolygon.

Is there any other my-sql function that I can use to only find the correct state?

enter image description here

One Answer

MySQL contains is not standard compliant. It does not use a precise object shape, just a boundary box.

So it "ignore" holes too.

Take a look at this thread for a MySQL or PostGIS solution: https://stackoverflow.com/questions/15394645/mysql-spatial-contains-shows-wrong-result

Answered by Michele on May 15, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP