Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

GIS coordinate analysis

Status
Not open for further replies.

csbdeady

Programmer
Joined
May 18, 2002
Messages
119
Location
GB
Hi there

Something different for you all :)

I have a data set of coordinates for locations that I want to mark each as "inside" or "outside" of a bounding polygon.

For example, if I have a square 2 cm long by 2 cm wide then a coordinate of (3cm,3cm) is clearly outside of this, whereas a coordinate of (1cm,1cm) is inside.

This is relatively straightforward if the polygon is a square (or pretty much any regular shape), but what if the bounding polygon is the edge of a county or state?

In this case the bounding polygon would comprise several hundred points!

Please can anyone offer me a thought on where I can go to accomplish this task? For example, can GD / JPGraph offer any solutions here?

Many thanks as always!
-Colin
 
I don't think that GD or JPGraph can help. Both of those functions create images, not perform graphical analysis.

One solution is to project a line from your point in any one direction. If it intersects the border of your polygon an odd number of times, the point is inside the polygon. If it intersects the border of the polygon an even number if times, it's outside the polygon.

This site has some c-language code that gives you an idea of the algorithm. It should be pretty straightforward to convert it to PHP.

Want the best answers? Ask the best questions: TANSTAAFL!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top