I am using the Google Maps API, in which as of now we are plotting the track of a vessel track, but the system is now allowing us to update even a Lat/Long which is on land. Is there is any way to stop this and check that the system should allow only updates to a lat/long that is in the sea?


As @blah238 wrote, several ideas can be found from https://stackoverflow.com/questions/9644452/verify-if-a-point-is-land-or-water-in-google-maps

If you trust on the map color then you could check if the place at each Lat/Long is painted with the sea color or something else. You can demonstrate this with gdallocationinfo and GDAL WMS driver. Read about these from



Save the Google Maps definition file from the WMS driver page on disk as "frmt_wms_googlemaps_tms.xml". I copied contents of the file here


<!-- Data is subject to term of use detailed at http://code.google.com/intl/nl/apis/maps/terms.html and
     http://www.google.com/intl/en_ALL/help/terms_maps.html -->

    <Service name="TMS">
        <ServerUrl>http://mt.google.com/vt/lyrs=m&amp;x=${x}&amp;y=${y}&amp;z=${z}</ServerUrl> <!-- Map -->
        <!-- <ServerUrl>http://mt.google.com/vt/lyrs=s&amp;x=${x}&amp;y=${y}&amp;z=${z}</ServerUrl> --> <!-- Satellite -->
        <!-- <ServerUrl>http://mt.google.com/vt/lyrs=y&amp;x=${x}&amp;y=${y}&amp;z=${z}</ServerUrl> --> <!-- Hybrid -->
        <!-- <ServerUrl>http://mt.google.com/vt/lyrs=t&amp;x=${x}&amp;y=${y}&amp;z=${z}</ServerUrl> --> <!-- Terrain -->
        <!-- <ServerUrl>http://mt.google.com/vt/lyrs=p&amp;x=${x}&amp;y=${y}&amp;z=${z}</ServerUrl> --> <!-- Terrain, Streets and Water  -->
    <Cache />

Now you must just run gdallocationinfo from this Google Maps definition file. This example checks what is at WGS84 coordinates (0,0)

gdallocationinfo -wgs84 frmt_wms_googlemaps_tms.xml 0 0
Location: (134217728P,134217728L)
Band 1:
Value: 148
Band 2:
Value: 107
Band 3:
Value: 76

I have no idea if all that has RGB values (148,107,76) in Google Maps is sea. All that is sea does obviously has this value because of labels.

| improve this answer | |

There is a free web API that solves exactly this problem called onwater.io. Given a latitude and longitude it will accurately return true or false via a get request.

Example on water: https://api.onwater.io/23.92323,-66.3

  lat: 23.92323,
  lon: -66.3,
  water: true

Example on land: https://api.onwater.io/42.35,-71.1

  lat: 42.35,
  lon: -71.1,
  water: false
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.