inpolygon usage with big matrices or faster function
Show older comments
Hello,
I have a matrix for latitudes with the size of 12200x6700 and longitudes with same size as well. I have a polygon of a river as well to check if the points are inside the polygon. However when I do
in = inpolygon(longitude,latitude,Poly.Lon,Poly.Lat);
it never ends.
If I check it by each column with for loop(6700 times), it again takes so much time.
Is there any way to fasten this single line. Like maybe using parfor by seperating the longitude and latitude?
Thanks in advance, Cheers
Accepted Answer
More Answers (1)
Is it a convex polygon? There are much faster alternatives to inpolygon for convex polygons,e.g.,
Even if it is not a convex polygon, perhaps you can frst discard points that are not in the convex hull of the polygon, thereby reducing the amount of work that inpolygon needs to do.
2 Comments
Bruno Luong
on 9 Nov 2022
"I have a polygon of a river"
Personally I never seen a convex river. ;-)
Categories
Find more on Computational Geometry in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!