MySQL Forums
Forum List  »  GIS

Border-Line Cases: Point-in-Polygon Function Results in Duplicates When the Point is on the Border
Posted by: Christopher Fridlund
Date: June 28, 2010 09:21AM


I posted this question in the Newbie forum. I didn't know about the GIS forum--sorry about that. So here goes:

I'm using MySQL to pull lat longs from a database and check whether or not they are in a particular neighborhood.

Everything works great, except if the point is on the border between two neighborhoods. Then, the point is included in both neighborhoods. It gets duplicated. What's the best way to handle points that are on borders?

Each point should be counted in only one neighborhood-- not both. Also, I don't want, for example, neighborhood A to get all of the border cases, but the bordering neighborhood, neighborhood B, to get zero cases.

Imagine that the point 30.3030, -70.7070 lies on the border between Newport and Oldport. Unfortunately, the point gets counted twice. It gets recorded as being in both Oldport and Newport.

small |  30.3030  | -70.7070  | Newport
small |  30.3030  | -70.7070  | Oldport
small |  30.3344  | -70.7274  | Anotherport

My select statement looks like this:

SELECT t.type, t.latitude, t.longitude, s.neighborhoods
  FROM my_type_table t, neighborhood_shapes s
WHERE myWithin(POINTFROMTEXT( CONCAT( 'POINT(', t.latitude, ' ', t.longitude, ')' ) ) , s.neighborhood_polygons )) = 1

I'm using the myWithin function found here:,366732,366732 to determine whether the point is in the polygon.

FYI, I posted a similar question on Stack Overflow a few days ago.

What would you do? What's the best solution? Any suggestions?

Thank you.


Options: ReplyQuote

Written By
Border-Line Cases: Point-in-Polygon Function Results in Duplicates When the Point is on the Border
June 28, 2010 09:21AM

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.