在 WorldWind 中查找位置是陆地还是水域

Find if location is land or water in WorldWind

我知道在 WorldWind Java 你可以用这样的东西找出海拔和特定位置:

public Double getPositionElevationMeters(Double lat, Double lon) {

    double elevation = getWorldWindCanvas().getModel().getGlobe()
            .getElevation(Angle.fromDegrees(lat), Angle.fromDegrees(lon));

    return elevation;
}

有没有办法从程序上判断 lat/lon 是否真的是一大片水域或陆地?我采用了 "blind" 方法,仅将海拔高度小于 0 视为水,但这显然不理想。

我什至会使用另一个能给我这些信息的图书馆;我只需要它离线工作。

您可以使用数据源 such as this,您应该能够从中确定地球上所有国家/地区的多边形。南极洲也已添加到该数据集中。根据您对 "major" 水域的定义,这将帮助您完成大部分工作。

从那里,您可以使用 GeoTools 导入形状数据并计算给定的 lat/lon 对属于哪些多边形。如果none,那么它很可能是一片海洋。

以下伪代码说明了逻辑流程:

// pseudocode, not the actual GeoTools API
boolean isWater(Coordinate point) 
{
    ShapeDataStore countryShapes = loadShapeData("world.shp");

    GeoShape shape = countryShapes.findShapeByPoint(point);

    if (shape == null)
        return true // not a country or Antarctica, must be international waters.
    else
        return false;
}

编辑

请参阅 this answer 以获取对更详细地描述此过程的类似问题的回答。