How to check if Pushpin location point is water or land?

Sujal Shah - Housing India 80 Reputation points
2023-09-27T04:30:32.2066667+00:00

Is there any API available which I'm not aware of which provides information that given lat-long is water or land?

Here is the video showcase what I want exactly: https://www.loom.com/share/7017c596d5de4daabe0750c932ad33b7

I want to check if on click of the map if location is land or not.
Thanks in advance.

Azure Maps
Azure Maps
An Azure service that provides geospatial APIs to add maps, spatial analytics, and mobility solutions to apps.
653 questions
Windows Maps
Windows Maps
A Microsoft app that provides voice navigation and turn-by-turn driving, transit, and walking directions.
253 questions
0 comments No comments
{count} votes

Accepted answer
  1. rbrundritt 16,456 Reputation points Microsoft Employee
    2023-09-27T15:23:13.45+00:00

    There isn't a great solution for this in general as it would heavily depend on the resolution and frequency at which the water data is updated and level of accuracy you want. Most map platforms for example render streams and small rivers as lines that have no widths and the shoreline borders aren't the highest resolution. The shoreline of all bodies of water have the potential of changing over time (big changes can happen over the course of a year.

    That said, if using Azure Maps, it uses vector tiles under the hood for the base maps, and it is possible to query what entities in the map exist at any point in the rendered map. There is a code sample for this here: https://samples.azuremaps.com/?search=inspect&sample=inspect-features-under-the-mouse If you click on the map, then scroll down past the geometry information in the side panel, you will see the source layer information that usually classifies the data, like "river", "lake", "bay", "canal"...

    On a similar topic I personally had a project where I needed to roughly know if a map tile was over a large body of water or not. In that case I was able to take a set of high-resolution country land boundaries that I found only, load them into a spatial database like PostgreSQL or Azure SQL, and then did a spatial intersection test. If there was an intersection, I would say it was over land, otherwise it was water. In my scenario I wanted a few extra map tiles near the shorelines, so I buffered the land boundaries by a few hundred meters in the spatial database.

    I ended up exporting this into a unique tile indexing system down to zoom level 14 that is a few MB in size.


1 additional answer

Sort by: Most helpful
  1. dupammi 7,955 Reputation points Microsoft Vendor
    2023-09-27T11:11:06.0533333+00:00

    Hi @Sujal Shah - Housing India ,

    Thanks for using Microsoft Q&A Platform. I will be happy to assist you with this.

    The Bing Maps API, along with Azure Maps, offers powerful tools for handling reverse geocoding.

    It also allows to convert geographic coordinates into meaningful location information in their applications.

    Bing Maps API:

    Bing Maps is a web mapping service offered by Microsoft, providing mapping and location-based services.

    The Bing Maps API is a set of APIs that allow developers to integrate mapping and geospatial functionality into their applications and websites.

    It offers features such as displaying maps, adding markers, calculating routes, and performing geospatial queries.

    Reverse Geocoding:

    Reverse geocoding is the process of converting geographic coordinates (latitude and longitude) into human-readable location information, such as an address.

    It's the opposite of traditional geocoding, where addresses are converted into coordinates.

    Handling Reverse Geocoding in Azure:

    Azure provides the Azure Maps service, which is built on top of Bing Maps and offers a robust set of mapping and geospatial APIs.

    To handle reverse geocoding in Azure Maps:

    You first obtain a Bing Maps API key to authenticate your requests.

    You can use the Azure Maps Web SDK or make HTTP requests directly to the Azure Maps services.

    To perform reverse geocoding, you send a request with latitude and longitude coordinates to the Bing Maps Location API.

    The API returns a JSON response with detailed location information, including addresses and place names.

    You can then use this information in your application to provide users with context about a specific location based on their geographic coordinates.

    Based on your use I believe you can make use of this API.

    Note: While reverse geocoding can provide you with information about the location, it may not directly tell you whether a specific point is over land or water.

    However, you can infer this information by examining the address or place details returned by the reverse geocoding service. However, "On Click" identification of land/water on map is feasible with little customization of JavaScript SDK.

    I would request you to refer to this documentation to know more about this Bing Maps API, Azure Maps and Reverse Geocoding:

    Bing Maps:

    Tutorial: Migrate a web app from Bing Maps | Microsoft Learn

    Raster Map in Azure Maps:

    Render custom data on a raster map in Microsoft Azure Maps | Microsoft Learn

    Basic Reverse Geocode Example:

    Basic Reverse Geocode Example - Bing Maps | Microsoft Learn

    User Input Geocode Example:

    User Input Geocode Example - Bing Maps | Microsoft Learn

    Try these and let us know.

    I hope this helps.

    Please 'Accept as answer' and ‘Upvote’ if it helped, so that it can help others in the community looking for help on similar topics. Thanks.