Verify If a Point Is Land or Water in Google Maps

how to know whether a point is on land or water using google maps api

You can filter results of reverse geocoding by result type and location type. In result type you can look for natural_feature and location type should be GEOMETRIC_CENTER or APPROXIMATE to exclude any ROOFTOP address that can be close to given point on the land.

Please have a look at the following request:

https://maps.googleapis.com/maps/api/geocode/json?latlng=40%2C-74&result_type=natural_feature&location_type=GEOMETRIC_CENTER%7CAPPROXIMATE&key=YOUR_API_KEY

The first two items in response are:

  • North Atlantic Ocean (type: natural_feature, place ID: ChIJeQ3JDsMo3QoRBGVpwFckZUQ)
  • Atlantic Ocean (type: natural_feature, place ID: ChIJ_7hu48qBWgYRT1MQ81ciNKY)

Now if I execute the same request for the point on the land:

https://maps.googleapis.com/maps/api/geocode/json?latlng=40.044043%2C-74.124069&result_type=natural_feature&location_type=GEOMETRIC_CENTER%7CAPPROXIMATE&key=YOUR_API_KEY

The first result will be 'Drum Point Rd, Brick, NJ 08723, USA' of type route.

Hope it helps.

Check land or water in google map

For today easiest way to do this is to use Google Static Map API and Styled Maps: you can create request for just one pixel map (size=1x1) for your Lat/Lon coords with hidden all features except water and set water color to e.g. pure blue (0x0000FF). Something like that

https://maps.googleapis.com/maps/api/staticmap?¢er={YOUR_LAT},{YOUR_LON}&zoom={YOUR_ZOOM}&size=1x1&style=feature:all|visibility:off&style=feature:water|visibility:on&style=feature:water|color:0x0000FF&key={YOUR_API_KEY}

Then download it (like in this answer of Vivek Khandelwal):

...

public static Bitmap getGoogleMapThumbnail(double lati, double longi) {
String URL = "http://maps.google.com/maps/api/staticmap?center=" + lati + "," + longi + "&zoom=15&size=200x200&sensor=false";
Bitmap bmp = null;
bmp = getBitmapFromURL(URL);
return bmp;
}

public static Bitmap getBitmapFromURL(String src) {
try {
URL url = new URL(src);
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setDoInput(true);
connection.connect();
InputStream input = connection.getInputStream();
Bitmap myBitmap = BitmapFactory.decodeStream(input);
return myBitmap;
}
catch (IOException e) {
e.printStackTrace();
return null;
}
}
...

and test color of one pixel like in that answer of Raz:

...
int pixel = bitmap.getPixel(x,y);
if (pixel == Color.BLUE) {
// water!
}
...

if it blue (0x0000FF) - there is water on your Lat/Lon coordinates.

NB! You should set appropriate zoom level and remember that is no map tiles for all zoom levels for entire Earth. Also some water/earth can be missed on map. So, that is not 100% right solution, but hope it helps.

Android Google Maps API v2 check land or water

No, there is no direct API for this AFAIK.

Another SO answer pointed out two possible workarounds:

  • You can use Google Maps Reverse Geocoding . In result set you can determine whether it is water by checking types. In waters case the type is natural_feature. See more at this link http://code.google.com/apis/maps/documentation/geocoding/#Types.
  • You can detect waters/lands by pixels, by using Google Static Maps. But for this purpose you need to create http service.

How to accurate determine if point on Google Maps is a building?

The closest thing that I can give is you can limit the points/coordinates that you are using in either land or water. You can verify that coordinates by following the answer and suggestion in this SO question. With the help of this you can now know if that point is in the water area, then you can now limit that place in your project.

I need to know the predefined point is in the sea or on the land

You can use the Google Maps Geocode API.

If your address is in land, the result_type of the response will be something like "administrative_area". if you are in the sea, the response will be "natural_feature".

Here are two examples:

  • The first is the 0,0 point, in the middle the the Atlantic Ocean: http://maps.google.com/maps/api/geocode/xml?address=0,0&sensor=false
  • The second is located at 20.012065,-6.82251, in the middle of the Saharan desert: http://maps.google.com/maps/api/geocode/xml?address=20.012065,-6.82251&sensor=false

Edit: Some more examples in response to comments:

  • This point is located in the sea claimed by UK, within the 12 miles limit. It shows as "natural_feature": http://maps.google.com/maps/api/geocode/xml?address=50.801541,0.424519&sensor=false
  • This point is located in the Lake Superior, in the Thunder Bay. It shows as "natural_feature": http://maps.google.com/maps/api/geocode/xml?address=48.23565,-86.981506&sensor=false


Related Topics



Leave a reply



Submit