Your project might need some random GPS tracks. You could get some GPS traces from OSM, but they might have a lot of off-road content, or not have the coverage in your area of interest. Here’s a very high-level recipe for making a whole load of GPS traces for pretty much anywhere in the world.
Make Some Start/End Points
I assume that you have an area defined in a Shapefile, PostGIS or similar. Use Quantum GIS to make some random points up within your area. Use Vector/Geoprocessing Tools/Research Tools/Random Points to make a new Shapefile with a load of points within your area of interest. You can load the Shapefile of random points into QGIS and right-click Save As… on the layer in the list to create a comma-separated file of longitude/latitude points (which will probably be easier to read with a script than a Shapefile, YMMV). Note that the version of QGIS (2.2.0) that I used for making random points and performing union and buffer operations was very slow and it was actually quicker to upload the geometry to a table in PostGIS 2.x and let PostGIS do the heavy lifting.
Route Between the Points
The easiest, free (as in beer), way to do this is with Graphhopper and some data from OSM (Geofabrik). Get your OSM dataset to cover your area of interest from Geofabrik. Clip the and transform the downloaded PBF format data from Geofabrik into OSM XML format with Osmosis. Then download, build and Graphhopper (mvn package
in top level Graphhopper directory, then ./graphhopper.sh web yourfile.osm
). You can then hit the Graphhopper routing API with a script to calculate routes. The REST endpoint of the Graphhopper server on your workstation is http://localhost:8989/route
. You specify latitude and longitude of the start and end points and you get the result back in JSON or XML. An example call for a route in St. Petersburg would be: http://localhost:8989/route?point=59.912482,30.291023&point=59.93386,30.318489&points_encoded=0&type=json
.
Make the Routes Into Something Like GPS Tracks
Now you have the routes, you probably want to turn them into something a little bit more like GPS tracks. You can use the PostGIS function ST_Segmentize
on the route line to make a set of regular points along each route.
I made a script to automate most of this, but it’s a bit of a hack at the moment, so not really worth sharing since it might raise more questions than it would answer.