View source: R/parks_calc_attributes.R
parks_calc_attributes | R Documentation |
Summaries will be calculated for each of the supplied datasets (data_points
, data_lines
, or data_rasters
)
and appended to the parks
data as additional columns.
Ensure that all have a (projected) coordinate reference system similar to parks
.
parks_calc_attributes(
parks,
data_points = list(),
data_lines = list(),
data_rasters = list(),
rasters_summarise_fun = NULL,
raster_min_patch_size = units::set_units(0, "m^2"),
raster_edge = NULL,
relative = TRUE,
filename = NULL,
...
)
parks |
|
data_points |
Named list of |
data_lines |
Named list of |
data_rasters |
Named list of single |
rasters_summarise_fun |
Function to summarise the raster data passed to |
raster_min_patch_size |
Minimum patch size to be included when tabulating the sum of each raster class.
Only relevant if |
raster_edge |
numeric. Option to calculate total edge length of (classified) raster(s)
associated with each of the |
relative |
logical. Whether or not to calculate relative amounts
(e.g. point density, ratio of line-to-perimeter length, proportional area). Defaults to |
filename |
character (optional). File path to export output data (GeoJSON format). |
... |
Other arguments passed to |
parks
with added columns containing the summaries of basic park attributes
(area and perimeter), as well as summaries of each of the supplied datasets.
The summary method depends on geometry type (i.e. points, lines or rasters) and supplied arguments.
Some examples:
Area of park polygon.
Perimeter of park polygon.
data_points
>_countTotal count of points within park polygon.
data_points
>_ptdensityTotal count divided by area of the park polygon (point density).
Included if argument relative
set to TRUE
.
data_lines
>_lengthSum of line lengths within park polygon.
data_lines
>_length_perim_ratioRatio of line-to-perimeter length of the park polygon.
Included if argument relative
set to TRUE
.
data_rasters
>Summarised values of a specific raster class
(depends on function provided in the rasters_summarise_fun
argument).
data_rasters
>< class value >_areaTotal area of a specific raster class
(if rasters_summarise_fun = NULL
).
data_rasters
>< class value >_area_pctPercentage area of a specific raster class
(if rasters_summarise_fun = NULL
). Included if argument relative
set to TRUE
.
data_rasters
>< class value >_lengthTotal edge length of a specific raster class.
data_rasters
>< class value >_length_perim_ratioEdge-to-perimeter length of a specific raster class.
Included if argument relative
set to TRUE
.
## Not run:
data(pop_sgp) # city census blocks
data(parks_sgp) # park polygons
# transform to projected crs
pop_sgp <- sf::st_transform(pop_sgp, sf::st_crs(32648))
parks_sgp <- sf::st_transform(parks_sgp, sf::st_crs(32648))
# get playground points (example attribute)
city_boundaries <- pop_sgp %>%
dplyr::filter(year == 2020) %>%
sf::st_union() %>%
sf::st_as_sf() %>%
smoothr::fill_holes(threshold = units::set_units(1, 'km^2')) %>% # clean up
smoothr::drop_crumbs(threshold = units::set_units(1, 'km^2')) %>%
sf::st_make_valid()
playgrounds <- get_playgrounds_osm(place = city_boundaries,
date = as.Date('2021-01-01'))
point_list <- list(playgrounds) # convert to list (can add other point data too)
names(point_list) <- c("playground") # name each element in list
# calculate playground point count & density per park
parks_calc_attributes(parks = parks_sgp,
data_points = point_list,
relative = TRUE)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.