Skip to content

Commit

Permalink
Update riverspace delineation vignette
Browse files Browse the repository at this point in the history
  • Loading branch information
cforgaci committed Aug 28, 2024
1 parent 800cad8 commit 08f6c83
Showing 1 changed file with 53 additions and 0 deletions.
53 changes: 53 additions & 0 deletions vignettes/riverspace-delineation.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,57 @@ knitr::opts_chunk$set(

```{r setup}
library(CRiSp)
library(osmdata)
library(sf)
```

River space delineation is a delineation step that uses the river and buildings as input to generate a polygon representing the space between the river and the first line of buildings. We will use Bucharest as the study area and the River Dâmbovița as the river.

```{r}
city_name <- "Bucharest, Romania" # Be specific and spell as in OSM
river_name <- "Dâmbovița" # Spell as it appears in OSM
epsg_code <- 32635 # UTM zone 35N
bbox_buffer <- 2000 # Buffer around the city boundary in meters
```

```{r aoi}
# Get the bounding box from the Nominatim API provided by OSM.
bb <- getbb(city_name)
aoi <- define_aoi(bb, epsg_code, bbox_buffer)
```

```{r city}
city_boundary <- osmdata_as_sf("place", "city", bb)$osm_multipolygons |>
st_transform(epsg_code) |>
st_geometry()
```

```{r river}
river_centerline <- osmdata_as_sf("waterway", "river", bb)$osm_multilines |>
filter(name == river_name) |>
st_transform(epsg_code) |>
st_geometry() |>
st_intersection(st_buffer(aoi, bbox_buffer))
river_surface <- osmdata_as_sf("natural", "water", bb)
river_surface <- river_surface$osm_multipolygons |>
bind_rows(river_surface$osm_polygons) |>
st_transform(epsg_code) |>
st_filter(river_centerline, .predicate = st_intersects) |>
st_geometry() |>
st_union()
```

```{r}
buildings <- osmdata_as_sf("building", "yes", bb)$osm_multipolygons |>
st_transform(epsg_code) |>
st_geometry()
```

The `delineate_riverspace()` function takes the city boundary, river surface and building polygons as input. If no river is found, it will return an error message. If buildings are not found, it will return an unobstructed buffer of a given radius with a warning message. By default, the river space will be capped by the city boundaries. The function returns an sf polygon.

```{r}
riverspace <- delineate_riverspace(city_boundary, river_surface, buildings)
```


0 comments on commit 08f6c83

Please sign in to comment.