3

I have got data using OpenStreetMaps Ways of many areas. I would now like to write a function which would return "true or false" if an single latitude/longitude point is found in that area or not.

I have already seen many answers to this question such as this answer however none of these deal with the issue when the Greenwich meridian line is crossed. Most of my area searches will occur in London which means I need a function that can cope with both negative and positive values for the lat/long points in the area.

Is there a known way on how to solve this?

0

It doesn't matter if the Greenwich meridian (longitude = 0) is crossed. The standard point-in-polygon algorithms work with both positive and negative values for coordinates. The only difficulty is if the polygon has lines which cross the anti-Greenwich meridian (longitude = plus or minus 180) and which therefore jump from -180 to +180.

My solution is to convert both the polygon and the point to be tested into the Lambert azimuthal equal-area projection, centred at the North Pole, then use the Horman-Agathos algorithm to see if the point is in the polygon. This is fine as long as the polygon doesn't contain the South pole, which in practice is unlikely.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.