-
Notifications
You must be signed in to change notification settings - Fork 0
/
day18.rmd
44 lines (28 loc) · 803 Bytes
/
day18.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
---
title: "day18"
author: "Xingxin Li"
date: "9/2/2020"
output: html_document
---
```{r, message = FALSE, warning = FALSE}
library(elevatr)
library(tidyverse)
library(ggplot2)
library(sf)
library(raster)
```
```{r, message = FALSE, warning = FALSE}
r = raster("/Users/xingxin/Github/geog176a-summer-2020-lab1/goletaelev.tif")
threshold = function(x) {ifelse(x <= 0 , NA, 1)}
threshold(-100)
(m = calc(r, threshold))
plot(r)
plot(m, col = "black")
ocean_cut = m * r
plot(ocean_cut, col = viridis::viridis(256))
(rcl = data.frame(min = seq(0,500,100),max = seq(100,600, 100), lab = c(0:5)))
(rc = reclassify(ocean_cut, rcl, lowerTRUE = TRUE))
(s = stack(r, m, ocean_cut, rc) %>%
setNames(c("elevation", "land-mask", "terrain", "topography")))
plot(s, col = viridis::viridis(256))
```