Title: | Calculate Travel Times Over Space |
---|---|
Description: | Calculate travel time over a friction surface from a specified set of locations. |
Authors: | Gerry Ryan [aut, cre] , Daniel Weiss [aut] |
Maintainer: | Gerry Ryan <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.0.0.9000 |
Built: | 2024-11-14 04:15:01 UTC |
Source: | https://github.com/idem-lab/traveltime |
Calculate the travel time from a set of points over a friction surface.
calculate_travel_time( friction_surface, points, filename = NULL, overwrite = FALSE )
calculate_travel_time( friction_surface, points, filename = NULL, overwrite = FALSE )
friction_surface |
A |
points |
A two-column |
filename |
|
overwrite |
|
Implements methods from Weiss et al. 2018, 2020 to calculate travel time from given locations over a friction surface.
Over large areas this function can require significant RAM and will be slow.
Citations: D. J. Weiss, A. Nelson, C. A. Vargas-Ruiz, K. Gligoric, S., Bavadekar, E. Gabrilovich, A. Bertozzi-Villa, J. Rozier, H. S. Gibson, T., Shekel, C. Kamath, A. Lieber, K. Schulman, Y. Shao, V. Qarkaxhija, A. K. Nandi, S. H. Keddie, S. Rumisha, P. Amratia, R. Arambepola, E. G. Chestnutt, J. J. Millar, T. L. Symons, E. Cameron, K. E. Battle, S. Bhatt, and P. W. Gething. Global maps of travel time to healthcare facilities. (2020) Nature Medicine. https://doi.org/10.1038/s41591-020-1059-1
D. J. Weiss, A. Nelson, H.S. Gibson, W. Temperley, S. Peedell, A. Lieber, M. Hancher, E. Poyart, S. Belchior, N. Fullman, B. Mappin, U. Dalrymple, J. Rozier, T.C.D. Lucas, R.E. Howes, L.S. Tusting, S.Y. Kang, E. Cameron, D. Bisanzio, K.E. Battle, S. Bhatt, and P.W. Gething. A global map of travel time to cities to assess inequalities in accessibility in 2015. (2018). Nature. doi:10.1038/nature25181.
SpatRaster
ext <- matrix( data = c("111", "0", "112", 1), nrow = 2, ncol = 2, dimnames = list( c("x", "y"), c("min", "max") ) ) friction_surface <- get_friction_surface( surface = "motor2020", extent = ext ) from_here <- data.frame( x = c(111.2, 111.9), y = c(0.2, 0.35) ) calculate_travel_time( friction_surface = friction_surface, points = from_here )
ext <- matrix( data = c("111", "0", "112", 1), nrow = 2, ncol = 2, dimnames = list( c("x", "y"), c("min", "max") ) ) friction_surface <- get_friction_surface( surface = "motor2020", extent = ext ) from_here <- data.frame( x = c(111.2, 111.9), y = c(0.2, 0.35) ) calculate_travel_time( friction_surface = friction_surface, points = from_here )
SpatRaster
or SpatVector
Formats spatial extent for use in get_friction_surface
.
ext_from_terra(r)
ext_from_terra(r)
r |
|
2x2 matrix
library(terra) r <- terra::rast( extent = terra::ext(c(111, 112, 0, 1)) ) ext_from_terra(r)
library(terra) r <- terra::rast( extent = terra::ext(c(111, 112, 0, 1)) ) ext_from_terra(r)
Extent vector to matrix
ext_vect_to_matrix(x)
ext_vect_to_matrix(x)
x |
|
2x2 matrix
ext_vect_to_matrix(c(111,112,0, 1))
ext_vect_to_matrix(c(111,112,0, 1))
Wrapper function to download friction surfaces via
malariaAtlas::getRaster
get_friction_surface( surface = c("motor2020", "walk2020"), filename = NULL, overwrite = FALSE, extent = NULL )
get_friction_surface( surface = c("motor2020", "walk2020"), filename = NULL, overwrite = FALSE, extent = NULL )
surface |
|
filename |
|
overwrite |
Overwrite |
extent |
Spatial extent as either numeric vector specifying |
Convenience wrapper to malariaAtlas::getRaster
to access motorised
and walking travel friction layers per Weiss et al. 2020, that adds safety to
check existing files before download. Surfaces can be downloaded directly
from:
https://malariaatlas.org/project-resources/accessibility-to-healthcare/
surface = "motor2020"
downloads
"Explorer__2020_motorized_friction_surface"
.
surface = "walk2020"
downloads
"Explorer__2020_walking_only_friction_surface"
.
D. J. Weiss, A. Nelson, C. A. Vargas-Ruiz, K. Gligoric, S., Bavadekar, E. Gabrilovich, A. Bertozzi-Villa, J. Rozier, H. S. Gibson, T., Shekel, C. Kamath, A. Lieber, K. Schulman, Y. Shao, V. Qarkaxhija, A. K. Nandi, S. H. Keddie, S. Rumisha, P. Amratia, R. Arambepola, E. G. Chestnutt, J. J. Millar, T. L. Symons, E. Cameron, K. E. Battle, S. Bhatt, and P. W. Gething. Global maps of travel time to healthcare facilities. (2020) Nature Medicine. https://doi.org/10.1038/s41591-020-1059-1
extent
is passed through is to pass to malariaAtlas::getRaster
as a 2x2
matrix. If passed in as a numeric vector, SpatExtent
, SpatVector
, or
SpatRaster
, it is converted into a matrix using ext_vect_to_matrix
and
ext_from_terra
. matrix
format is as returned by sf::st_bbox() - the
first column has the minimum, the second the maximum values; rows 1 & 2
represent the x & y dimensions respectively (matrix(c("xmin", "ymin","xmax", "ymax"), nrow = 2, ncol = 2, dimnames = list(c("x", "y"), c("min", "max")))
)
(use either shp OR extent; if neither is specified global raster is
returned). NULL
extent downloads (large) global layer.
Additional details...
SpatRaster
ext <- matrix( data = c(111, 0, 112, 1), nrow = 2, ncol = 2, dimnames = list( c("x", "y"), c("min", "max") ) ) get_friction_surface( surface = "motor2020", extent = ext )
ext <- matrix( data = c(111, 0, 112, 1), nrow = 2, ncol = 2, dimnames = list( c("x", "y"), c("min", "max") ) ) get_friction_surface( surface = "motor2020", extent = ext )