I have many vehicles GPS data points, which consist of "timestamp, longitude, latitude, fuel consumption and distance" and the data is OSM(open street map) based. I want to match the data points to OSM, divide it by road type, so that I could get road type specific data in groups (e.g, highway group, local roadway group). Then I could calculate the fuel efficiency corresponding to different road type.

I'm wondering if R has any packages could handle this type of task?

  • 1
    Welcome! Please take the tour here: gis.stackexchange.com/tour. What have you tried/what issues have you hit while trying to use R to calculate this so far? – MaryBeth Dec 20 '15 at 2:38
  • 2
    ?sp::over - plus there are "trajectory" specific packages for this kind of guff, it's easy to convert to sp too - see this Task View cran.rstudio.com/web/views/SpatioTemporal.html - it's not at all systematic or organized but there's tonnes of helpful stuff in all those packages – mdsumner Dec 20 '15 at 2:43
  • 1
    I had a similar question and at least some general approaches are introduced to do this calculations gis.stackexchange.com/questions/81551/matching-gps-tracks – Mapper Dec 20 '15 at 7:51
  • I'd be tempted to do the spatial join in PostGIS/QGIS and then run the analysis od that file in R. Preparing the file that way could mean that mapping the results would be easier. I'm making the assumption that they'll be other reasons for fuel efficiency then just road type (inclines etc) that you'll need to explore. – Andrew Tice Dec 20 '15 at 11:04
  • 1
    You can find snapPointsToLines() from the maptools package useful. Have a look at this post: geotux.tuxfamily.org/index.php/en/component/k2/item/… snapPointsToLines() allows you to get the line id each point lies on. Then you could query a specific line attribute using the line id. – Germán Carrillo Dec 20 '15 at 12:57