View source: R/get_buildings_osm.R
get_buildings_osm | R Documentation |
Download and process OpenStreetMap (OSM) building 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_buildings_osm(
place,
date = NULL,
dir_raw = osmextract::oe_download_directory(),
filename = NULL,
driver = "GeoJSON",
delete_dsn = TRUE,
append = NA,
...
)
place |
|
date |
Date of OSM data snapshot to download. Object of class "Date" in format |
dir_raw |
character. Directory to download the raw unprocessed OSM data. Passed to
argument |
filename |
character (optional). File path to export output data. |
driver |
character (optional). Name of driver used to export output data, passed to |
delete_dsn |
logical (optional). Passed to |
append |
defaults to |
... |
Other arguments passed to |
Data is filtered by key-value attributes, where building:
is not NULL
.
The column levels
is derived from building:levels
; values were set to 1
if the
extracted value is empty or NA
, and set to NA
if ≤ 0
(i.e. underground);
values were then rounded up to the nearest whole number.
The column area_m2
represents the building footprint area,
and floorarea_m2
is calculated by multiplying the area_m2
by the number of levels
.
The processed building polygons (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()
# run function
get_buildings_osm(place = city_boundaries,
date = as.Date('2021-01-01'),
filename = 'buildings_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.