inpolygon usage with big matrices or faster function
35 ビュー (過去 30 日間)
古いコメントを表示
Ahmet Hakan UYANIK
2022 年 11 月 9 日
コメント済み: Ahmet Hakan UYANIK
2022 年 11 月 10 日
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
0 件のコメント
採用された回答
Bruno Luong
2022 年 11 月 9 日
At some point it was 10 time faster than MATLAB stock function.
But you can start to discard points outside the conves hull first as Matt suggests then refine with this non convex polygonal function.
その他の回答 (1 件)
Matt J
2022 年 11 月 9 日
編集済み: Matt J
2022 年 11 月 9 日
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 件のコメント
Bruno Luong
2022 年 11 月 9 日
"I have a polygon of a river"
Personally I never seen a convex river. ;-)
参考
カテゴリ
Help Center および File Exchange で Computational Geometry についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!