Skip to content

Commit

Permalink
markdown source builds
Browse files Browse the repository at this point in the history
Auto-generated via {sandpaper}
Source  : 988239c
Branch  : main
Author  : Claudiu Forgaci <[email protected]>
Time    : 2024-05-15 14:45:24 +0000
Message : Merge pull request #41 from carpentries-incubator/post-feedback-update-lesson-4

Post feedback update lesson 4
  • Loading branch information
actions-user committed May 15, 2024
1 parent b47841e commit 4508358
Show file tree
Hide file tree
Showing 17 changed files with 169 additions and 99 deletions.
Binary file modified .DS_Store
Binary file not shown.
82 changes: 72 additions & 10 deletions 18-import-and-visualise-osm-data.md

Large diffs are not rendered by default.

65 changes: 36 additions & 29 deletions 19-basic-gis-with-r-sf.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ After completing this episode, participants should be able to…
- Perform geoprocessing operations such as unions, joins and intersections with dedicated functions from the `sf` package
- Compute the area of spatial polygons
- Create buffers and centroids
- Map the results
- Map and save the results

::::::::::::::::::::::::::::::::::::::::::::::::

Expand All @@ -30,6 +30,8 @@ library(sf)
library(osmdata)
library(leaflet)
library(nominatimlite)
library(lwgeom)
library(here)
assign("has_internet_via_proxy", TRUE, environment(curl::has_internet))
```

Expand Down Expand Up @@ -74,7 +76,9 @@ buildings$start_date <- as.numeric(buildings$start_date)
old_buildings <- buildings %>%
filter(start_date <= old)

ggplot(data = old_buildings) + geom_sf(colour="red")
ggplot(data = old_buildings) +
geom_sf(colour="red") +
coord_sf(datum = st_crs(28992))
```

<img src="fig/19-basic-gis-with-r-sf-rendered-unnamed-chunk-2-1.png" style="display: block; margin: auto;" />
Expand Down Expand Up @@ -153,7 +157,9 @@ PROJCRS["Amersfoort / RD New",
buffer_old_buildings <-
st_buffer(x = old_buildings, dist = distance)

ggplot(data = buffer_old_buildings) + geom_sf()
ggplot(data = buffer_old_buildings) +
geom_sf() +
coord_sf(datum = st_crs(28992))
```

<img src="fig/19-basic-gis-with-r-sf-rendered-unnamed-chunk-4-1.png" style="display: block; margin: auto;" />
Expand Down Expand Up @@ -189,7 +195,8 @@ centroids_old <- st_centroid(old_buildings) %>%

ggplot() +
geom_sf(data = single_old_buffer, aes(fill=ID)) +
geom_sf(data = centroids_old)
geom_sf(data = centroids_old) +
coord_sf(datum = st_crs(28992))
```

<img src="fig/19-basic-gis-with-r-sf-rendered-unnamed-chunk-6-1.png" style="display: block; margin: auto;" />
Expand Down Expand Up @@ -218,7 +225,8 @@ Now, we would like to distinguish conservation areas based on the number of hist
begin = 0.6,
end = 1,
direction = -1,
option = "B")
option = "B") +
coord_sf(datum = st_crs(28992))
```

<img src="fig/19-basic-gis-with-r-sf-rendered-unnamed-chunk-7-1.png" style="display: block; margin: auto;" />
Expand All @@ -229,21 +237,29 @@ We aggregate them by ID number (`group_by(ID)`) and sum the variable `n` to know

### Final output:

Let's map this layer over the initial map of individual buildings.
Let's map this layer over the initial map of individual buildings, and save the result.


```r
ggplot() +
p <- ggplot() +
geom_sf(data = buildings) +
geom_sf(data = single_buffer, aes(fill=n_buildings), colour = NA) +
scale_fill_viridis_c(alpha = 0.6,
begin = 0.6,
end = 1,
direction = -1,
option = "B")
option = "B") +
coord_sf(datum = st_crs(28992))

