get_informalnature_osm | R Documentation |
Download and process OpenStreetMap (OSM) 'informal nature' polygons within a specified geographical place
,
from the Geofabrik database. It is a wrapper around
functions in the package osmextract
, and
processes the downloaded files for subsequent analyses. Refer to package osmextract
for
more details and options for input arguments when downloading the data.
get_informalnature_osm(
place,
date = NULL,
mutually_exclusive_with = list(),
snap_tolerance = 5,
min_area = units::set_units(0, "m^2"),
min_trails = units::set_units(0, "m"),
aggregate_polygons = 15,
dir_raw = osmextract::oe_download_directory(),
filename = NULL,
...
)
place |
|
date |
Date of OSM data snapshot to download. Object of class "Date" in format |
mutually_exclusive_with |
list of |
snap_tolerance |
numeric. Argument for |
min_area |
numeric. Specify minimum area of each polygon to be retained in the output,
passed to argument |
min_trails |
numeric. Specify minimum length of OSM trail lines that has to be within
nature area polygons, for the polygons to be retained in the output.
Provided either as a units object (see |
aggregate_polygons |
numeric. Argument for |
dir_raw |
character. Directory to download the raw unprocessed OSM data. Passed to
argument |
filename |
character (optional). File path to export output data (GeoJSON format). |
... |
Other arguments passed to |
OSM polygons are filtered by key-value attributes, where landuse:
is forest
or meadow
,
or natural:
is wood
, scrub
, heath
, grassland
, wetland
, marsh
, fell
or tundra
,
and access:
is not no
, private
or restricted
.
Polygons contained within leisure:golf_course
are excluded after mutually-snapping vertices between the two
(see argument snap_tolerance
). Intersections with landuse:military
polygons are also removed.
To exclude nature areas that are inaccessible, OSM trail lines are extracted (highway:
is track
, path
, footway
or cycleway
,
and access:
is not no
or private
). The remaining polygons without such trails within their boundaries are removed.
If mutually_exclusive_with
is provided, intersections between
the output and these polygon(s) will be excluded using polygons_mutually_exclude()
.
Polygons are then cleaned up using polygons_clean()
.
The processed 'informal nature areas' (polygons) that are publicly accessible (sf
object).
## Not run:
data(pop_sgp)
pop_sgp <- sf::st_transform(pop_sgp, sf::st_crs(32648)) # transform to projected crs
# merge all census blocks for chosen year (2020) into single multi-polygon
# function requires that polygons are merged
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()
data(parks_sgp) # to exclude nature areas within/intersecting these polygons
parks_sgp <- sf::st_transform(parks_sgp, sf::st_crs(32648)) # transform to projected crs
# run function
get_informalnature_osm(place = city_boundaries,
date = as.Date('2021-01-01'),
mutually_exclusive_with = list(parks_sgp),
snap_tolerance = 5,
min_area = units::set_units(2500, 'm^2'),
min_trails = units::set_units(0, 'm'),
aggregate_polygons = 15,
filename = 'nature-areas_osm-polygons_2021-01-01.geojson')
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.