Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I'm developing a spatial database of administrative areas. I started out with PostGIS, but as MySQL is being used in our other projects, I thought I would at least try to create a spatial-enabled MySQL database.

However, spatial queries give me different results than PostGIS does. Let's say I have a query like this

SELECT nazev FROM orp as o, kraje as k WHERE Intersects(o.geom,k.geom) AND Within(Centroid(o.geom),k.geom) AND k.nazev = 'Nazev'.

It should return a list of administrative areas within a county with defined name (nazev). Instead, it gives me expected areas + areas that touch boundary of a county, but are not contained by this county. When I run the same query with PostGIS, I get the correct results.

Have anyone ever faced this issue? I am using a national CRS (EPSG:102067) and have tried also with EPSG:4326 with same result. Isn't the implementation of the OGC spec the same as in PostGIS? Thanks for any hint.

share|improve this question
If i recall correctly mysql used to do comparison with bounding boxes. But i think it has lately started to do real spatial comparison. so it might be because you have old mysql or it is feature. can you post your mysql version numbr –  simplexio Jan 17 '13 at 11:00
MySQL 5.5. It seems there are two sets of functions defined: one beginning with "MBR" and the other one using the real geometry. –  zimmi Jan 17 '13 at 11:11
MySQL is not quite the with spatial functions - Bound Box is use (MBR) bostongis.com/blog/index.php?/archives/… –  Mapperz Jan 17 '13 at 14:35
MySQL 5.6 is the first release with true spatial relationships dev.mysql.com/doc/refman/5.6/en/… –  Mapperz Jan 17 '13 at 14:37
The implementation of Centroid() might also be a gotcha, since it often is implemented as a center-of-mass, which for concave features might not fall within the feature. Probably not your problem, but always a surprise to new users. –  Paul Ramsey Jan 17 '13 at 18:48

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.