Skip to content

Commit a28def3

Browse files
committed
Update exercises before tackling #766
1 parent 7b59c49 commit a28def3

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

Diff for: _04-ex.Rmd

+10-1
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,25 @@ data(nz_height, package = "spData")
88
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.
99
How many of these high points does the Canterbury region contain?
1010

11+
**Bonus:** plot the result using the `plot()` function to show all of New Zealand, `canterbury` region highlighted in yellow, high points in Canterbury represented with black dots and
12+
13+
1114
```{r 04-ex-e1}
1215
library(tmap)
1316
# tmap_mode("view")
1417
qtm(nz) + qtm(nz_height)
1518
canterbury = nz %>% filter(Name == "Canterbury")
1619
canterbury_height = nz_height[canterbury, ]
20+
nz_not_canterbury_height = nz_height[canterbury, , op = st_disjoint]
1721
nrow(canterbury_height) # answer: 70
22+
23+
plot(nz$geom)
24+
plot(canterbury$geom, col = "yellow", add = TRUE)
25+
plot(nz_not_canterbury_height$geometry, pch = 4, col = "blue", add = TRUE)
26+
plot(canterbury_height$geometry, pch = 3, col = "red", add = TRUE)
1827
```
1928

20-
E2. Which region has the second highest number of `nz_height` points in, and how many does it have?
29+
E2. Which region has the second highest number of `nz_height` points, and how many does it have?
2130

2231
```{r 04-ex-e2}
2332
nz_height_count = aggregate(nz_height, nz, length)

0 commit comments

Comments
 (0)