Find land mass nearest to a geo coordinate

2019-04-14 20:26发布

As part of a developer challenge, I am trying to determine the land mass closest to a given coordinate. Obviously, if the point is on land, I use reverse geocoding and can get details. The problem is that if the point is in a body of water, especially oceans, it often won't return anything (Google, Nokia, Bing). I'd like to know that a point 3 miles off the coast of California is 3 miles from USA, or x miles from Japan, y miles from South Korea when a point is reasonably near more than one country. Is there any service that provides this information?

2条回答
趁早两清
2楼-- · 2019-04-14 20:47

check older post in here Verify if a point is Land or Water in Google Maps, check the answer about the Koordinates Vector JSON Query service

查看更多
霸刀☆藐视天下
3楼-- · 2019-04-14 20:54
  • Take a KML file of the world's Maine Regions
  • Simplify it down to a minimum number of rough polygons.
  • Take your location, does it lie within one of the polygons?
    • If your location lies with a polygon, then it is at sea, iterate though the points on the inner and outer boundary to find the nearest one using the Haversine Formula. This will be the nearest point on land.
    • If your location does not lies with a polygon, you are already on land, do a direct reverse geocode.

Just imagine the world is a bit like the board from the game Diplomacy

enter image description here

Now coalesce the sea areas into larger polygons with holes for islands. If you're not at sea you must be on the land right?

查看更多
登录 后发表回答