| 
1 | 1 | ```{r 04-ex-e0, include=TRUE, message=FALSE}  | 
2 | 2 | library(sf)  | 
3 | 3 | library(dplyr)  | 
4 |  | -data(nz, package = "spData")  | 
5 |  | -data(nz_height, package = "spData")  | 
 | 4 | +library(spData)  | 
6 | 5 | ```  | 
7 | 6 | 
 
  | 
8 | 7 | 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.  | 
@@ -67,6 +66,27 @@ nz_height_combined %>%  | 
67 | 66 |   na.omit()  | 
68 | 67 | ```  | 
69 | 68 | 
 
  | 
 | 69 | +E4. To test your knowledge of spatial predicates:  | 
 | 70 | + | 
 | 71 | +- Create an object representing Colorado state in the USA, e.g. with the command   | 
 | 72 | +`colorado = us_states[us_states$NAME == "Colorado",]` (base R) or  | 
 | 73 | +`colorado = us_states %>% filter(NAME == "Colorado")` (tidyverse).  | 
 | 74 | +- Create a new object representing all the objects that intersect, in some way, with Colorado and plot the result.  | 
 | 75 | +- Create another object representing all the objects that touch Colorado and plot the result.  | 
 | 76 | + | 
 | 77 | +```{r 04-ex-4}  | 
 | 78 | +plot(us_states$geometry)  | 
 | 79 | +plot(Colorado$geometry, col = 2, add = TRUE)  | 
 | 80 | +colorado = us_states[us_states$NAME == "Colorado", ]  | 
 | 81 | +intersects_with_colorado = us_states[colorado, , op = st_intersects]  | 
 | 82 | +touches_colorado = us_states[colorado, , op = st_touches]  | 
 | 83 | +plot(us_states$geometry)  | 
 | 84 | +plot(touches_colorado$geometry, col = "grey", add = TRUE)  | 
 | 85 | +```  | 
 | 86 | + | 
 | 87 | + | 
 | 88 | +# What are the neighbouring states of Colorado?   | 
 | 89 | + | 
70 | 90 | E4. Use `dem = rast(system.file("raster/dem.tif", package = "spDataLarge"))`, and reclassify the elevation in three classes: low (<300), medium and high (>500).  | 
71 | 91 | 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.  | 
72 | 92 | 
 
  | 
 | 
0 commit comments