14

I am new here and points poor so I can only offer 50 pt bounty.

Suppose I have an application a search for all gas stations within 10 mile radius of a certain location. However one side of this location is surrounded by a mountain range that you have to drive 50 miles to get around. You would not want to return results from the other side of the mountain. What are some good algorithms/techniques to deal with such a problem? I know with point to point searches you can use path costs but I am not sure what the technique is with radius searches.

Here is an example:

alt text

The red line is a chord on the radius circle from 40,-74 to 41,-72 lat long (not accurate just saying) The user at 40,-73 performs a geographic radius search for something which also encompasses areas across the LI sound in Connecticut which are impractical to get to. The algorithm should know that there exists a chord completely intersecting the search circle and not return results that are on the other side of that chord. So only points in the green area would get returned.

This should be able to be done without any road network analysis if the programmer defines these bounding lines. For instance there may be an area in some country that is dangerous to pass through and you would want people on either side of that area to be restricted to that side. Or an international border etc. I am just asking this because I am pretty sure people are doing this.

Michael Papile
  • 6,836
  • 30
  • 30
  • 1
    I don't think the question is clear. Do you measure distance along a road network or do you use aerial distance (supposing there are no mountains)? – Ilya Kogan Jan 10 '11 at 05:17
  • Well aerial distance. For instance, if I am standing on the west side of Manhattan and I do a radius search for restaurants. I would want the Hudson River to be a hard geographic bound on this search. IE, there may be a restaurant on the NJ bank of the Hudson but it is not practically possible to get there even though it may be in my "as the bird flies" radius. – Michael Papile Jan 10 '11 at 06:09
  • In essence I am asking what is a technique to do this without doing a graph point to point route using roads. I know if I wanted to do it roads for instance, I would assign a high or infinite cost to travel across a bridge or tunnel to exclude NJ results. I would imagine there is a way to define a line from one coordinate to another that would exclude results across that border even if they meet the as the bird flies distance. – Michael Papile Jan 10 '11 at 06:16
  • 2
    You should consider posting this question on http://gis.stackexchange.com – Jay Cummins Jan 10 '11 at 13:58
  • I'm not sure that ignoring the road network is a sound approach, if only from the user perspective. If I'm looking for a gas station within 10 km and I have to use the road network to get there, then I probably want driving distance. I know of gas stations that I could walk to in under a minute, yet would have to drive far more than 10 km to reach by car (think of that gas station you can see by the road, but you've missed the exit). – jadero Jan 28 '11 at 16:17
  • I suppose that using Gas stations as an example was a bad one. I was more thinking of this being for any business like if you were viewing restaurants in the area on yelp.com. I am pretty sure that doing a road network analysis for a lot of users to potentially a lot of places may be very intensive. – Michael Papile Jan 28 '11 at 16:40

3 Answers3

8

Although the best solution would be to calculate distance along a road network (rather than straight line distance) using, for example, ArcGIS's Network Analyst, a dirty hack would be to create straight lines between the center of your radius and each station, then calculate the total elevation gain along that profile (a script for doing this automatically is given here). You could then set a threshold to reject those with total elevation gains higher than a certain value (those that you need to cross mountains to reach).

EDIT Since you seem set on not using network analysis, why not create a raster cost map in which the value corresponds to the difficulty of traversing that terrain? That could be based on other data (i.e. water bodies, elevation, landcover, etc.). Then you can either return the lowest cost station or do a select by attribute using the cost map...

Another option would be to create a polygon vector layer showing the impassable zones (mountains, water bodies, etc.) and then create a line between your location and all stations in the radius. Using select by location you can see whether that line intersects any of the impassable polygons; if it does, unselect the station.

The best tool for the task is still network analysis...

Benjamin
  • 11,560
  • 13
  • 70
  • 119
1

You should change your metric, what "near" then means. In your example 10 miles nearby meams 10 miles beeline. However, you might rather want to query for any gas stations, where the shortest street way path is not longer than 10 miles away.

You can also combine both approaches and first query all surrounding points and then filter them, i.e. by calculating the route lengths.

If you are more into the algorithms, I'd suggest you to have a look at pathfinding algorithms used for navigation assistants.

b_erb
  • 20,932
  • 8
  • 55
  • 64
1

Solution that is possibly closer to what you asking for is to take locations of all gas stations in the area, add points of intersection between circle and your exclusion zone boundary lines and then perform topological sorting on resulting set of nodes in 2-dimensional space. Finding gas stations within certain area will be as simple as returning set of values that fall within given range given that entries in a set are sorted.

Please refer to Chapters 5.10.1 and 15.2 in Steven Skienn'a "Algorithm Design Manual" for more details. Boost graph library provides implementation of topological sorting algorithm.

I still think that this is strictly a graph problem so "10 mile radius" is not what your algorithm would use to find matches, but rather a road distance. Good solution should also include factors such as speed limit on roads, one way streets etc. and allow user to include in in costing function for best match.