Automatically detects whether it is a vector or raster map and uses the appropriate read function.

load_layer(x)

Arguments

x

File name with full path

Value

A sf object for vector maps and a SpatRaster

object for raster maps.

Examples

 (pkg_layers <- list.files(
   system.file("cartography/CMR", package = "mapMCDA"),
   full.names = TRUE
 ))
#> [1] "/tmp/RtmpZKVMrL/temp_libpath388e55a42803/mapMCDA/cartography/CMR/animal.density.tif" 
#> [2] "/tmp/RtmpZKVMrL/temp_libpath388e55a42803/mapMCDA/cartography/CMR/cmr_admin3.gpkg"    
#> [3] "/tmp/RtmpZKVMrL/temp_libpath388e55a42803/mapMCDA/cartography/CMR/mobility.csv"       
#> [4] "/tmp/RtmpZKVMrL/temp_libpath388e55a42803/mapMCDA/cartography/CMR/national_parks.gpkg"
#> [5] "/tmp/RtmpZKVMrL/temp_libpath388e55a42803/mapMCDA/cartography/CMR/water_bodies.gpkg"  
 
 epiunits <- load_layer(pkg_layers[[2]])