1. 程式人生 > 其它 >geotools:how to find distance from a point to closest polygon in shapefile

geotools:how to find distance from a point to closest polygon in shapefile

So I have a shp-file containing a bunch of polygons. In this case, a polygon is a body of in-land water (like lakes and that kind of stuff).

我有一個shp檔案,裡面存有一些多邊形。在本例中,多邊形代表內陸水體(像湖和類似的東西)。

My system is tracking a moving object, so in order to determine what this object is, I would like to see if this object is in water or on land AND how far it is to NEAREST shore (yes, both if it's in or out of water). I will take a sample point from the object once in a while and test it.

我的系統是追蹤移動的物體,從而決定該物體是什麼,我想要看看是否

The system is written in Java, and I have imported GeoTools snapshot 17. But if other utils is easier to use, there is no requirements to use this.

To test if the point is IN water (that is, inside a polygon), this methods works:

https://stackoverflow.com/questions/44045598/java-geotools-how-to-find-distance-from-a-point-to-closest-polygon-in-shape-fil?r=SearchResults