none
How to get all the roads within a polygon? RRS feed

  • Question

  • Hi,

    I am using bing maps api.

    I need to find all the roads within a polygon and highlight those inside a map.

    Is there any API which gives these details? Looked the documentation but did not find any.

    Thanks in Advance.

    Monday, July 22, 2019 10:36 AM

Answers

  • You might want to take a look at Azure Maps. It's base maps uses vector tiles which provides access to the raw road geometry data.

    This means you can directly access the road geometries that are displayed. There will be a few limitations with this approach as well:

    • Only road data that is rendered is queryable.
    • This hasn't yet been exposed as a public API, so some hackish code required.
    • Vector tiles clip geometries to tiles, so a road may be broken up into multiple pieces.
    • Depending on the zoom level, multiple roads of similar types may be grouped as a MultiLineString. This is an optimization in the vector tiles.

    Here is an example that selects the geometries that you click on the map: https://azuremapscodesamples.azurewebsites.net/Experimental/Inspect%20features%20under%20the%20mouse.html

    If you want to increase accuracy, one approach is to create a service and have it download all the tiles that cover the area of your polygon at zoom level 16 or 17. At that zoom level all roads should be in the tiles. From there, use something like NetTopologySuite and combine the geometries together to create a massive MultiLineString of all the roads in the polygon. This will give the best accuracy and you would then be able to highlight all roads. I've done similar things with the vector tiles to generate millions of random routes in within cities for simulation purposes.

    Thursday, July 25, 2019 6:50 PM

All replies

  • Hi ameydeshpande.18,

    Our API returns road segments on a route. Would that work for your scenario?

    Sincerely,

    IoTGirl 

    Tuesday, July 23, 2019 6:13 AM
    Owner
  • Hi IoTGirl ,

    I do not require the road segments within a route.

    Let's say I have a small area within a town (suburb) , enclosed by a polygon. In that case I want to highlight All the roads within the area. 

    Our user will drive in real time on these routes, in the end I need to highlight the route/part of the route which is not covered by them.

    Thanks,

    Amey 

    Tuesday, July 23, 2019 11:41 AM
  • Hi Amey,

    Our service won't return road segments within a polygon, only within a route.  What you seem to be asking about is something like a paper route. If you have all of the addresses that should be visited you can plot those and then also plot the route travelled.  This should highlight the locations that were missed.

    If you are set on just getting all segments in the polygon, you might ask if this is possible with Azure Maps. ( https://social.msdn.microsoft.com/Forums/en-US/b5b027a0-c3ae-4b22-aab9-e77a8c87935e/azure-maps-forum?forum=bingmaps )  Azure maps is a vector based service while Bing Maps is a raster based service. 

    Sincerely,

    IoTGirl


    Tuesday, July 23, 2019 4:30 PM
    Owner
  • You might want to take a look at Azure Maps. It's base maps uses vector tiles which provides access to the raw road geometry data.

    This means you can directly access the road geometries that are displayed. There will be a few limitations with this approach as well:

    • Only road data that is rendered is queryable.
    • This hasn't yet been exposed as a public API, so some hackish code required.
    • Vector tiles clip geometries to tiles, so a road may be broken up into multiple pieces.
    • Depending on the zoom level, multiple roads of similar types may be grouped as a MultiLineString. This is an optimization in the vector tiles.

    Here is an example that selects the geometries that you click on the map: https://azuremapscodesamples.azurewebsites.net/Experimental/Inspect%20features%20under%20the%20mouse.html

    If you want to increase accuracy, one approach is to create a service and have it download all the tiles that cover the area of your polygon at zoom level 16 or 17. At that zoom level all roads should be in the tiles. From there, use something like NetTopologySuite and combine the geometries together to create a massive MultiLineString of all the roads in the polygon. This will give the best accuracy and you would then be able to highlight all roads. I've done similar things with the vector tiles to generate millions of random routes in within cities for simulation purposes.

    Thursday, July 25, 2019 6:50 PM
  • Thanks Ricky!  Great answer!
    Friday, July 26, 2019 5:20 PM
    Owner