views:

93

answers:

2

Hi,

I have a system where users put some coordinates (latitude/longitude), I need to check if specified coordinates are in the sea or not. Is there any service that could give me the answer. Or is it possible to do this using google maps.

thank you in advance.

+7  A: 

I have thought about this once before.

I would not use a web service. but I would use a pretty simple image. alt text

This image is taken from http://www.vectorworldmap.com/vectormaps/vector-world-map-v2.2-blank.jpg

  • I would map lat/long over this map for know points so you know your map is correct.
  • For any give point, I would locate the pixel location on this map and figure out the colour (php can do this).
  • If the colour is white, I would say it is sea, black = land.
  • if you dont want lakes, open the map up and color all the lakes black.

If you need super high res maps, I would get a very large map and divide it up in a grid of smaller images that you can load.

If you need to make this system super duper fast. I would can this image pixel for pixel and create a database of this stuff so you can look it up pretty quick. But already this image below actually acts as an excellent database that can be easily checked or changed.

Did you want oceans and lakes?

Curious to know where you are going with this, as I like this problem.

John.

John Ballinger
+1 clever solution. I learned something today
sandeepan
thanks! appreciated. damn google, I would have got accepted answer. Mine is still pretty good for other things. And you could put in other sorts of features pretty easily.
John Ballinger
Clever! But you need to take the logo off first :D
Michael Clerx
Yeah, logos are the spice off life. It would end up being a new question on stackoverflow. "My geo-locating system is not working" - take logo off....
John Ballinger
+11  A: 

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:

Edit: Some more examples in response to comments:

Vivien Barousse
damn, nice answer!
John Ballinger
+1 Very nice! Only one potential snag comes to mind: Sea areas claimed by a country or within the 12 mile zone - will they show up as "Administrative area" or as a "Natural feature"? That would be worth testing.
Pekka
I edited my answer to add a test within the UK 12 miles zone. Shows as natural feature.
Vivien Barousse
+1 Google thinks of **everything**.
BoltClock