Link to home
Start Free TrialLog in
Avatar of websss
websssFlag for Kenya

asked on

Find if a geographical point lies within a set of points making a polygon

Given a set of geographical coordinates making up a polygon, how would I determine if another geographical point (x-latitude, y-longitude) lies either within the polygon, or outside the polygon. The set of coordinates is stored in a table in an SQL server database.
Avatar of Paul 1
Paul 1
Flag of United Kingdom of Great Britain and Northern Ireland image

The first process is to create a virtual box around the polygon. This gives you a top, bottom, left and right value to see if the target point is close ( T > bottom, T < Top, T > Left and T < Right)

If the value is confirmed then you work out the 3 nearest point to form a triangle and then calculate - check this to see the theory - http://www.blackpawn.com/texts/pointinpoly/

also this explains - http://stackoverflow.com/questions/2049582/how-to-determine-a-point-in-a-triangle
Are you using  LatLon, UTM, UPS, MGRS, MGRS Polar, USNG (identical to MGRS), Georef, or State Plane coordinate systems?  Depending on the coordinate format, it'll be an algebraic equation.

- gurutc
Also, what type of polygon?  How many points?
SOLUTION
Avatar of Olaf Doschke
Olaf Doschke
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of websss

ASKER

@gurutc, I am using LatLon
Degree-Decimal?
Avatar of websss

ASKER

Decimal..
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial