-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path03_get_landscape_data.Rmd
89 lines (69 loc) · 1.6 KB
/
03_get_landscape_data.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
---
output: html_document
editor_options:
chunk_output_type: console
---
# Getting Background Data
## Load libraries
```{r}
# load libs
library(sf)
library(rnaturalearth)
library(osmdata)
```
## Get Africa landmass from _Natural Earth_
```{r}
# only if local data does not exist
if (!file.exists("data/africa.gpkg")) {
# get natural earth data
land <- ne_countries(
continent = "africa",
scale = "small",
returnclass = "sf"
)
# save
st_write(land, "data/africa.gpkg", append = F)
}
```
## Get Kruger boundary
The Kruger boundary was provided by SANParks.
## Get rivers from OSM
```{r}
# if data does not already exist
if (!file.exists("data/rivers_kruger.gpkg")) {
# kruger bounding box
kruger <- st_read("data/kruger_clip/kruger_clip.shp")
q <- opq(bbox = st_bbox(kruger))
# make query
query_waterways <- add_osm_feature(q,
key = "waterway",
value = c("river", "stream")
)
# run query
rivers_kruger <- osmdata_sf(query_waterways)
# get only lines
rivers_kruger <- rivers_kruger$osm_lines
# assign crs
st_crs(rivers_kruger) <- 4326
st_write(
rivers_kruger,
"data/rivers_kruger.gpkg"
)
}
```
## Get Waterholes
Waterhole locations were provided by Abi Vanak and Maria Thaker, originally from SANParks.
## Process LANDSAT data
```{r eval=FALSE}
# do not evaluate because raster is large and not on GH
# read data
temp <- raster("data/kruger_landsat5_temp.tif")
# reproject
temp_UTM <- projectRaster(
from = temp,
res = 200,
crs = st_crs(32736)$proj4string
)
# save to file
writeRaster(temp_UTM, filename = "data/kruger_temperature_UTM.tif")
```