Skip to content

Commit

Permalink
differences for PR #41
Browse files Browse the repository at this point in the history
  • Loading branch information
actions-user committed Mar 22, 2024
1 parent cb5d0a5 commit e760cb4
Show file tree
Hide file tree
Showing 17 changed files with 167 additions and 101 deletions.
Binary file modified .DS_Store
Binary file not shown.
82 changes: 70 additions & 12 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-03-20"
"LICENSE.md" "b24ebbb41b14ca25cf6b8216dda83e5f" "site/built/LICENSE.md" "2024-03-20"
"config.yaml" "5cdec2e43f9bf2f5c5c48c3c0abaa6d1" "site/built/config.yaml" "2024-03-20"
"index.md" "c3f5b43e2b2d6840652b19a83d0fc50e" "site/built/index.md" "2024-03-20"
"links.md" "8184cf4149eafbf03ce8da8ff0778c14" "site/built/links.md" "2024-03-20"
"renv.lock" "2e1773ba456fb3b57a751ca422e25129" "site/built/renv.lock" "2024-03-20"
"episodes/01-intro-to-r.Rmd" "2478c5bbe85904a35b75b76aa8a38bf2" "site/built/01-intro-to-r.md" "2024-03-20"
"episodes/02-data-structures.Rmd" "d6dfc08b875ff1ad367150a2ecc505f1" "site/built/02-data-structures.md" "2024-03-20"
"episodes/03-explore-data.Rmd" "4a37bf3e83e983b96cbb376d5fc3e399" "site/built/03-explore-data.md" "2024-03-20"
"episodes/04-intro-to-visualisation.Rmd" "0b40d9920fc04f4096bbf403c30349fe" "site/built/04-intro-to-visualisation.md" "2024-03-20"
"episodes/08-intro-to-geospatial-concepts.Rmd" "cea04d6fd3be978d734ddc03483b5d58" "site/built/08-intro-to-geospatial-concepts.md" "2024-03-20"
"episodes/09-open-and-plot-vector-layers.Rmd" "a15a86530ee76982feff608fca64dd69" "site/built/09-open-and-plot-vector-layers.md" "2024-03-20"
"episodes/10-explore-and-plot-by-vector-layer-attributes.Rmd" "f53b3d813d3ff4d341f2c58568e23c73" "site/built/10-explore-and-plot-by-vector-layer-attributes.md" "2024-03-20"
"episodes/11-plot-multiple-shape-files.Rmd" "3fef708a1a2b86b95edb09d701a39a43" "site/built/11-plot-multiple-shape-files.md" "2024-03-20"
"episodes/12-handling-spatial-projection-and-crs.Rmd" "3596828b5868119ee9d2c6d89528f630" "site/built/12-handling-spatial-projection-and-crs.md" "2024-03-20"
"episodes/13-intro-to-raster-data.Rmd" "eacc90b2e62a4b612715534c3b92e34a" "site/built/13-intro-to-raster-data.md" "2024-03-20"
"episodes/14-plot-raster-data.Rmd" "e74c1aae5e32478ba386f15a9b7b80d9" "site/built/14-plot-raster-data.md" "2024-03-20"
"episodes/15-reproject-raster-data.Rmd" "9392077cf50153cc1443b270b904e28b" "site/built/15-reproject-raster-data.md" "2024-03-20"
"episodes/16-raster-calculations.Rmd" "b5be879fb97fb5aa53184ef3890f3243" "site/built/16-raster-calculations.md" "2024-03-20"
"episodes/17-work-with-multi-band-rasters.Rmd" "9f8d16f868ab05241d010bd3d81c641a" "site/built/17-work-with-multi-band-rasters.md" "2024-03-20"
"episodes/18-import-and-visualise-osm-data.Rmd" "70e7ee3ffe79367612ad50fa97d83f96" "site/built/18-import-and-visualise-osm-data.md" "2024-03-20"
"episodes/19-basic-gis-with-r-sf.Rmd" "cd4fe4050b67f46536fe61b3b72a43c2" "site/built/19-basic-gis-with-r-sf.md" "2024-03-20"
"instructors/instructor-notes.md" "cae72b6712578d74a49fea7513099f8c" "site/built/instructor-notes.md" "2024-03-20"
"learners/reference.md" "1c7cc4e229304d9806a13f69ca1b8ba4" "site/built/reference.md" "2024-03-20"
"learners/setup.md" "dea81100282d7460d6534bcb721c6982" "site/built/setup.md" "2024-03-20"
"profiles/learner-profiles.md" "60b93493cf1da06dfd63255d73854461" "site/built/learner-profiles.md" "2024-03-20"
"renv/profiles/lesson-requirements/renv.lock" "2e1773ba456fb3b57a751ca422e25129" "site/built/renv.lock" "2024-03-20"
"CODE_OF_CONDUCT.md" "c93c83c630db2fe2462240bf72552548" "site/built/CODE_OF_CONDUCT.md" "2024-03-22"
"LICENSE.md" "b24ebbb41b14ca25cf6b8216dda83e5f" "site/built/LICENSE.md" "2024-03-22"
"config.yaml" "5cdec2e43f9bf2f5c5c48c3c0abaa6d1" "site/built/config.yaml" "2024-03-22"
"index.md" "c3f5b43e2b2d6840652b19a83d0fc50e" "site/built/index.md" "2024-03-22"
"links.md" "8184cf4149eafbf03ce8da8ff0778c14" "site/built/links.md" "2024-03-22"
"renv.lock" "10f399b80348a9f0c1c624d180939ce2" "site/built/renv.lock" "2024-03-22"
"episodes/01-intro-to-r.Rmd" "2478c5bbe85904a35b75b76aa8a38bf2" "site/built/01-intro-to-r.md" "2024-03-22"
"episodes/02-data-structures.Rmd" "d6dfc08b875ff1ad367150a2ecc505f1" "site/built/02-data-structures.md" "2024-03-22"
"episodes/03-explore-data.Rmd" "4a37bf3e83e983b96cbb376d5fc3e399" "site/built/03-explore-data.md" "2024-03-22"
"episodes/04-intro-to-visualisation.Rmd" "0b40d9920fc04f4096bbf403c30349fe" "site/built/04-intro-to-visualisation.md" "2024-03-22"
"episodes/08-intro-to-geospatial-concepts.Rmd" "cea04d6fd3be978d734ddc03483b5d58" "site/built/08-intro-to-geospatial-concepts.md" "2024-03-22"
"episodes/09-open-and-plot-vector-layers.Rmd" "a15a86530ee76982feff608fca64dd69" "site/built/09-open-and-plot-vector-layers.md" "2024-03-22"
"episodes/10-explore-and-plot-by-vector-layer-attributes.Rmd" "f53b3d813d3ff4d341f2c58568e23c73" "site/built/10-explore-and-plot-by-vector-layer-attributes.md" "2024-03-22"
"episodes/11-plot-multiple-shape-files.Rmd" "3fef708a1a2b86b95edb09d701a39a43" "site/built/11-plot-multiple-shape-files.md" "2024-03-22"
"episodes/12-handling-spatial-projection-and-crs.Rmd" "3596828b5868119ee9d2c6d89528f630" "site/built/12-handling-spatial-projection-and-crs.md" "2024-03-22"
"episodes/13-intro-to-raster-data.Rmd" "eacc90b2e62a4b612715534c3b92e34a" "site/built/13-intro-to-raster-data.md" "2024-03-22"
"episodes/14-plot-raster-data.Rmd" "e74c1aae5e32478ba386f15a9b7b80d9" "site/built/14-plot-raster-data.md" "2024-03-22"
"episodes/15-reproject-raster-data.Rmd" "9392077cf50153cc1443b270b904e28b" "site/built/15-reproject-raster-data.md" "2024-03-22"
"episodes/16-raster-calculations.Rmd" "b5be879fb97fb5aa53184ef3890f3243" "site/built/16-raster-calculations.md" "2024-03-22"
"episodes/17-work-with-multi-band-rasters.Rmd" "9f8d16f868ab05241d010bd3d81c641a" "site/built/17-work-with-multi-band-rasters.md" "2024-03-22"
"episodes/18-import-and-visualise-osm-data.Rmd" "9966faa3449fcb1c2c370b5d5309321e" "site/built/18-import-and-visualise-osm-data.md" "2024-03-22"
"episodes/19-basic-gis-with-r-sf.Rmd" "d7ca8961f8e5ab6bcb7e55e646e537f0" "site/built/19-basic-gis-with-r-sf.md" "2024-03-22"
"instructors/instructor-notes.md" "cae72b6712578d74a49fea7513099f8c" "site/built/instructor-notes.md" "2024-03-22"
"learners/reference.md" "1c7cc4e229304d9806a13f69ca1b8ba4" "site/built/reference.md" "2024-03-22"
"learners/setup.md" "dea81100282d7460d6534bcb721c6982" "site/built/setup.md" "2024-03-22"
"profiles/learner-profiles.md" "60b93493cf1da06dfd63255d73854461" "site/built/learner-profiles.md" "2024-03-22"
"renv/profiles/lesson-requirements/renv.lock" "10f399b80348a9f0c1c624d180939ce2" "site/built/renv.lock" "2024-03-22"

0 comments on commit e760cb4

Please sign in to comment.