Getting wrong boundaries for some locations

Nilesh Khonde 60 Reputation points
2024-10-27T05:15:43.8866667+00:00

Hi, I am using the "Search for Boundaries" sample code from Azure Maps to get the boundaries of a desired location, but I have some questions regarding that.

https://samples.azuremaps.com/?search=boundary&sample=search-for-boundaries

  1. I was searching for Staten Island, which is supposed to be a county, but it is giving me the result as a locality. Please correct me if I am wrong.

I am referring to the documentation of the API provided in the sample.

https://learn.microsoft.com/en-us/rest/api/maps/search/get-geocoding?view=rest-maps-2024-04-01&tabs=HTTP

  • addressLine = local address of that area
  • adminDistrict = state
  • adminDistrict2 = county
  • adminDistrict3 = named area of that address (which I actually didn't understand; could you please give an example?)
  • countryRegion = country
  • locality = city
  • postalCode = postal code

I am using these parameters in the query for accurate results according to the search.

According to my understanding, Staten Island is a county according to Google and Bing Maps, but it is giving me the result as a locality, which I am considering as a city.

Here is the attached screenshot of the results, and it is actually giving me the result for New York.

I have some other postal code issues to ask but after this i will get the idea that what to do with those.

Screenshot (19)

Screenshot (20)

Azure Maps
Azure Maps
An Azure service that provides geospatial APIs to add maps, spatial analytics, and mobility solutions to apps.
736 questions
0 comments No comments
{count} votes

3 answers

Sort by: Most helpful
  1. RevelinoB 3,505 Reputation points
    2024-10-27T06:48:30.4033333+00:00

    Hi Nilesh,

    I’ve come across this type of issue before with Azure Maps, and it can be a bit confusing when comparing it to other mapping services like Google Maps or Bing. Here’s what’s going on:

    Classification as Locality vs. County: Azure Maps seems to recognize Staten Island as a "locality" rather than a "county." This happens because each mapping service uses its own conventions. Technically, Staten Island is both a borough of New York City and a county (Richmond County) in the state of New York. Azure Maps might simplify it to "locality" to align with New York City’s borough structure, treating the whole of NYC as a single administrative unit.

    Clarifying adminDistrict3:

    adminDistrict3 isn’t always consistent across searches but generally refers to a named area within a locality. For example, it could be a neighborhood or a specific district within a city. In some places, adminDistrict3 might represent areas like “Midtown” or “Harlem” if you’re searching in Manhattan. In other cases, it might not show up at all if there’s no named area associated with the address.

    Differences Between adminDistrict2 and Locality:

    Normally, adminDistrict2 would return the county or equivalent region. However, in New York City, Azure Maps might default to showing the broader city classification instead of individual boroughs as counties, which could be why Staten Island isn’t coming up as a county (Richmond County) here.

    Workaround Suggestion

    For unique cases like New York City, where boroughs and counties overlap, you might want to handle it through a custom lookup to translate boroughs into their respective counties. Alternatively, checking the results against another API that distinguishes counties more reliably could help if you need precise county-level data.

    If you have similar questions with postal codes or any other parameters, feel free to ask—this setup can sometimes require a bit of fine-tuning!

    1 person found this answer helpful.
    0 comments No comments

  2. Deleted

    This answer has been deleted due to a violation of our Code of Conduct. The answer was manually reported or identified through automated detection before action was taken. Please refer to our Code of Conduct for more information.


    Comments have been turned off. Learn more

  3. rbrundritt 18,686 Reputation points Microsoft Employee
    2024-10-28T16:34:44.7466667+00:00

    Staten island is not a county, it is a borough in Richmond county. Funny enough though, Richmond county is pretty much just Staten Island. Note that both Bing Maps and Google Maps also say it is a borough (it's even in your screenshot).

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.