Giter VIP home page Giter VIP logo

traveltime's Introduction

traveltime - a Traveltime API Wrapper for R

The traveltime-package allows to retrieve isochrones for traveltime-maps from the Traveltime Platform API directly from R. The isochrones are stored as sf-objects, ready for visualization or further processing. The isochrones display how far you can travel from a certain location within a given timeframe. Numerous modes of transport are supported.

GET an API-KEY here: http://docs.traveltimeplatform.com/overview/getting-keys/

For non-commercial use the usage of the API is free for a restricted period of 10 days and can be granted for longer periods upon request.

You can install the traveltime-package with devtools or remotes from Github.

devtools::install_github("tlorusso/traveltime")

library(traveltime)

The traveltime_map function allows to easily retrieve traveltime-isochrones via the Traveltime-API.

querying the Traveltime-API with traveltime_map

# retrieve isochrones via request 

The following transport modes are supported:

# "cycling"", "cycling_ferry", "driving", "driving+train", "driving_ferry", "public_transport", 
# "walking", "walking+coach", "walking_bus", "walking_ferry" or "walking_train".


# how far can you go by public transport within 30 minutes?

traveltime30 <- traveltime_map(appId="YourAppId",
               apiKey="YourAPIKey",
               location=c(47.378610,8.54000),
               traveltime=1800,
               type="public_transport",
               departure="YYYY-MM-DDT08:00:00Z")
			   
# take a glimpse at the data

plot(traveltime30)

# or on top of a leaflet-map with mapview

mapview::mapview(traveltime30)

# You can switch to arrival search (from how far is a location reachable within x min?) just by using the 'arrival' argument instead of 'departure'.

traveltime30_arrival <- traveltime_map(appId="YourAppId",
               apiKey="YourAPIKey",
               location=c(47.378610,8.54000),
               traveltime=1800,
               type="public_transport",
               arrival="YYYY-MM-DDT08:00:00Z")

Some examples of how to use the API-Wrapper and what can be done with the data are available here:

https://www.tlorusso.ch/posts/traveltime/

In the upcoming version, further API-Modules will be supported.

traveltime's People

Contributors

tlorusso avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

traveltime's Issues

arrival parameter in traveltime_map function not responding as expected

It seems that when I call the "arrival" parameter, that the tool is not responding correctly to this parameter. Here is example code:

traveltimes <-strftime(strptime(seq(20,23,1),format = "%H",tz ="America/New_York"),format = "%FT%T-05:00") %>%
  map(.,~traveltime_map(appId=appid,
                        apiKey=apikey,
                        location=c(X,Y),
                        traveltime=20*60,
                        type="public_transport",
                        arrival = .x) %>%
        mutate(Hour=.x))
df2<-do.call(rbind.data.frame, traveltimes)

Returns as follows:

Simple feature collection with 4 features and 7 fields
geometry type:  MULTIPOLYGON
dimension:      XY
bbox:           xmin: -77.06287 ymin: 38.93825 xmax: -76.99137 ymax: 38.9986
CRS:            +proj=longlat +datum=WGS84
                        geometry       lat        lng traveltime             type departure arrival
