Skip to content

Commit

Permalink
update news
Browse files Browse the repository at this point in the history
  • Loading branch information
rafapereirabr committed Nov 21, 2023
1 parent e68617c commit 8b4f9ab
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 1 deletion.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,6 @@ BibTeX:
shorttitle = {r5r},
url = {https://findingspress.org/article/21262-r5r-rapid-realistic-routing-on-multimodal-transport-networks-with-r-5-in-r},
doi = {10.32866/001c.21262},
abstract = {Routing is a key step in transport planning and research. Nonetheless, researchers and practitioners often face challenges when performing this task due to long computation times and the cost of licensed software. R{\textasciicircum}5{\textasciicircum} is a multimodal transport network router that offers multiple routing features, such as calculating travel times over a time window and returning multiple itineraries for origin/destination pairs. This paper describes r5r, an open-source R package that leverages R{\textasciicircum}5{\textasciicircum} to efficiently compute travel time matrices and generate detailed itineraries between sets of origins and destinations at no expense using seamless parallel computing.},
language = {en},
urldate = {2021-03-04},
journal = {Findings},
Expand Down
7 changes: 7 additions & 0 deletions r-package/NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
# r5r 1.1.0999 dev

**Minor changes**

- In the `accessibility()` function, the value of `max_trip_duration` is now capped by the max value passed to the `cutoffs` parameter. Closes [#342](https://github.com/ipeaGIT/r5r/issues/348).


# r5r 1.1.0

**Major changes**
Expand Down
71 changes: 71 additions & 0 deletions r-package/tests/tests_rafa/r5r_arrow.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# allocate RAM memory to Java
options(java.parameters = "-Xmx2G")

# 1) build transport network, pointing to the path where OSM and GTFS data are stored
library(r5r)
library(arrow)
library(dplyr)


path <- system.file("extdata/poa", package = "r5r")
r5r_core <- setup_r5(data_path = path, verbose = FALSE)

# 2) load origin/destination points and set arguments
points <- read.csv(system.file("extdata/poa/poa_hexgrid.csv", package = "r5r"))
mode <- c("WALK", "TRANSIT")
max_walk_time <- 30 # minutes
max_trip_duration <- 60 # minutes
departure_datetime <- as.POSIXct("13-05-2019 14:00:00",
format = "%d-%m-%Y %H:%M:%S")

# 3.1) calculate a travel time matrix
ttm <- travel_time_matrix(r5r_core = r5r_core,
origins = points,
destinations = points,
mode = mode,
departure_datetime = departure_datetime,
max_walk_time = max_walk_time,
max_trip_duration = max_trip_duration,
output_dir = './aaaa')



csv_files <- list.files(path = './aaaa', full.names = TRUE)

# Define the dataset
DS <- arrow::open_csv_dataset(sources = csv_files)

# Create a scanner
O <- Scanner$create(DS)

# Load it as Arrow Table in memory
AT <- SO$ToTable()


# prep land use data
jobs_df <- select(points, c('id', 'jobs', 'healthcare'))

# merge jobs
AT <- left_join(AT, jobs_df, by = c('to_id' = 'id'))

head(AT) |> collect()

# calculate cumulative access in less than 20 min.
access_df <- AT |>
filter(travel_time_p50 <= 20) |>
group_by(from_id) |>
summarise(access = sum(jobs)) |>
collect()

head(access_df)


# calculate access to closest healthcare facility
access_df2 <- AT |>
filter(healthcare > 0) |>
group_by(from_id) |>
summarise(access = min(jobs)) |>
collect()

head(access_df2)

0 comments on commit 8b4f9ab

Please sign in to comment.