MySQL Forums
Forum List  »  GIS

Strange behavior with contains function and bounding rectangle
Posted by: Carlos Quiros
Date: December 04, 2011 07:57PM

Hi,

I imported a ESRI shapefile into mysql using two methods. GDAL (ogr2ogr) and Barend Kobben's shp2mysql. The shape files contains three countries (Kenya, Uganda and Tanzania). The insert of the geometry for each shape went without warnings or errors (see script link below).

Now, when I try to find out if a point is contained by a geometry using the function 'contains' in some cases returns two records when It should be just one and seems to happen because the bound rectangle. See this example image:

http://www.qlands.com/other_files/br.jpg

If I choose points that are contained within two bound rectangles (red dot in example image), the sql returns two records, if I use a point that is just contained by one bound rectangle (blue dot in example image) the sql returns positively just one . As far as I know the original shape file does not have bound rectangles as part of the shapes.

How can I ignore the bounding rectangle so I can select a point that is just inside the geometry of a shape? I thought that was the difference between 'contains' and 'MBRcontains'.

I am using an SQL like:

SELECT OGR_FID FROM test2 where contains(ogc_geom,GeomFromText('POINT(32.17 -1.52)'));

The table is:

+----------+----------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+----------+----------+------+-----+---------+----------------+
| OGR_FID | int(11) | NO | PRI | NULL | auto_increment |
| ogc_geom | geometry | NO | | NULL | |
+----------+----------+------+-----+---------+----------------+

You can get the insert script for here:

http://www.qlands.com/other_files/test.sql (348k)

Many thanks for any help!

Carlos.

Options: ReplyQuote


Subject
Views
Written By
Posted
Strange behavior with contains function and bounding rectangle
5111
December 04, 2011 07:57PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.