Detecting water vs landmass, coastline layer?

949 views
Skip to first unread message

drbroad

unread,
Sep 7, 2009, 10:57:07 AM9/7/09
to KML Developer Support - Google Earth Plug-in
The Goal: user to draw rectangles on google earth, only situated on
water, and NOT land.

The Problem: A reliable way to detect if a user drawn rectangle
encroaches on land

So for I have two ideas for how to achieve this:

1 - Being able to manipulate the data from the "costline layer", of
the yellow outline around land (I am unsure if you can access this
information in the plugin)

2 - Being able to retrieve the altitude of a given point. The method
would involve gathering 4 points of a selected rectangle (TR, TL, BR,
BL) and determining the sea level of each of these points (http://
code.google.com/apis/ajax/playground/?
exp=earth#retrieving_ground_altitude_data). Testing on beaches in
Sydney, New Zealand and France produces wildly different results.
The problems include varying altitude (sydney beaches seemed to work
on a 3 meters and below, france was around 0 and below, and both in
france and NZ there was a lot of missing data)
So far this seems to be the most promising option, but still buggy.

Does anyone have any clues on how to go about detecting land from
water?

Thanks in advance.

Barry Hunter

unread,
Sep 7, 2009, 11:49:02 AM9/7/09
to KML Developer Support - Google Earth Plug-in
Use the Reverse Geocoder from the Maps API?

That returns (at least) a country from a lat/long - probably using a
coastline dataset.

http://code.google.com/apis/maps/documentation/services.html#ReverseGeocoding


Its easy to load the Maps API along with the Earth API, if you have
loaded the Earth API using the Common loader, just add a call to the
Maps API
http://code.google.com/apis/maps/documentation/index.html#AJAX_Loader

drbroad

unread,
Sep 7, 2009, 12:36:18 PM9/7/09
to KML Developer Support - Google Earth Plug-in
Thanks for the speedy reply Barry,

Unfortunately I havent been 100% clear on what i was trying to
achieve. The aim is to limit these drawings to water only. I dont care
so much to where one the water, or next to what country - only that
the rectangle lives on water only, and does not encroach onto land.
Hence trying to use the ground altitude to determine water, as most
land around a coast has a higher ground level than that of the sea
floor.

Although it didnt solve my problem, it solved another issue i had been
toying with - Thank you!

On Sep 7, 5:49 pm, Barry Hunter wrote:
> Use the Reverse Geocoder from the Maps API?
>
> That returns (at least) a country from a lat/long - probably using a
> coastline dataset.
>
> http://code.google.com/apis/maps/documentation/services.html#ReverseG...
>
> Its easy to load the Maps API along with the Earth API, if you have
> loaded the Earth API using the Common loader, just add a call to the
> Maps APIhttp://code.google.com/apis/maps/documentation/index.html#AJAX_Loader

Barry Hunter

unread,
Sep 7, 2009, 12:44:51 PM9/7/09
to KML Developer Support - Google Earth Plug-in
The reverse geocoder will tell you if a point is on water or on land.
- which still seems is what you asking...

Query the reverse geocoder, if you get a country - then the point is
on land - reject it. If you dont get a reply, must be on water, allow
to continue.

drbroad

unread,
Sep 7, 2009, 1:31:48 PM9/7/09
to KML Developer Support - Google Earth Plug-in
As far as i was aware the reverse geocoding still had issues in
determing water that was landlocked. Ror example lakes and rivers. In
these cases the water is shown as a country, not a seperate entity.
So yes, reverse geocoding does work, but only for the ocean.

Also, around some regions, the reverse geocoding needs to go very far
offshore before the water is recognized as a seperate entity, and a
lot of what i am trying to achieve revolves around shorelines and
lakes (which is why i am seriously considering ground level as my
measurement).

I appreciate the help with this.

Xavier Tassin

unread,
Jun 29, 2011, 6:15:03 AM6/29/11
to google-earth-...@googlegroups.com
I am reviving this old topic as I just posted a feature request for a new method allowing for terrain type testing.

I may also propose a (complicated) alternative.

Using styled static maps you can generate a request for an image like this one
It is possible to load this image in Canvas, and use a coordinate mapping to test pixel colors via Javascript.

Main issue here is to work around cross domain security restriction: Javascript can not manipulate a canvas image loaded from a different domain. Solution: you have to proxy the image through your own HTTP server.
Also, the Canvas tag is not available on every browser (IE)

Another possibility is to test image pixels server side (when you do not need to test too often)

Advantage: high accuracy of the result depending on the zoom level used to generate the image. Rivers, lakes and streams will be detected.

Andy Gee

unread,
May 3, 2012, 2:48:18 PM5/3/12
to google-earth-...@googlegroups.com
The data contained here can be correlated to define land and ocean

http://www.ngdc.noaa.gov/mgg/shorelines/gshhs.html
Reply all
Reply to author
Forward
0 new messages