none
Find nearst street & distance RRS feed

  • Question

  • Hi,

    If I have a point (or a Polygon) how can I find nearest streets around it and the distance (direct spatial distance to walking distance). Nearest can be defined by a radius to the point; say within 100 meters? 

    Appreciate if you could provide me with some code samples as well. 

    Thanks.


    Monday, January 20, 2014 5:10 AM

Answers

All replies

  • The reverse geocoding service can be used to find the nearest street. This service usually allows up to 100 meters search area. This will return a coordinate. You can then use the Haversine formula to calculate the distance between the coordinates: http://megocode3.wordpress.com/2008/02/05/haversine-formula-in-c/

    http://rbrundritt.wordpress.com

    Monday, January 20, 2014 8:13 AM
  • Does Reverse Geocoding give you all the streets around the point? Like if the point is at a corner of 2 streets will it give both of those streets?

    Could you pls point me to some code (Preferably C#)?

    Thanks.

    Monday, January 20, 2014 8:21 AM
  • The reverse geocoding service will only return a single location. However you can make multiple requests within an area to get more roads within an area. Here is a blog post on how to do this: http://rbrundritt.wordpress.com/2010/01/09/reverse-geocoding-over-a-search-area/ This uses the SOAP services. I recommend using our REST services as they are much faster: http://msdn.microsoft.com/en-us/library/jj819168.aspx

    http://msdn.microsoft.com/en-us/library/ff701710.aspx


    http://rbrundritt.wordpress.com

    Monday, January 20, 2014 11:17 AM
  • Hi Ricky,

    The Reverse Geocoding gives me the closest Street. But the problem is, coordinates returened  from response result's location is the (almost) same as the request coordinates I sent to reverse geocode. It's not on the street, so I can't calculate the distance from my point to the colsest street.

    Is there a way to get the shortest distance from a point to the closest street?

    Thanks.

    Friday, January 24, 2014 5:04 AM
  • Can you provide a coordinate for testing?

    http://rbrundritt.wordpress.com

    Friday, January 24, 2014 9:18 AM
  • Hi Ricky,

    These are some test coordinates. All of them are in Western Australia.

    -31.96194778, 115.95199273
    -32.004750, 115.899400
    -31.965133, 115.919583
    -32.05479602, 115.81525126

    I used both REST & SOAP service calls and getting the same results. In both cases the Result's Location coordinates are the same as the reverse geocoded point.

    Thanks.

    Tuesday, January 28, 2014 1:58 AM
  • Actually the REST service is returning slightly different coordinates for the addresses. It appears the reverse geocoder knows what side of the street the coordinate is and approximates the location of the house of the nearest address. Everything looks fine here.

    http://rbrundritt.wordpress.com

    Tuesday, January 28, 2014 8:49 AM
  • Yes, bus I wanted to know how far the coordinate from the street not the nearest address. This approximation doesn't give me an accurate indication how far the street is.

    The reverse geocoding is doing what it suppose to do. I'm looking at alternate ways to achive my goal.

    Thanks for all the info & support Ricky.

    Wednesday, January 29, 2014 12:46 AM
  • You won't be able to get the nearest location on the street using the reverse geocoder every time. Instead try passing the coordinate into the routing service. This will give you the coordinate on the street. You will have to pass in a second coordinate for the route to calculate. Simply add 0.0001 to the latitude or longitude coordinate. This will give you a coordinate that is about 11 meters away but still close enough to the road to be routes too.

    http://rbrundritt.wordpress.com

    Wednesday, January 29, 2014 1:08 PM