Download and process OpenStreetMap (OSM) public sports/fitness amenities (points) within 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_sportfitness_osm(
  place,
  date = NULL,
  dir_raw = osmextract::oe_download_directory(),
  filename = NULL,
  ...
)

Arguments

place

sf object (with projected coordinate reference system). Geographical area to match with the (.osm.pbf) file in the data archive. Argument passed to osmextract::oe_match().

date

Date of OSM data snapshot to download. Object of class "Date" in format %Y-%m-%d. Refer to https://download.geofabrik.de for the specific dates available. Defaults to NULL (download the latest available data).

dir_raw

character. Directory to download the raw unprocessed OSM data. Passed to argument download_directory in osmextract::oe_read().

filename

character (optional). File path to export output data (GeoJSON format).

...

Other arguments passed to osmextract::oe_read().

Value

The processed sport/fitness amenities (sf object).

Details

OSM points filtered by key-value attributes, where leisure:fitness_station or sport:*, and access: is not no or private.

Examples

if (FALSE) {
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_sportfitness_osm(place = city_boundaries,
                    date = as.Date('2021-01-01'),
                    filename = 'sport-fitness_osm-points_2021-01-01.geojson')
}