cache_csv_sf_wrapper | R Documentation |
Send in a unique name to save the object and a function that will create it along with its parameters.
cache_csv_sf_wrapper(name_str, fun, id_name = "GEOID", path_dir = NA, ...)
id_name |
Also possible to change the path directory otherwise will use the default one
Will zip the files (including all shp shx prj dbf in the case of shp files)
Writes the rectangular dataframe to a separate csv to avoid the name mangling nonsense associated with ESRI shp and then merges everything together using the id_name column. This means you need to know the dataset in advance, but should not be an issue if using census data - GEOID for us and GeoUID for can.
fun(...) - and results cached to a zip file
## Not run:
get_isochrone <- function(buffer_km){
shp_point <- data.frame(X=-71.22776107610193, Y=46.805060757836486) %>% sf::st_as_sf(coords=c('X','Y'),crs=4326)
osm <- SfSpHelpers::osm_buffer_query_helper(shp_point,buffer_km = buffer_km)
return(osm$osm_lines)
}
shp_iso_5km <- cache_csv_sf_wrapper(name_str='qc_city_isochrone_5km',
fun=get_isochrone,
buffer_km=5,
id_name='osm_id',
path_dir=here('cache'))
shp_iso_1km <- cache_csv_sf_wrapper(name_str='qc_city_isochrone_1km',
fun=get_isochrone,
buffer_km=1,
id_name='osm_id')
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.