Skip to contents

Wrapper function to download friction surfaces via malariaAtlas::getRaster

Usage

get_friction_surface(
  surface = c("motor2020", "walk2020"),
  filename = NULL,
  overwrite = FALSE,
  extent = NULL
)

Arguments

surface

"motor2020" or "walk2020.

filename

character. File name for output layer.

overwrite

Overwrite filename if exists

extent

Spatial extent as either numeric vector specifying c(xmin, xmax, ymin, ymax), SpatExtent, SpatVector or SpatRaster (from which the extent will be taken), or 2x2 matrix (see details).

Value

SpatRaster

Details

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...

Examples


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
 )
#> Checking if the following Surface-Year combinations are available to download:
#> 
#>     DATASET ID  YEAR 
#>   - Explorer__2020_motorized_friction_surface:  DEFAULT 
#> 
#> <GMLEnvelope>
#> ....|-- lowerCorner: 0 111
#> ....|-- upperCorner: 1 112Start tag expected, '<' not found
#> class       : SpatRaster 
#> dimensions  : 120, 120, 1  (nrow, ncol, nlyr)
#> resolution  : 0.008333333, 0.008333333  (x, y)
#> extent      : 111, 112, 0, 1  (xmin, xmax, ymin, ymax)
#> coord. ref. : lon/lat WGS 84 (EPSG:4326) 
#> source      : Explorer__2020_motorized_friction_surface_0,111,1,112.tif 
#> name        : friction_surface