p
```

<img src="fig/19-basic-gis-with-r-sf-rendered-unnamed-chunk-8-1.png" style="display: block; margin: auto;" />

```r
ggsave(filename = "fig/ConservationBrielle.png",
plot = p)
```

::::::::::::::::::::::::::::::::::::: challenge

Expand Down Expand Up @@ -289,17 +305,26 @@ centroid_by_buffer <- centroids_buffers %>%

single_buffer <- single_old_buffer %>%
mutate(n_buildings = centroid_by_buffer$n)
ggplot() +

pnew <- ggplot() +
geom_sf(data = buildings) +
geom_sf(data = single_buffer, aes(fill = n_buildings), colour = NA) +
scale_fill_viridis_c(alpha = 0.6,
begin = 0.6,
end = 1,
direction = -1,
option = "B")
option = "B") +
coord_sf(datum = st_crs(28992))

pnew
```

<img src="fig/19-basic-gis-with-r-sf-rendered-unnamed-chunk-9-1.png" style="display: block; margin: auto;" />

```r
ggsave(filename = "fig/ConservationBrielle_newrules.png",
plot = pnew)
```
::::::::::::::::::::::::


Expand All @@ -314,21 +339,9 @@ single_buffer <- single_old_buffer %>%
```r
single_buffer$area <- sf::st_area(single_buffer) %>%
units::set_units(., km^2)
```

```{.error}
Error in st_area.sfc(st_geometry(x), ...): package lwgeom required, please install it first
```

```r
single_buffer$old_buildings_per_km2 <- as.numeric(single_buffer$n_buildings / single_buffer$area)
```

