Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
318 views
in Technique[技术] by (71.8m points)

javascript - Verify if a point is Land or Water in Google Maps

..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.

Question&Answers:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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_features.

    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:

    1. Receive latitude,longitude and current zoom from client.
    2. Send 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.
    3. Detect pixel's color of 1x1 static image.
    4. Respond an information about detection.

    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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...