..and then Google-maps "divide the waters from the waters"
Well, not in the biblical sense but..
I would like to know what options I have in order to verify if a point of [Lat, Lon] is Land or Water.
Google Maps obviously has this data (the bodies of water are blue) - but is there something in the API that I can use for that? And if not - are they not serving it because they never thought of it? Or because it is too complicated?
I have not found any info on the matter - except some similar questions here (like finding type of terrain, or elevation - but it is not exactly what I need).
Is there separated layer for that? An option? Command? Or should I go to do that manually?
The only way that I can think of how to approach this (should I need to do that manually) is to check every served tile for the exact point - and then check RGB value for that Google map hue. This is only on theory - because in practice - I have no idea how to accomplish that, the first obstacle being that I do not know how I can convert a pixel location on a tile to [LatLon] point for example
A ready made solution would be much easier.
Note that I do not need ALL the water in the world (for example - I do not care about streams, small ponds, most rivers or your neighbor's swimming pool. I need the points where a person can venture without the aid of a floating vehicle)
EDIT I
After reading comments: The elevation method is not reliable, there are too many places BELOW sea-level (you can see a list of the "deepest" 10 here http://geology.com/below-sea-level/ ) and there are too many land-locked water bodies ABOVE sea level (lakes). The reverse geolocation method is not reliable because it will return a Geo-political entity, like city, or state - or ZERO many times. I have already looked into those pseudo-solutions before asking the question - but none of them actually answered the question - those methods are bad "guessing" at best.
Unfortunately this answer isn't within the Google Maps API and the referenced resource is not free, but there's a web service provided by DynamicGeometry that exposes an operation
GetWaterOrLand
which accepts a latitude/longitude pair (you can see a demo here).My understanding of how this is implemented is by using water body shape files. How exactly these shape files are used with the Google Maps API, but you might be able to get some insight from the linked demo.
Hope that helps in some way.
This what I use and it is working not too bad... you can improve the test if you have more cpu to waste by adding pixels.
I would recommend rolling your own here. You can use tools like GDAL to query the contents under a point in a shapefile. You can get shapefiles for US geography from many sources including the US Census Bureau.
This can be done via GDAL binaries, the source C, or via swig in Java, Python, and more.
Census Maps
GDAL Information
Point Query Example in Python
Here's another example in pure JavaScript: http://jsfiddle.net/eUwMf/
As you can see, the ideia is basically the same as rebe100x, getting the image from Google static map API, and read the first pixel:
I have a different solution here. In current google map implementation, it does not calculate direction/distance from a water location to land location and vice versa. Why dont we use this logic to determine if the point is land or water.
For example lets take this example
if we want to determine, if a point
x
is land or water, thenlet us check the direction between point
x
and a known pointy
which is land. If it determines the direction/distance then pointx
is land or else it is water.Checkout this article. It accurately detects if something is on the water without needing a server. It's a hack that relies on the custom styling feature in Google Maps.
http://tech.bellycard.com/blog/where-d-the-water-go-google-maps-water-pixel-detection-with-canvas/