```{.error}
Error in `[[<-.data.frame`(`*tmp*`, i, value = numeric(0)): replacement has 0 rows, data has 159
```

```r
ggplot() +
geom_sf(data = buildings) +
geom_sf(data = single_buffer, aes(fill=old_buildings_per_km2), colour = NA) +
Expand All @@ -339,13 +352,7 @@ Error in `[[<-.data.frame`(`*tmp*`, i, value = numeric(0)): replacement has 0 ro
option = "B")
```

```{.error}
Error in `geom_sf()`:
! Problem while computing aesthetics.
ℹ Error occurred in the 2nd layer.
Caused by error:
! object 'old_buildings_per_km2' not found
```
<img src="fig/19-basic-gis-with-r-sf-rendered-unnamed-chunk-10-1.png" style="display: block; margin: auto;" />



Expand Down
67 changes: 34 additions & 33 deletions 4-gis-slides.html

Large diffs are not rendered by default.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified fig/19-basic-gis-with-r-sf-rendered-unnamed-chunk-2-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified fig/19-basic-gis-with-r-sf-rendered-unnamed-chunk-4-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified fig/19-basic-gis-with-r-sf-rendered-unnamed-chunk-6-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified fig/19-basic-gis-with-r-sf-rendered-unnamed-chunk-7-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified fig/19-basic-gis-with-r-sf-rendered-unnamed-chunk-8-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified fig/19-basic-gis-with-r-sf-rendered-unnamed-chunk-9-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added fig/ConservationBrielle.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added fig/ConservationBrielle_newrules.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
54 changes: 27 additions & 27 deletions md5sum.txt
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
"file" "checksum" "built" "date"
"CODE_OF_CONDUCT.md" "c93c83c630db2fe2462240bf72552548" "site/built/CODE_OF_CONDUCT.md" "2024-05-14"
"LICENSE.md" "b24ebbb41b14ca25cf6b8216dda83e5f" "site/built/LICENSE.md" "2024-05-14"
"config.yaml" "eba2e90f9f89b711e953fb45172634ef" "site/built/config.yaml" "2024-05-14"
"index.md" "db222f765de8e62e7990ec8ba4328199" "site/built/index.md" "2024-05-14"
"links.md" "8184cf4149eafbf03ce8da8ff0778c14" "site/built/links.md" "2024-05-14"
"renv.lock" "faa3e4f5fc92beb7c4044d2633303c4c" "site/built/renv.lock" "2024-05-14"
"episodes/01-intro-to-r.Rmd" "b13d8b2857351dc5b861e6f3f86f8add" "site/built/01-intro-to-r.md" "2024-05-14"
"episodes/02-data-structures.Rmd" "2e3bbbc3ff746151b6bfeffdce1d61c9" "site/built/02-data-structures.md" "2024-05-14"
"episodes/03-explore-data.Rmd" "9e557be2898dfa30ff101cb2717b7deb" "site/built/03-explore-data.md" "2024-05-14"
"episodes/04-intro-to-visualisation.Rmd" "1837275ff28be449e5dee9fc69d49aa7" "site/built/04-intro-to-visualisation.md" "2024-05-14"
"episodes/08-intro-to-geospatial-concepts.Rmd" "cea04d6fd3be978d734ddc03483b5d58" "site/built/08-intro-to-geospatial-concepts.md" "2024-05-14"
"episodes/09-open-and-plot-vector-layers.Rmd" "cb9c1453822a18918067f5cb26a0b951" "site/built/09-open-and-plot-vector-layers.md" "2024-05-14"
"episodes/10-explore-and-plot-by-vector-layer-attributes.Rmd" "4637f1b2bf993bb4a6cb2688ebd38ea8" "site/built/10-explore-and-plot-by-vector-layer-attributes.md" "2024-05-14"
"episodes/11-plot-multiple-shape-files.Rmd" "1fa5e6d7bbce5d4bd8b2e1a083b53460" "site/built/11-plot-multiple-shape-files.md" "2024-05-14"
"episodes/12-handling-spatial-projection-and-crs.Rmd" "a0f6523fa9e0a92bf7f469fed449aa87" "site/built/12-handling-spatial-projection-and-crs.md" "2024-05-14"
"episodes/13-intro-to-raster-data.Rmd" "eacc90b2e62a4b612715534c3b92e34a" "site/built/13-intro-to-raster-data.md" "2024-05-14"
"episodes/14-plot-raster-data.Rmd" "e74c1aae5e32478ba386f15a9b7b80d9" "site/built/14-plot-raster-data.md" "2024-05-14"
"episodes/15-reproject-raster-data.Rmd" "9392077cf50153cc1443b270b904e28b" "site/built/15-reproject-raster-data.md" "2024-05-14"
"episodes/16-raster-calculations.Rmd" "b5be879fb97fb5aa53184ef3890f3243" "site/built/16-raster-calculations.md" "2024-05-14"
"episodes/17-work-with-multi-band-rasters.Rmd" "9f8d16f868ab05241d010bd3d81c641a" "site/built/17-work-with-multi-band-rasters.md" "2024-05-14"
"episodes/18-import-and-visualise-osm-data.Rmd" "70e7ee3ffe79367612ad50fa97d83f96" "site/built/18-import-and-visualise-osm-data.md" "2024-05-14"
"episodes/19-basic-gis-with-r-sf.Rmd" "cd4fe4050b67f46536fe61b3b72a43c2" "site/built/19-basic-gis-with-r-sf.md" "2024-05-14"
"instructors/instructor-notes.md" "55fd6f5f1627ddc05b0d8a25a1fc22bd" "site/built/instructor-notes.md" "2024-05-14"
"learners/reference.md" "1c7cc4e229304d9806a13f69ca1b8ba4" "site/built/reference.md" "2024-05-14"
"learners/setup.md" "dea81100282d7460d6534bcb721c6982" "site/built/setup.md" "2024-05-14"
"profiles/learner-profiles.md" "60b93493cf1da06dfd63255d73854461" "site/built/learner-profiles.md" "2024-05-14"
"renv/profiles/lesson-requirements/renv.lock" "faa3e4f5fc92beb7c4044d2633303c4c" "site/built/renv.lock" "2024-05-14"
"CODE_OF_CONDUCT.md" "c93c83c630db2fe2462240bf72552548" "site/built/CODE_OF_CONDUCT.md" "2024-05-15"
"LICENSE.md" "b24ebbb41b14ca25cf6b8216dda83e5f" "site/built/LICENSE.md" "2024-05-15"
"config.yaml" "eba2e90f9f89b711e953fb45172634ef" "site/built/config.yaml" "2024-05-15"
"index.md" "db222f765de8e62e7990ec8ba4328199" "site/built/index.md" "2024-05-15"
"links.md" "8184cf4149eafbf03ce8da8ff0778c14" "site/built/links.md" "2024-05-15"
"renv.lock" "5234c6582daf3ebb1f126ee9f57c2876" "site/built/renv.lock" "2024-05-15"
"episodes/01-intro-to-r.Rmd" "b13d8b2857351dc5b861e6f3f86f8add" "site/built/01-intro-to-r.md" "2024-05-15"
"episodes/02-data-structures.Rmd" "2e3bbbc3ff746151b6bfeffdce1d61c9" "site/built/02-data-structures.md" "2024-05-15"
"episodes/03-explore-data.Rmd" "9e557be2898dfa30ff101cb2717b7deb" "site/built/03-explore-data.md" "2024-05-15"
"episodes/04-intro-to-visualisation.Rmd" "1837275ff28be449e5dee9fc69d49aa7" "site/built/04-intro-to-visualisation.md" "2024-05-15"
"episodes/08-intro-to-geospatial-concepts.Rmd" "cea04d6fd3be978d734ddc03483b5d58" "site/built/08-intro-to-geospatial-concepts.md" "2024-05-15"
"episodes/09-open-and-plot-vector-layers.Rmd" "cb9c1453822a18918067f5cb26a0b951" "site/built/09-open-and-plot-vector-layers.md" "2024-05-15"
"episodes/10-explore-and-plot-by-vector-layer-attributes.Rmd" "4637f1b2bf993bb4a6cb2688ebd38ea8" "site/built/10-explore-and-plot-by-vector-layer-attributes.md" "2024-05-15"
"episodes/11-plot-multiple-shape-files.Rmd" "1fa5e6d7bbce5d4bd8b2e1a083b53460" "site/built/11-plot-multiple-shape-files.md" "2024-05-15"
"episodes/12-handling-spatial-projection-and-crs.Rmd" "a0f6523fa9e0a92bf7f469fed449aa87" "site/built/12-handling-spatial-projection-and-crs.md" "2024-05-15"
"episodes/13-intro-to-raster-data.Rmd" "eacc90b2e62a4b612715534c3b92e34a" "site/built/13-intro-to-raster-data.md" "2024-05-15"
"episodes/14-plot-raster-data.Rmd" "e74c1aae5e32478ba386f15a9b7b80d9" "site/built/14-plot-raster-data.md" "2024-05-15"
"episodes/15-reproject-raster-data.Rmd" "9392077cf50153cc1443b270b904e28b" "site/built/15-reproject-raster-data.md" "2024-05-15"
"episodes/16-raster-calculations.Rmd" "b5be879fb97fb5aa53184ef3890f3243" "site/built/16-raster-calculations.md" "2024-05-15"
"episodes/17-work-with-multi-band-rasters.Rmd" "9f8d16f868ab05241d010bd3d81c641a" "site/built/17-work-with-multi-band-rasters.md" "2024-05-15"
"episodes/18-import-and-visualise-osm-data.Rmd" "3f152cee5c4ab57d134057a72a44341b" "site/built/18-import-and-visualise-osm-data.md" "2024-05-15"
"episodes/19-basic-gis-with-r-sf.Rmd" "113bb971333546663f7e61f2f6498693" "site/built/19-basic-gis-with-r-sf.md" "2024-05-15"
"instructors/instructor-notes.md" "55fd6f5f1627ddc05b0d8a25a1fc22bd" "site/built/instructor-notes.md" "2024-05-15"
"learners/reference.md" "1c7cc4e229304d9806a13f69ca1b8ba4" "site/built/reference.md" "2024-05-15"
"learners/setup.md" "dea81100282d7460d6534bcb721c6982" "site/built/setup.md" "2024-05-15"
"profiles/learner-profiles.md" "60b93493cf1da06dfd63255d73854461" "site/built/learner-profiles.md" "2024-05-15"
"renv/profiles/lesson-requirements/renv.lock" "5234c6582daf3ebb1f126ee9f57c2876" "site/built/renv.lock" "2024-05-15"

0 comments on commit 4508358

Please sign in to comment.