Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 626
Tornike Avatar asked Sep 05 '10 09:09

Tornike


2 Answers

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
like image 96
Vivien Barousse Avatar answered Sep 21 '22 19:09

Vivien Barousse


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

EDIT from a great comment

I like the solution, but I'm not sure that map is totally accurate or equirectangular (which would be the easiest to work with). How about this one? naturalearth.springercarto.com/ne3_data/8192/masks/water_8k.png

//END

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

like image 33
John Ballinger Avatar answered Sep 25 '22 19:09

John Ballinger