Giter Site home page Giter Site logo

pivot-sciences / osrm Goto Github PK

View Code? Open in Web Editor NEW

This project forked from riatelab/osrm

0.0 3.0 0.0 421 KB

:twisted_rightwards_arrows: Shortest Paths and Travel Time from OpenStreetMap with R

Home Page: https://rgeomatic.hypotheses.org/category/osrm

License: GNU General Public License v3.0

R 100.00%

osrm's Introduction

osrm R package

Version Travis-CI Build Status

Interface Between R and the OpenStreetMap-Based Routing Service OSRM

Description

OSRM is a routing service based on OpenStreetMap data. See http://project-osrm.org/ for more information. A public API exists but one can run its own instance. This package allows to compute distance (travel time and kilometric distance) between points and travel time matrices.

This package relies on the usage of a running OSRM service (tested with version 5.0.0 of the OSRM API). By default, this service is the OSRM demo server (http://router.project-osrm.org/). If you plan to use the OSRM demo server you should read the OSRM API Usage Policy. You should also take into account "that there are no guarantees regarding availability, stability or correctness of results. It's server to demonstrate OSRM, not a production-ready API." Demo Server To change the OSRM server, change the osrm.server option: options(osrm.server = "http://address.of.the.server/"). To change the profile (driving is set by default), use the osrm.profile option: options(osrm.profile = "name.of.the.profile")

Features

  • osrmTable Get travel time matrices between points.

  • osrmRoute Get the shortest path between two points.

  • osrmTrip Get the travel geometry between multiple unordered points.

  • osrmIsochrone Get a SpatialPolygonsDataFrame of isochrones.

Demo

osrmTable

library(osrm)
# Load data
data("com")
# Travel time matrix
distCom <- osrmTable(loc = com[1:50, c("name","lon","lat")])
# First 5 rows and columns
distCom$duration[1:5,1:5]
Bethune Annezin Denderleeuw Haaltert Locon
Bethune 0.00 5.40 95.10 91.60 7.50
Annezin 4.90 0.00 98.30 94.70 7.10
Denderleeuw 94.20 97.30 0.00 10.40 93.50
Haaltert 90.80 93.80 10.40 0.00 90.00
Locon 7.00 6.90 93.50 90.00 0.00

osrmRoute

library(osrm)
# Load data
data("com")

# Travel path between SpatialPointsDataFrame
route <- osrmRoute(src = src[1,], dst = dst[1,], sp = TRUE)
if(require("cartography")){
  osm <- getTiles(spdf = route, crop = TRUE, type = "osmtransport")
  tilesLayer(osm)
  plot(route, lwd = 5, col = "blue", add = TRUE)
  plot(src[1,], pch = 20, col = "green", cex = 5, add = TRUE)             
  plot(dst[1,], pch = 20, col = "red", cex = 5, add = TRUE) 
  dev.off()
}

osrmTrip

library(osrm)
# Load data
data("com")

# Get a trip with a SpatialPointsDataFrame
trips <- osrmTrip(loc = src)

# Map
if(require("cartography")){
  osm <- getTiles(spdf = trips[[1]]$trip, crop = TRUE, type = "osmtransport")
  tilesLayer(osm)
  plot(trips[[1]]$trip, add = TRUE, col = 1:5, lwd = 5)
  plot(src, pch = 21, bg = "red", cex = 2, col = "black", add = TRUE)
}

osrmIsochrone

library(osrm)
# Load data
data("com")

# Get isochones with a SpatialPointsDataFrame, custom breaks
iso <- osrmIsochrone(loc = src[6,], breaks = seq(from = 0,to = 30, by = 5))

# Map
if(require("cartography")){
  osm <- getTiles(spdf = iso, crop = TRUE, type = "osmtransport")
  tilesLayer(osm)
  breaks <- sort(c(unique(iso$min), max(iso$max)))
  pal <- paste(carto.pal("taupe.pal", length(breaks)-1), "95", sep="")
  cartography::choroLayer(spdf = iso, df = iso@data,
                          var = "center", breaks = breaks,
                          border = "grey50", lwd = 0.5, col = pal,
                          legend.pos = "topleft",legend.frame = TRUE, 
                          legend.title.txt = "Driving Time\nto Renescure\n(min)", 
                          add = TRUE)
  plot(src[6,], cex = 2, pch = 20, col ="red", add=T)
  text(src[6,], label = "Renescure", pos = 3)
}

Installation

  • Development version on GitHub
require(devtools)
devtools::install_github("rCarto/osrm")
  • Stable version on CRAN
install.packages("osrm")

Community Guidelines

One can contribute to the package through pull requests and report issues or ask questions here.

osrm's People

Contributors

rcarto avatar rcura avatar metanoid avatar kirel avatar

Watchers

James Cloos avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.