R code to "average" GPS traces from OpenStreetMap to derive usable GPX tracks for roadways.
- R (core)
- R packages: princurve, rgdal, maptools, geosphere, rgeos (all on CRAN)
- Also: libgdal and gfortran are required by some of the dependencies above.
To get started using Debian unstable (or presumably Ubuntu w/universe):
apt-get install libgeos-dev r-cran-maptools gpsbabel libgdal-dev gfortran libgdal-dev
R -e "install.packages('princurve', 'geosphere', 'rgeos', 'rgdal', dependencies=TRUE)"
makeroads.R and process.R are lightly commented. Place them in the same directory (and cd there), edit process.R to your liking, then use:
R -f process.R
You'll get a bunch of GPX files named 'roadway-*.gpx', one per identified track, along with Rplots.pdf containing a visual representation of each estimated track along with the tracks that were used to construct it.
- This version uses rgeos to ridiculously improve the time taken to match the tracks. (Data matching now takes an order of minutes versus hours in previous versions.)
- Use local principal curves (R LPCM package).
- Take advantage of parallelism (investigate R multicore?).
- Memory usage improvements.
- A few problems with the instructions were pointed out by malenki: http://www.openstreetmap.org/user/malenki/diary/17976