Inpolygon - wrong classification for points lcoated on boundary
17 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
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 Commenti
Risposte (2)
Ahmed Mahfouz
il 8 Nov 2020
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 Commenti
Matt J
il 8 Nov 2020
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 Commenti
Vedere anche
Categorie
Scopri di più su Computational Geometry in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!