Skip to content

Commit

Permalink
Progress on #766
Browse files Browse the repository at this point in the history
  • Loading branch information
Robinlovelace committed Mar 18, 2022
1 parent 9b27b7f commit d099188
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions _04-ex.Rmd
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
```{r 04-ex-e0, include=TRUE, message=FALSE}
library(sf)
library(dplyr)
data(nz, package = "spData")
data(nz_height, package = "spData")
library(spData)
```

E1. It was established in Section \@ref(spatial-vec) that Canterbury was the region of New Zealand containing most of the 100 highest points in the country.
Expand Down Expand Up @@ -67,6 +66,27 @@ nz_height_combined %>%
na.omit()
```

E4. To test your knowledge of spatial predicates:

- Create an object representing Colorado state in the USA, e.g. with the command
`colorado = us_states[us_states$NAME == "Colorado",]` (base R) or
`colorado = us_states %>% filter(NAME == "Colorado")` (tidyverse).
- Create a new object representing all the objects that intersect, in some way, with Colorado and plot the result.
- Create another object representing all the objects that touch Colorado and plot the result.

```{r 04-ex-4}
plot(us_states$geometry)
plot(Colorado$geometry, col = 2, add = TRUE)
colorado = us_states[us_states$NAME == "Colorado", ]
intersects_with_colorado = us_states[colorado, , op = st_intersects]
touches_colorado = us_states[colorado, , op = st_touches]
plot(us_states$geometry)
plot(touches_colorado$geometry, col = "grey", add = TRUE)
```


# What are the neighbouring states of Colorado?

E4. Use `dem = rast(system.file("raster/dem.tif", package = "spDataLarge"))`, and reclassify the elevation in three classes: low (<300), medium and high (>500).
Secondly, read the NDVI raster (`ndvi = rast(system.file("raster/ndvi.tif", package = "spDataLarge"))`) and compute the mean NDVI and the mean elevation for each altitudinal class.

Expand Down

0 comments on commit d099188

Please sign in to comment.