inpolygon usage with big matrices or faster function

조회 수: 30 (최근 30일)
Ahmet Hakan UYANIK
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

채택된 답변

Bruno Luong
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
Ahmet Hakan UYANIK
Ahmet Hakan UYANIK 2022년 11월 10일
Regarding big size of matrices, this tool works way more faster than MATLAB stock function(even much more faster than 10 times :) Thanks in advance.

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Matt J
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
Bruno Luong 2022년 11월 9일
"I have a polygon of a river"
Personally I never seen a convex river. ;-)
Matt J
Matt J 2022년 11월 10일
편집: Matt J 2022년 11월 10일
Some sections of the Amazon boundary some fairly convex-looking bits of land:

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Computational Geometry에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by