I'm currently working on a map with stores and clients. I want to find the closest store by road from a given client, with the aim of simulating the creation of a new store.


  • precision is not an issue (low quality data is OK)
  • web based (API, some code server-side, or javascript)
  • free or cheap (no 100000$ GIS solutions...)

Of course I could use google maps api and try every store. But I have a lot of stores and clients, and I would like to run the simulation several times, so it would sent far too many queries.

  • 1
    Are you willing to build this using an open source stack or are you looking for a pre-packaged solution? – Jay Laura Jun 4 '13 at 14:34
  • Does it have to be web-based or would a desktop solution also do? – Uffe Kousgaard Jun 4 '13 at 14:35
  • @JayLaura I'm willing to build the missing parts. – L. Sanna Jun 4 '13 at 15:35
  • @UffeKousgaard I prefer web based but I could take a look at a desktop solution too. – L. Sanna Jun 4 '13 at 15:36
  • Have a look into graphhopper which uses openstreetmap data and is very fast and easy to setup. It also includes a web API – Karussell Jun 5 '13 at 5:59

Maybe there's someone on the web who has ArcGIS Server for Network Analyst and has published a closest facilities layer, similar to this sample service. You could adapt this javascript code, to perform the task.

Often these sorts of analyses use choice models that take the "n nearest facilities" as an input, such as multinomial logit models. For example suppose a neighborhood is close to two different facilities that are about the same distance. We would expect an equal number of people in that neighborhood to use each facility.

This seems like such a common need that someone must be doing it somewhere. However, my google searches haven't turned up anything.


No need for expensive proprietary solutions, this is called the Traveling Sales Person (TSP) problem and luckily for you this PostGIS extension PG Routing already has this cracked.

Better yet it's free and opensource! Just vanilla web app stuff to write some back end code to that you can run those queries over HTTP.

Happy mapping!

  • Oops didn't address the data question. That's free too - wiki.openstreetmap.org/wiki/Shapefiles – ChrisInCambo Jun 5 '13 at 4:17
  • It don't think my problem is the TSP. I don't want to visit all n locations, just to find the nearest one. – L. Sanna Jun 5 '13 at 6:58
  • OP doesn't ask about TSP and the TSP implemented in postgis is quite limited, since it doesn't really work with roads, only in "flying mode". Meaning lack of roads in an area is not considered and oneway restrictions is also ignored. OSM can be good in some areas and bad in others. So, in terms of accepting low quality, yes at least that part fit the demand. – Uffe Kousgaard Jun 5 '13 at 7:03

You can use our RW Net 4 library, either calling it from .NET or use Python as a scripting language. Prices start from €1000 for a solution covering the needs you specify. You will need a street network covering your area of interest, for some areas good and free sources exist.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.