..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.
These are 2 different ways, you may try:
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.
Also you need to check the names of features, if they contain Sea, Lake, Ocean
and some other words related to waters for more accuracy. For example the deserts also are natural_feature
s.
Pros - All detection process will be done on client's machine. No need of creating own server side service.
Cons - Very inaccurate and the chances you will get "none" at waters is very high.
You can detect waters/lands by pixels, by using Google Static Maps. But for this purpose you need to create http service.
These are steps your service must perform:
latitude
,longitude
and current zoom
from client.http://maps.googleapis.com/maps/api/staticmap?center={
latitude,
longitude}&zoom={
current zoom`}&size=1x1&maptype=roadmap&sensor=false request to Google Static Map service.You can't detect pixel's color in client side. Yes , you can load static image on client's machine and draw image on canvas
element. But you can't use getImageData
of canvas's context for getting pixel's color. This is restricted by cross domain policy.
Prons - Highly accurate detection
Cons - Use of own server resources for detection
It doesn't seem possible with any current Google service.
But there are other services, like Koordinates Vector JSON Query service! You simply query the data in the URL, and you get back a JSON/XML response.
Example request: http://api.koordinates.com/api/vectorQuery.json?key=YOUR_GEODATA_KEY&layer=1298&x=-159.9609375&y=13.239945499286312&max_results=3&radius=10000&geometry=true&with_field_names=true
You have to register and supply your key and selected layer number. You can search all their repository of available layers. Most of the layers are only regional, but you can find global also, like the World Coastline:
When you select a layer, you click on the "Services" tab, you get the example request URL. I believe you just need to register and that's it!
And now the best:
It is not available right away, hey have to process it somehow, but it should work! The layer repository actually looks like people uploaded them as they needed.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With