| Title: | Automate the Delineation of Urban River Spaces |
|---|---|
| Description: | Provides tools to automate the morphological delineation of riverside urban areas based on a method introduced in Forgaci (2018) <doi:10.7480/abe.2018.31>. Delineation entails the identification of corridor boundaries, segmentation of the corridor, and delineation of the river space using two-dimensional spatial information from street network data and digital elevation data in a projected CRS. The resulting delineation can be used to characterise spatial phenomena that can be related to the river as a central element. |
| Authors: | Claudiu Forgaci [aut, cre, cph] (ORCID: <https://orcid.org/0000-0003-3218-5102>), Francesco Nattino [aut] (ORCID: <https://orcid.org/0000-0003-3286-0139>), Fakhereh Alidoost [ctb] (ORCID: <https://orcid.org/0000-0001-8407-6472>), Meiert Willem Grootes [ctb] (ORCID: <https://orcid.org/0000-0002-5733-4795>), Netherlands eScience Center [fnd] |
| Maintainer: | Claudiu Forgaci <[email protected]> |
| License: | Apache License (>= 2) |
| Version: | 0.3.1 |
| Built: | 2026-06-01 23:10:22 UTC |
| Source: | https://github.com/cityriverspaces/rcrisp |
If the x does not have a CRS, WGS84 is assumed.
as_bbox(x)as_bbox(x)
x |
Simple feature object (or compatible) or a bounding box, provided either as a matrix (with x, y as rows and min, max as columns) or as a vector (xmin, ymin, xmax, ymax) |
A bbox object as returned by sf::st_bbox()
library(sf) bounding_coords <- c(25.9, 44.3, 26.2, 44.5) bb <- as_bbox(bounding_coords) class(bb) st_crs(bb)library(sf) bounding_coords <- c(25.9, 44.3, 26.2, 44.5) bb <- as_bbox(bounding_coords) class(bb) st_crs(bb)
Standardise the coordinate reference system (CRS) of an object
as_crs(x, allow_geographic = FALSE)as_crs(x, allow_geographic = FALSE)
x |
An object of class |
allow_geographic |
Logical, whether to allow geographic CRS (lat/lon). |
An object of class sf::crs with a valid CRS.
library(sf) # Standardise a numeric EPSG code as_crs(4326, allow_geographic = TRUE) # Standardise a character EPSG code as_crs("EPSG:4326", allow_geographic = TRUE) # Standardise a bbox object bb <- st_bbox(c(xmin = 25.9, ymin = 44.3, xmax = 26.2, ymax = 44.5), crs = 4326) as_crs(bb, allow_geographic = TRUE) # Standardise a simple feature object bb_sfc <- st_as_sfc(bb) bb_sf <- st_as_sf(bb_sfc) as_crs(bb_sf, allow_geographic = TRUE) as_crs(bb_sfc, allow_geographic = TRUE)library(sf) # Standardise a numeric EPSG code as_crs(4326, allow_geographic = TRUE) # Standardise a character EPSG code as_crs("EPSG:4326", allow_geographic = TRUE) # Standardise a bbox object bb <- st_bbox(c(xmin = 25.9, ymin = 44.3, xmax = 26.2, ymax = 44.5), crs = 4326) as_crs(bb, allow_geographic = TRUE) # Standardise a simple feature object bb_sfc <- st_as_sfc(bb) bb_sf <- st_as_sf(bb_sfc) as_crs(bb_sf, allow_geographic = TRUE) as_crs(bb_sfc, allow_geographic = TRUE)
Create a network from a collection of line strings
as_network(edges, flatten = TRUE, clean = TRUE)as_network(edges, flatten = TRUE, clean = TRUE)
edges |
An |
flatten |
Whether all intersections between edges should be converted to nodes |
clean |
Whether general cleaning tasks should be run on the generated
network (see |
An sfnetworks::sfnetwork object
edges <- sf::st_sfc( sf::st_linestring(matrix(c(0, 0, 1, 1), ncol = 2, byrow = TRUE)), sf::st_linestring(matrix(c(0, 1, 1, 0), ncol = 2, byrow = TRUE)), crs = sf::st_crs("EPSG:32635") ) # Run with default values as_network(edges) # Only build the spatial network as_network(edges, flatten = FALSE, clean = FALSE)edges <- sf::st_sfc( sf::st_linestring(matrix(c(0, 0, 1, 1), ncol = 2, byrow = TRUE)), sf::st_linestring(matrix(c(0, 1, 1, 0), ncol = 2, byrow = TRUE)), crs = sf::st_crs("EPSG:32635") ) # Run with default values as_network(edges) # Only build the spatial network as_network(edges, flatten = FALSE, clean = FALSE)
Delineation generated with rcrisp example data found at https://zenodo.org/records/16325879
bucharest_dambovitabucharest_dambovita
A list of sf objects representing:
The valley boundaries of river Dâmbovița.
The corridor boundaries of river Dâmbovița.
Corridor segments of river Dâmbovița.
River space of Dâmbovița.
By default, the user-specific directory as returned by
tools::R_user_dir() is used. A different directory can be used by
setting the environment variable CRISP_CACHE_DIRECTORY. This can also be
done by adding the following line to the .Renviron file:
CRISP_CACHE_DIRECTORY=/path/to/crisp/cache/dir.
cache_directory()cache_directory()
The cache directory used by rcrisp.
cache_directory()cache_directory()
A warning is raised if the cache size is > 100 MB or if it includes files older than 30 days.
check_cache()check_cache()
NULL
check_cache()check_cache()
Subdivide edges by adding missing nodes,
(optionally) simplify the network (see simplify_network()), remove
pseudo-nodes,
and discard all but the main connected component.
clean_network(network, simplify = TRUE)clean_network(network, simplify = TRUE)
network |
A network object of class |
simplify |
Whether the network should be simplified with
|
A cleaned network object of class sfnetworks::sfnetwork
bucharest_osm <- get_osm_example_data() edges <- dplyr::bind_rows(bucharest_osm$streets, bucharest_osm$railways) network <- sfnetworks::as_sfnetwork(edges, directed = FALSE) clean_network(network)bucharest_osm <- get_osm_example_data() edges <- dplyr::bind_rows(bucharest_osm$streets, bucharest_osm$railways) network <- sfnetworks::as_sfnetwork(edges, directed = FALSE) clean_network(network)
Remove files from cache directory either before a given date or entirely.
clear_cache(before_date = NULL)clear_cache(before_date = NULL)
before_date |
Date before which cache files should be removed provided
as object of class |
List of file paths of removed files
# Clear all cache clear_cache() # Clear cache before given date before_date <- as.Date("1-1-1999", "%m-%d-%Y") clear_cache(before_date = before_date)# Clear all cache clear_cache() # Clear cache before given date before_date <- as.Date("1-1-1999", "%m-%d-%Y") clear_cache(before_date = before_date)
Endpoint and collection ID of the default STAC collection where to access digital elevation model (DEM) data. This is the global Copernicus DEM 30 dataset hosted on AWS, as listed in the EarthSearch STAC API endpoint. Note that AWS credentials need to be set up in order to access the data (not the catalog). References:
default_stac_demdefault_stac_dem
An object of class list of length 2.
Delineate a corridor around a river
delineate( city_name, river_name, crs = NULL, network_buffer = NULL, buildings_buffer = NULL, corridor_init = "valley", dem = NULL, dem_buffer = 2500, max_iterations = 10, capping_method = "shortest-path", angle_threshold = 100, corridor = TRUE, segments = FALSE, riverspace = FALSE, force_download = FALSE, ... )delineate( city_name, river_name, crs = NULL, network_buffer = NULL, buildings_buffer = NULL, corridor_init = "valley", dem = NULL, dem_buffer = 2500, max_iterations = 10, capping_method = "shortest-path", angle_threshold = 100, corridor = TRUE, segments = FALSE, riverspace = FALSE, force_download = FALSE, ... )
city_name |
A character vector of length one |
river_name |
A character vector of length one |
crs |
The projected Coordinate Reference System (CRS) to use. If not provided, the suitable Universal Transverse Mercator (UTM) CRS is selected |
network_buffer |
Add a buffer (an integer in meters) around river to retrieve additional data (streets, railways, etc.). Default is 3000 m. |
buildings_buffer |
Add a buffer (an integer in meters) around the river to retrieve additional data (buildings). Default is 100 m. |
corridor_init |
How to estimate the initial guess of the river corridor. It can take the following values:
|
dem |
Digital elevation model (DEM) of the region (only used if
|
dem_buffer |
Size of the buffer region (in meters) around the
river to retrieve the DEM (only used if |
max_iterations |
Maximum number of iterations employed to refine the
corridor edges (see |
capping_method |
The method employed to connect the corridor edge end
points (i.e., to "cap" the corridor), as character vector of length one.
See |
angle_threshold |
Only network edges forming angles above this threshold
(in degrees) are considered when forming segment edges. See
|
corridor |
Whether to carry out the corridor delineation |
segments |
Whether to carry out the corridor segmentation |
riverspace |
Whether to carry out the riverspace delineation |
force_download |
Download data even if cached data is available |
... |
Additional (optional) input arguments for retrieving the DEM
dataset (see |
A list with the corridor, segments, and riverspace geometries as
sf::sfc_POLYGON objects.
# Set parameters city <- "Bucharest" river <- "Dâmbovița" # Delineate with defaults delineate(city, river) # Use custom CRS delineate(city, river, crs = "EPSG:31600") # National projected CRS # Use custom network buffer delineate(city, river, network_buffer = 3500) # Use custom buildings buffer delineate(city, river, buildings_buffer = 150, riverspace = TRUE) # Provide DEM as input bucharest_dem <- get_dem_example_data() delineate(city, river, dem = bucharest_dem)# Set parameters city <- "Bucharest" river <- "Dâmbovița" # Delineate with defaults delineate(city, river) # Use custom CRS delineate(city, river, crs = "EPSG:31600") # National projected CRS # Use custom network buffer delineate(city, river, network_buffer = 3500) # Use custom buildings buffer delineate(city, river, buildings_buffer = 150, riverspace = TRUE) # Provide DEM as input bucharest_dem <- get_dem_example_data() delineate(city, river, dem = bucharest_dem)
The corridor edges on the two river banks are drawn on the provided spatial network starting from an initial guess of the corridor (based e.g. on the river valley).
delineate_corridor( network, river, corridor_init = 1000, max_width = 3000, max_iterations = 10, capping_method = "shortest-path" )delineate_corridor( network, river, corridor_init = 1000, max_width = 3000, max_iterations = 10, capping_method = "shortest-path" )
network |
The spatial network of class |
river |
A (MULTI)LINESTRING simple feature geometry of class |
corridor_init |
How to estimate the initial guess of the river corridor. It can take the following values: |
max_width |
A positive number representing the (approximate) maximum width of the corridor in meters. The upper limit is unrestricted. The spatial network is trimmed by a buffer region of this size around the river. |
max_iterations |
A positive integer greater than 0, with upper limit
unrestricted, representing the maximum number of iterations employed to
refine the corridor edges (see |
capping_method |
Case-insensitive character vector of length 1 with the
method employed to connect the corridor edge end points (i.e. to "cap" the
corridor). See |
A simple feature geometry of class sf::sfc_POLYGON representing
the river corridor
bucharest_osm <- get_osm_example_data() streets <- bucharest_osm$streets railways <- bucharest_osm$railways river <- bucharest_osm$river_centerline # Delineate with default values network <- rbind(streets, railways) |> as_network() delineate_corridor(network = network, river = river) # Delineate with user-specified parameters bucharest_dem <- get_dem_example_data() corridor_init <- delineate_valley(dem = bucharest_dem, river = river) delineate_corridor(network = network, river = river, corridor_init = corridor_init, max_width = 4000, max_iterations = 5, capping_method = "direct")bucharest_osm <- get_osm_example_data() streets <- bucharest_osm$streets railways <- bucharest_osm$railways river <- bucharest_osm$river_centerline # Delineate with default values network <- rbind(streets, railways) |> as_network() delineate_corridor(network = network, river = river) # Delineate with user-specified parameters bucharest_dem <- get_dem_example_data() corridor_init <- delineate_valley(dem = bucharest_dem, river = river) delineate_corridor(network = network, river = river, corridor_init = corridor_init, max_width = 4000, max_iterations = 5, capping_method = "direct")
Delineate the space surrounding a river
delineate_riverspace( river, occluders = NULL, density = 1/50, ray_num = 40, ray_length = 100 )delineate_riverspace( river, occluders = NULL, density = 1/50, ray_num = 40, ray_length = 100 )
river |
List with river surface and centerline |
occluders |
Geometry of occluders |
density |
Density of viewpoints |
ray_num |
Number of rays as numeric vector of length one |
ray_length |
Length of rays in meters as numeric vector of length one |
Riverspace as object of class sf::sfc_POLYGON
bucharest_osm <- get_osm_example_data() delineate_riverspace(bucharest_osm$river_surface, bucharest_osm$buildings)bucharest_osm <- get_osm_example_data() delineate_riverspace(bucharest_osm$river_surface, bucharest_osm$buildings)
Segments are defined as corridor subregions separated by river-crossing transversal lines that form continuous strokes in the network.
delineate_segments(corridor, network, river, angle_threshold = 100)delineate_segments(corridor, network, river, angle_threshold = 100)
corridor |
The river corridor as a simple feature geometry of class
|
network |
The spatial network of class |
river |
The river centerline as a simple feature geometry of class
|
angle_threshold |
Only consider angles above this threshold (in degrees)
to form continuous strokes in the network. The value can range between
0 and 180, with the default set to 100. See |
Segment polygons as a simple feature geometry of class
sf::sfc_POLYGON
bucharest_osm <- get_osm_example_data() corridor <- bucharest_dambovita$corridor network <- rbind(bucharest_osm$streets, bucharest_osm$railways) |> as_network() river <- bucharest_osm$river_centerline delineate_segments(corridor, network, river)bucharest_osm <- get_osm_example_data() corridor <- bucharest_dambovita$corridor network <- rbind(bucharest_osm$streets, bucharest_osm$railways) |> as_network() river <- bucharest_osm$river_centerline delineate_segments(corridor, network, river)
The slope of the digital elevation model (DEM) is used as friction (cost) surface to compute the cost distance from any grid cell of the raster to the river. A characteristic value (default: the mean) of the cost distance distribution in a region surrounding the river (default: a buffer region of 2 km) is then calculated, and used to threshold the cost-distance surface. The resulting area is then "polygonized" to obtain the valley boundary as a simple feature geometry.
delineate_valley(dem, river)delineate_valley(dem, river)
dem |
|
river |
River valley as a simple feature geometry of class sfc_MULTIPOLYGON
bucharest_osm <- get_osm_example_data() bucharest_dem <- get_dem_example_data() delineate_valley(bucharest_dem, bucharest_osm$river_centerline)bucharest_osm <- get_osm_example_data() bucharest_dem <- get_dem_example_data() delineate_valley(bucharest_dem, bucharest_osm$river_centerline)
All crossing edges are identified, and the points of intersections are
injected within the edge geometries. Note that the injected points are
not converted to network nodes (this can be achieved via sfnetworks'
sfnetworks::to_spatial_subdivision(), which is part of the tasks
that are included in clean_network().
flatten_network(network)flatten_network(network)
network |
A network object of class |
The functionality is similar to sfnetworks'
sfnetworks::st_network_blend(), but in that case an external point is
only injected to the closest edge.
An sfnetworks::sfnetwork object with additional points at
intersections
bucharest_osm <- get_osm_example_data() edges <- dplyr::bind_rows(bucharest_osm$streets, bucharest_osm$railways) network <- sfnetworks::as_sfnetwork(edges, directed = FALSE) flatten_network(network)bucharest_osm <- get_osm_example_data() edges <- dplyr::bind_rows(bucharest_osm$streets, bucharest_osm$railways) network <- sfnetworks::as_sfnetwork(edges, directed = FALSE) flatten_network(network)
Access digital elevation model (DEM) for a given region
get_dem( bb, dem_source = "STAC", stac_endpoint = NULL, stac_collection = NULL, crs = NULL, force_download = FALSE )get_dem( bb, dem_source = "STAC", stac_endpoint = NULL, stac_collection = NULL, crs = NULL, force_download = FALSE )
bb |
A bounding box, provided either as a matrix (rows for "x", "y",
columns for "min", "max") or as a vector ("xmin", "ymin", "xmax", "ymax"),
in lat/lon coordinates (WGS84 coordinate reference system) of class |
dem_source |
Source of the DEM:
|
stac_endpoint |
URL of the STAC API endpoint (only used if |
stac_collection |
Identifier of the STAC collection to be queried (only
used if |
crs |
Coordinate reference system (CRS) which to transform the DEM to |
force_download |
Download data even if cached data is available |
DEM as a terra SpatRaster object
# Get DEM with default values bb <- get_osm_bb("Bucharest") crs <- 31600 # National projected CRS # Get DEM with default values get_dem(bb) # Get DEM from custom STAC endpoint get_dem(bb, stac_endpoint = "some endpoint", stac_collection = "some collection") # Specify CRS get_dem(bb, crs = crs)# Get DEM with default values bb <- get_osm_bb("Bucharest") crs <- 31600 # National projected CRS # Get DEM with default values get_dem(bb) # Get DEM from custom STAC endpoint get_dem(bb, stac_endpoint = "some endpoint", stac_collection = "some collection") # Specify CRS get_dem(bb, crs = crs)
This function retrieves example Digital Elevation Model (DEM) data from the Zenodo data repository, and it can be used in examples and tests. The code used to generate the example dataset is available at https://github.com/CityRiverSpaces/CRiSpExampleData. Note that the example dataset is cached locally, so that subsequent calls to the function can load the example data from disk without having to re-download the data.
get_dem_example_data(force_download = FALSE)get_dem_example_data(force_download = FALSE)
force_download |
Download data even if cached data is available |
An object of class terra::SpatRaster containing the DEM data.
get_dem_example_data(force_download = TRUE)get_dem_example_data(force_download = TRUE)
Get the bounding box of a city
get_osm_bb(city_name)get_osm_bb(city_name)
city_name |
A character vector of length one |
A bbox object with the bounding box of the city
get_osm_bb(city_name = "Bucharest")get_osm_bb(city_name = "Bucharest")
Get buildings from OpenStreetMap within a given buffer around a river.
get_osm_buildings(aoi, crs = NULL, force_download = FALSE)get_osm_buildings(aoi, crs = NULL, force_download = FALSE)
aoi |
Area of interest as sf object or bbox |
crs |
Coordinate reference system as EPSG code |
force_download |
Download data even if cached data is available |
An object of class sf::sfc_POLYGON
bb <- get_osm_bb("Bucharest") crs <- get_utm_zone(bb) get_osm_buildings(aoi = bb, crs = crs)bb <- get_osm_bb("Bucharest") crs <- get_utm_zone(bb) get_osm_buildings(aoi = bb, crs = crs)
This function retrieves the city boundary from OpenStreetMap based on a bounding box with the OSM tags "place:city" and "boundary:administrative". The result is filtered by the city name.
get_osm_city_boundary( bb, city_name, crs = NULL, multiple = FALSE, force_download = FALSE )get_osm_city_boundary( bb, city_name, crs = NULL, multiple = FALSE, force_download = FALSE )
bb |
Bounding box of class |
city_name |
A case-sensitive character vector of length 1 with the name of the city |
crs |
Coordinate reference system as EPSG code |
multiple |
A logical indicating if multiple city boundaries should be returned. By default, only the first one is returned. |
force_download |
Download data even if cached data is available |
An object of class sf::sfc_POLYGON or sf::sfc_MULTIPOLYGON
with the city boundary
bb <- get_osm_bb("Bucharest") crs <- get_utm_zone(bb) get_osm_city_boundary(bb = bb, city_name = "Bucharest", crs = crs)bb <- get_osm_bb("Bucharest") crs <- get_utm_zone(bb) get_osm_city_boundary(bb = bb, city_name = "Bucharest", crs = crs)
This function retrieves example OpenStreetMap (OSM) data from the Zenodo data repository, and it can be used in examples and tests. The code used to generate the example dataset is available at https://github.com/CityRiverSpaces/CRiSpExampleData. Note that the example dataset is cached locally, so that subsequent calls to the function can load the example data from disk without having to re-download the data.
get_osm_example_data(force_download = FALSE)get_osm_example_data(force_download = FALSE)
force_download |
Download data even if cached data is available |
A list of sf objects containing the OSM data as sf::sfc
objects.
get_osm_example_data(force_download = TRUE)get_osm_example_data(force_download = TRUE)
Get OpenStreetMap railways
get_osm_railways( aoi, crs = NULL, railway_values = "rail", force_download = FALSE )get_osm_railways( aoi, crs = NULL, railway_values = "rail", force_download = FALSE )
aoi |
Area of interest as sf object or bbox |
crs |
A numeric vector of length one with the EPSG code of the CRS |
railway_values |
A case-insensitive character vector with the railway values to retrieve. |
force_download |
Download data even if cached data is available |
An object of class sf::sfc_LINESTRING
bb <- get_osm_bb("Bucharest") crs <- get_utm_zone(bb) get_osm_railways(aoi = bb, crs = crs)bb <- get_osm_bb("Bucharest") crs <- get_utm_zone(bb) get_osm_railways(aoi = bb, crs = crs)
Get the river centreline from OpenStreetMap
get_osm_river_centerline(bb, river_name, crs = NULL, force_download = FALSE)get_osm_river_centerline(bb, river_name, crs = NULL, force_download = FALSE)
bb |
Bounding box of class |
river_name |
The name of the river as character vector of length 1, case-sensitive. |
crs |
Coordinate reference system as EPSG code |
force_download |
Download data even if cached data is available |
The river centreline as object of class sf::sfc_LINESTRING or
sf::sfc_MULTILINESTRING.
bb <- get_osm_bb("Bucharest") crs <- get_utm_zone(bb) get_osm_river_centerline(bb = bb, river_name = "Dâmbovița", crs = crs, force_download = FALSE)bb <- get_osm_bb("Bucharest") crs <- get_utm_zone(bb) get_osm_river_centerline(bb = bb, river_name = "Dâmbovița", crs = crs, force_download = FALSE)
Get the river surface from OpenStreetMap
get_osm_river_surface(bb, river_centerline, crs = NULL, force_download = FALSE)get_osm_river_surface(bb, river_centerline, crs = NULL, force_download = FALSE)
bb |
Bounding box of class |
river_centerline |
The river centerline as an object of class
|
crs |
Coordinate reference system as EPSG code |
force_download |
Download data even if cached data is available |
The river surface as object of class sf::sfc_POLYGON or
sf::sfc_MULTIPOLYGON.
bb <- get_osm_bb("Bucharest") crs <- get_utm_zone(bb) river <- get_osm_river_centerline(bb, "Dâmbovița") get_osm_river_surface(bb = bb, river_centerline = river, crs = crs, force_download = FALSE)bb <- get_osm_bb("Bucharest") crs <- get_utm_zone(bb) river <- get_osm_river_centerline(bb, "Dâmbovița") get_osm_river_surface(bb = bb, river_centerline = river, crs = crs, force_download = FALSE)
Get OpenStreetMap streets
get_osm_streets(aoi, crs = NULL, highway_values = NULL, force_download = FALSE)get_osm_streets(aoi, crs = NULL, highway_values = NULL, force_download = FALSE)
aoi |
Area of interest as sf object or bbox. Required, no default. |
crs |
A numeric vector of length one with the EPSG code of the CRS |
highway_values |
A character vector with the highway values to retrieve. If left NULL, the function retrieves the following values: "motorway", "trunk", "primary", "secondary", "tertiary" |
force_download |
Download data even if cached data is available |
An object of class sf::sfc_LINESTRING
# Set parameters bb <- get_osm_bb("Bucharest") crs <- 31600 # National projected CRS # Get streets with default values get_osm_streets(aoi = bb, crs = crs) # Specify street categories to be retrieved get_osm_streets(aoi = bb, crs = crs, highway_values = "primary") # Ensure that data is not retrieved from cache get_osm_streets(aoi = bb, crs = crs, force_download = FALSE)# Set parameters bb <- get_osm_bb("Bucharest") crs <- 31600 # National projected CRS # Get streets with default values get_osm_streets(aoi = bb, crs = crs) # Specify street categories to be retrieved get_osm_streets(aoi = bb, crs = crs, highway_values = "primary") # Ensure that data is not retrieved from cache get_osm_streets(aoi = bb, crs = crs, force_download = FALSE)
Retrieve OpenStreetMap data for a given location, including the city boundary, the river centreline and surface, the streets, the railways, and the buildings
get_osmdata( city_name, river_name, network_buffer = NULL, buildings_buffer = NULL, city_boundary = TRUE, crs = NULL, force_download = FALSE )get_osmdata( city_name, river_name, network_buffer = NULL, buildings_buffer = NULL, city_boundary = TRUE, crs = NULL, force_download = FALSE )
city_name |
The name of the city as character vector of length 1, case-sensitive. Required, no default. |
river_name |
The name of the river as character vector of length 1, case-sensitive. Required, no default. |
network_buffer |
Buffer distance in meters around the river to get the streets and railways, default is 0 means no network data will be downloaded |
buildings_buffer |
Buffer distance in meters around the river to get the buildings, default is 0 means no buildings data will be downloaded |
city_boundary |
A logical indicating if the city boundary should be retrieved. Default is TRUE. |
crs |
An integer or character vector of length one with the EPSG code for the projection. If no CRS is specified, the default is the UTM zone for the city. |
force_download |
Download data even if cached data is available |
A list with the retrieved OpenStreetMap data sets for the
given location, as objects of class sf::sfc
# Set parameters city <- "Bucharest" river <- "Dâmbovița" crs <- "EPSG:31600" # National projected CRS # Get OSM data with defaults get_osmdata(city_name = city, river_name = river) # Get OSM data without city boundary get_osmdata(city_name = city, river_name = river, city_boundary = FALSE) # Use custom network buffer to get streets and railways get_osmdata(city_name = city, river_name = river, network_buffer = 3500) # Use custom buffer to get buildings get_osmdata(city_name = city, river_name = river, buildings_buffer = 150) # Use custom CRS get_osmdata(city_name = city, river_name = river, crs = crs) # Avoid getting OSM data from cache get_osmdata(city_name = city, river_name = river, force_download = TRUE)# Set parameters city <- "Bucharest" river <- "Dâmbovița" crs <- "EPSG:31600" # National projected CRS # Get OSM data with defaults get_osmdata(city_name = city, river_name = river) # Get OSM data without city boundary get_osmdata(city_name = city, river_name = river, city_boundary = FALSE) # Use custom network buffer to get streets and railways get_osmdata(city_name = city, river_name = river, network_buffer = 3500) # Use custom buffer to get buildings get_osmdata(city_name = city, river_name = river, buildings_buffer = 150) # Use custom CRS get_osmdata(city_name = city, river_name = river, crs = crs) # Avoid getting OSM data from cache get_osmdata(city_name = city, river_name = river, force_download = TRUE)
Get an area of interest (AoI) around a river, cropping to the bounding box of a city
get_river_aoi(river, city_bbox, buffer_distance)get_river_aoi(river, city_bbox, buffer_distance)
river |
A |
city_bbox |
Bounding box of class |
buffer_distance |
A positive number representing the buffer size around the river in meters. The upper limit is unrestricted. |
An sf::sfc_POLYGON object in lat/lon coordinates
bb <- get_osm_bb("Bucharest") river_centerline <- get_osm_river_centerline(bb, "Dâmbovița") river_surface <- get_osm_river_surface(bb, "Dâmbovița") river <- list(centerline = river_centerline, surface = river_surface) get_river_aoi(river = river, city_bbox = bb, buffer_distance = 100)bb <- get_osm_bb("Bucharest") river_centerline <- get_osm_river_centerline(bb, "Dâmbovița") river_surface <- get_osm_river_surface(bb, "Dâmbovița") river <- list(centerline = river_centerline, surface = river_surface) get_river_aoi(river = river, city_bbox = bb, buffer_distance = 100)
Retrieve the URLs of all the assets intersecting a bbox from a STAC API
get_stac_asset_urls(bb, endpoint = NULL, collection = NULL)get_stac_asset_urls(bb, endpoint = NULL, collection = NULL)
bb |
A bounding box, provided either as a matrix (rows for "x", "y",
columns for "min", "max") or as a vector ("xmin", "ymin", "xmax", "ymax"),
in lat/lon coordinates (WGS84 coordinate referece system) of class |
endpoint |
URL of the STAC API endpoint. To be provided together with
|
collection |
Identifier of the STAC collection to be queried. To be
provided together with |
A list of URLs for the assets in the collection overlapping with the specified bounding box
bb <- get_osm_bb("Bucharest") get_stac_asset_urls(bb) # Use non-default STAC API get_stac_asset_urls(bb, endpoint = "some endpoint", collection = "some collection")bb <- get_osm_bb("Bucharest") get_stac_asset_urls(bb) # Use non-default STAC API get_stac_asset_urls(bb, endpoint = "some endpoint", collection = "some collection")
Get the UTM zone of a spatial object
get_utm_zone(x)get_utm_zone(x)
x |
Object in any class accepted by |
The EPSG code of the UTM zone
# Get EPSG code for UTM zone of Bucharest bb <- c(xmin = 25.97, ymin = 44.33, xmax = 26.23, ymax = 44.54) get_utm_zone(bb)# Get EPSG code for UTM zone of Bucharest bb <- c(xmin = 25.97, ymin = 44.33, xmax = 26.23, ymax = 44.54) get_utm_zone(bb)
Load DEM data from a list of tiles, crop and merge using a given bounding box to create a raster DEM for the specified region. Results are cached, so that new queries with the same input parameters will be loaded from disk.
load_dem(bb, tile_urls, force_download = FALSE)load_dem(bb, tile_urls, force_download = FALSE)
bb |
A bounding box, provided either as a matrix (rows for "x", "y",
columns for "min", "max") or as a vector ("xmin", "ymin", "xmax", "ymax")
of class |
tile_urls |
A list of tiles where to read the DEM data from |
force_download |
Download data even if cached data is available |
A DEM of class terra::SpatRaster, retrieved and retiled to the
given bounding box
bb <- get_osm_bb("Bucharest") tile_urls <- get_stac_asset_urls(bb) load_dem(bb = bb, tile_urls = tile_urls, force_download = TRUE)bb <- get_osm_bb("Bucharest") tile_urls <- get_stac_asset_urls(bb) load_dem(bb = bb, tile_urls = tile_urls, force_download = TRUE)
Query the Overpass API for a key:value pair within a given bounding box (provided as lat/lon coordiates). Results are cached, so that new queries with the same input parameters will be loaded from disk.
osmdata_as_sf(key, value, aoi, force_download = FALSE)osmdata_as_sf(key, value, aoi, force_download = FALSE)
key |
A case-insensitive character vector of length 1 with the key to filter the data |
value |
A case-insensitive character vector with the value(s) to filter the data |
aoi |
An area of interest, provided either as as sf object or "bbox" or as a vector ("xmin", "ymin", "xmax", "ymax") |
force_download |
Download data even if cached data is available |
An osmdata::osmdata object with the retrieved OpenStreetMap data
bb <- get_osm_bb("Bucharest") osmdata_as_sf(key = "highway", value = "motorway", aoi = bb, force_download = FALSE)bb <- get_osm_bb("Bucharest") osmdata_as_sf(key = "highway", value = "motorway", aoi = bb, force_download = FALSE)
Reproject a raster or vector dataset to the specified coordinate reference system (CRS)
reproject(x, crs, ...)reproject(x, crs, ...)
x |
Raster ( |
crs |
CRS to be projected to, provided as |
... |
Optional arguments for raster or vector reproject functions |
sf::sf, sf::sfc, or terra::SpatRaster object reprojected
to specified CRS
# Reproject a raster to EPSG:4326 r <- terra::rast(matrix(1:12, nrow = 3, ncol = 4), crs = "EPSG:32633") reproject(r, 4326)# Reproject a raster to EPSG:4326 r <- terra::rast(matrix(1:12, nrow = 3, ncol = 4), crs = "EPSG:32633") reproject(r, 4326)