Does inpolygon work for latitudes and longitudes on the surface of the earth?
8 次查看(过去 30 天)
显示 更早的评论
Just wondering if inpolygon will work correctly if using lat/lons on the surface of the earth for the points and polygons. Or would they need to be mapped to 2D/cartesian points?
0 个评论
回答(2 个)
Bruno Luong
2019-9-23
A polygon in lat/lon will NOT map to a "polygon" on the sphere. A "polygon" on the sphere composed by edges that are grand circles - geodesic of the sphere (and the sum of the angles of the corners > 360 degree), which in turns is NOT a polygon in a cartesian space.
2 个评论
Jared Hoy
2020-9-28
编辑:Jared Hoy
2020-9-28
I need to detemine if a point on the surface of the sphere is within a region on the surface of the sphere. From what is stated here, inpolygon will not work for this? I figured that inpolygon was simply determining if the coordinates of the point exceeded the values of the coordinates of the region boundaries. I dont see why this wouldn't work for a signed latitude and a longitude. If possible, could you please explain a little more why this does not work, I am not quite following.
Would there be a better tool for this? Would "ingeoquad" be better?
Thanks
Bruno Luong
2020-9-28
编辑:Bruno Luong
2020-9-28
Because a constant latitude line is NOT a great circle.
If you take a fly from europe to US/canada (or the opposite) between 2 cities that have the same latitude, you'll see the air-plane goes north to halfway then go south. It doesn't have a constant latitude on the trajectory.
If you plot a "polygon" by enlarge on the left/right airplane route on the earth surface by - said 10 km from each side - the airplane trajectory in inside this "polygon".
However if you enlarge the polygone projected on the earth longitude/latitude map of the destination/arrival by a straight line on the 2D map, the air-plane will goes out (since it goes north, the latitude is increasing for half way).
So no you cannot use in-polygon directly on longitude/latitude 2D map.
This happens if you have you polygone vertexes that are far-away so that the earth radius is not negligible.
Obviously "ingeoquad" suffers the same drawback. However at least it specifieds what it does and returns.
If you want to know how a polygonal differs from a lon/lat quadrant, takes a look at this spherical Voronoi diagram, each cell is a polygon ohn sphere, NOT a latitude longitude quadrant.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/367990/image.png)
BTW topologically there is no sense to speak about inside/outside a polygon of a sphere. Take a polygonal as the equator, whet is the inside? half-spehere north side? south side? Any polygonal divide earth surface in 2 parts, each is bounded (granted there is one larger than other in term of area), but if you cut something similar to euler spiral it quite hard to tell what is inside, what is outside.
Sean de Wolski
2020-9-28
You need to project lat/lon into x/y using an appropriate projection for the region you're focused on. Then inpolygon (or polyshape) can be used. Before that, you may want to use interpm to create many points along the boundaries.
https://www.mathworks.com/help/releases/R2020b/map/ref/projcrs.projfwd.html
0 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!