1 MULTIPOLYGON (((-77.0623 38... 38.974425 -77.029864       1200 public_transport        NA      NA
2 MULTIPOLYGON (((-77.04258 3... 38.974425 -77.029864       1200 public_transport        NA      NA
3 MULTIPOLYGON (((-77.04175 3... 38.974425 -77.029864       1200 public_transport        NA      NA
4 MULTIPOLYGON (((-77.04233 3... 38.974425 -77.029864       1200 public_transport        NA      NA
                       Hour
1 2020-06-25T20:00:00-05:00
2 2020-06-25T21:00:00-05:00
3 2020-06-25T22:00:00-05:00
4 2020-06-25T23:00:00-05:00

Note that the arrival field is NA. When changing "arrival for "departure", it appears to return as expected. Note the "Departure column:

Simple feature collection with 4 features and 7 fields
geometry type:  MULTIPOLYGON
dimension:      XY
bbox:           xmin: -77.04398 ymin: 38.93912 xmax: -77.00361 ymax: 38.99857
CRS:            +proj=longlat +datum=WGS84
                        geometry       lat        lng traveltime             type                 departure arrival
1 MULTIPOLYGON (((-77.0434 38... 38.974425 -77.029864       1200 public_transport 2020-06-25T20:00:00-05:00      NA
2 MULTIPOLYGON (((-77.04216 3... 38.974425 -77.029864       1200 public_transport 2020-06-25T21:00:00-05:00      NA
3 MULTIPOLYGON (((-77.04538 3... 38.974425 -77.029864       1200 public_transport 2020-06-25T22:00:00-05:00      NA
4 MULTIPOLYGON (((-77.04203 3... 38.974425 -77.029864       1200 public_transport 2020-06-25T23:00:00-05:00      NA
                       Hour
1 2020-06-25T20:00:00-05:00
2 2020-06-25T21:00:00-05:00
3 2020-06-25T22:00:00-05:00
4 2020-06-25T23:00:00-05:00

Version of R

Hi, this looks good. Are there plans to update this so that it will run on the latest version of R? I was running this on R version 3.4.? yesterday and it worked, but have updated to R version 3.5.2 and it is no longer possible to use this. Thanks.

Multiple coordinates

Fantastic package! Any chance you could provide a solution for querying multiple coordinates? The following does not work

traveltimes = c("59.85784, 17.64629", "59.95784, 17.84629") %>%
map(.,~traveltime_map(appId=appID,
apiKey=apiKey,
location=.x,
traveltime=1800,
type="public_transport",
departure="2021-02-23T14:00:00+01:00") %>%
mutate(location=.x))

and neither does

list(c(59.854373, 17.650896),c(60.17643, 18.18830992)) %>%
map(.,~traveltime_map(appId=appID,
apiKey=apiKey,
location=.x,
traveltime=1800,
type="public_transport",
departure="2021-02-23T14:00:00+01:00") %>%
mutate(location=.x))

The latter generates the following error, supposedly as a vector is required

Error: Problem with mutate() input location.
x Input location can't be recycled to size 1.
i Input location is .x.
i Input location must be size 1, not 2.

Error handling

Insert some error - handling mechanisms into the get_traveltime function

CRAN submission

Hi there, cool package. Are there plans to submit this to CRAN? I am also sitting in Zurich btw :-) We depend on this in production and I'd sleep better if it was on CRAN than GitHub only ๐Ÿ˜„ . I might also be able help you with some R CMD Check things and the submission process if needed.

Having problems with public_transport

Hey,
im still using your traveltime package instead of the official one as it seems way more handy for my work.
To my problem:

Im seeing continuous errors while trying to do some isochrones visualization with public_transport as type. It works nicely with walking and driving.

Maybe something changed in the API?

traveltime30 <- traveltime_map(appId="XXX",
                               apiKey="YYY",
                               location= Standort,
                               traveltime=1800,
                               type="public_transport",
                               departure="2022-12-15T08:00:00+01:00")
traveltime_driving_30 <- traveltime_map(appId="XXX",
                               apiKey="YYY",
                               location= Standort,
                               traveltime=1800,
                               type="driving",
                               departure="2022-12-15T08:00:00+01:00")

I can't really figure out, what's wrong. The error message is the standard one.

Fehler: request did not deliver isochrone coordinates - please check appId / apiKey and / or if the coordinates lie in a supported country. Also, departure time must lie in the future

Best regards,
Sebastian

Coordinate not lie in a supported country

Hi @tlorusso,

This is a great work you have done with the {traveltime} package.

I am trying to create isochrone around a point of interest in Qatar and South Africa. It seems this location is not supported by the API you are created.

Do you have any idea, how it can become supported or any tips?

Thanks!

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.