Verify if a point is Land or Water in Google Maps

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=1×1&maptype=roadmap&sensor=false request to Google Static Map service.
    3. Detect pixel’s color of 1×1 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

Leave a Comment