Find if location is land or water in WorldWind
Asked Answered
L

1

9

I know in WorldWind Java you can find out the elevation and a particular location with something like this:

public Double getPositionElevationMeters(Double lat, Double lon) {

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

    return elevation;
}

Is there a way to figure out if that lat/lon is actually a major body of water or land pro-grammatically? I've taken a "blind" approach of just considering elevation less than 0 to be water, but that's obviously not ideal.

I'd even use another library that would give me this information; I just need it to work offline.

Litman answered 25/1, 2015 at 5:58 Comment(3)
You could try gis.stackexchange.com where you might get better answers.Vining
This post forum.worldwindcentral.com/… has a response from one of the developers saying it isn't possible in the SDK, unless it has been added since 2009. He suggests two alternatives instead of looking at the elevation: "using a bitmap that has a particular color for water bodies, but which limited resolution will result in a somewhat coarse estimate of the boundaries, or using vector data that define each body perimeter as a polygon and use polygon inclusion logic to determine if a point is inside a water body or not"Ictus
I managed to find this on the WorldWind forum which gives some useful ideas, but nothing particularly concrete. forum.worldwindcentral.com/…Craig
K
6

You could possibly use a data source such as this from which you should be able to determine the polygons for all countries on Earth. Antarctica has also been added to that data set. This would get you most of the way there, depending on what you define as a "major" body of water.

From there, you can use GeoTools to import the shape data and calculate which polygons a given lat/lon pair fall in to. If none, then it is probably an ocean.

The following pseudocode illustrates the logical flow:

// 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;
}

edit

See this answer for an answer to a similar question that describes this process in a bit more detail.

Kingmaker answered 27/1, 2015 at 22:55 Comment(2)
Don't want to go bounty stealing - but this question has useful information too - especially (IMO) this answer if the OP can use python instead of / alongside Java. There are some rather nice Open Street map derived data files, here.Abacus
Hi Jeff, can you please answer one of my question related to world wind? Thanks.. questionIggie

© 2022 - 2024 — McMap. All rights reserved.