Inpolygon - wrong classification for points lcoated on boundary
조회 수: 14 (최근 30일)
이전 댓글 표시
Hello everybody,
I have to classify points which are located on the boundary of a polygon shapefile, which is given in Gauss-Krüger coordinate system.
The function indicates points which are really close to the polygon boundary (but correctly not lying on it) as located on it.
Does anybody know if the inpolygon function automatically creates something like a buffer zone around points, through which nodes might be classified wrong if they are really close to the polygon boundary?
I have added an image where you can see the case I am talking about:
The exact coordinates are as follows:
Upper orange point: Lower Point of the boundary shapefile:
X: 4437431.64953548 X: 4437431.650
Y: 5350649.24495488 Y: 5350649.240
As you can see the coordinates are really close but not identical.
Does anybody know a possibility to obtain the correct result from the inpolygon function even when the upper point is only 0.1 mm away from the boundary polygon?
Thanks in advance!
Timo
댓글 수: 0
답변 (2개)
Ahmed Mahfouz
2020년 11월 8일
Hello Timo,
I have encountered this problem today, and it seems a problem that a lot of people face.
My solution was to simply change in the original funtion, by scalling the scaleFactor in line 168 with a gain of 5 to 10. This makes the tolerance big enough to include the very close points as In or On.
scaleFactor = max(scaleFactor, avx(m,:).*avy(m,:) )*5;
Of course you cannot make any changes in the original function itself, that's why you will need to copy the code from the original inpolygon funtion to a user-defined funtion file. You will then be able to change the function name (just to avoid confusion) alongside the scaleFactor, then proceed using the new user-defined function instead of inpolygon.
댓글 수: 0
Matt J
2020년 11월 8일
If you represent the polygon using a polyshape object, P, you can use isinterior() in conjunction with polybuffer(), to add a tolerance to the test of whether a point (x,y) is in the polygon,
isinterior( polybuffer(P,tolerance) , x,y)
댓글 수: 0
참고 항목
카테고리
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!