-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathflow_duration_maps.Rmd
More file actions
117 lines (95 loc) · 3.4 KB
/
flow_duration_maps.Rmd
File metadata and controls
117 lines (95 loc) · 3.4 KB
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
---
title: "Stream Tracker flow duration map"
output: html_document
editor_options:
chunk_output_type: console
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = F,
message = F,
warning = F)
library(tidyverse)
library(mapview)
library(tmap)
library(sp)
library(raster)
library(sf)
library(here)
library(rgdal)
library(leaflet)
library(htmltools)
library(leafem)
```
```{r maps, echo = F, message = F, warning = F, include = F}
sensors <- st_read(here('data', 'sensor_st_pts.shp'))
#nhd_hr <- readOGR(here('data', 'NHD_HR_flowlines.shp'))
nhd_mr <- readOGR(here('data', 'NHD_MR_flowlines.shp'))
#st_sites <- st_read(here('data', 'ST Sites.shp'))
#st_test_sites <- st_read(here('data', 'ST Test Sites.shp'))
wbdhu8 <- st_read(here('data', 'WBDHU8.shp'))
#read in FF_predictions raster
ff <- raster(here('data', "predicted_flow_fraction.tif"))
ff[ff < 0] <- NA
crs_target <- CRS("+init=EPSG:4269")
#ff <- projectRaster(ff, crs = crs_target)
```
```{r process, echo = F, message = F, warning = F, include = F}
#st_sites %>% st_transform(., '+proj=longlat +datum=NAD83 +no_defs')
# 3857
ff <- projectRaster(ff, crs = 3857)
#sensors <- st_transform(sensors, 3857)
#wbdhu8 <- st_transform(wbdhu8, 3857)
#nhd_mr <- st_crs(3857)
#nhd_mr <- st_transform(nhd_mr, 3857)
colores <- c('#FF2B18', '#FF8C0B', '#FDD11C', '#E9FD49', '#BEFD97', '#7BFDD6',
'#2FE8FF', '#62A9FE', '#6A68FE', '#5813FC')
at <- seq(0, 1, 0.1)
cb <- colorBin(palette = colores, bins = at, domain = at,
na.color = 'transparent')
```
```{r leaf, echo = F, message = F, warning = F, fig.width= 8, fig.height=6}
map <- leaflet(sensors) %>%
clearTiles() %>%
addCircles(popup = ~htmlEscape(paste('Site:',
site)),
color = 'black',
weight = 5,
opacity = 0.8) %>%
addPolygons(data = wbdhu8,
color = 'black',
weight = 2,
fill = F) %>%
addPolylines(data = nhd_mr,
color = 'black',
weight = 1,
popup = ~htmlEscape(paste('NHD ID:', GNIS_ID))) %>%
addRasterImage(ff,
maxBytes = 16852306,
colors = cb,
layerId = 'values',
project = F,
opacity = 0.80,
group = "Flow fraction") %>%
#addMouseCoordinates() %>%
# leafem::addImageQuery(ff,
# layerId = 'values',
# type='mousemove',
# digits=3,
# position = 'topright',
# prefix='Flow fraction value') %>%
addLegend(pal = cb,
values = at,
title = 'Flow fraction') %>%
addScaleBar(position = 'bottomleft') %>%
addProviderTiles('Esri.WorldTopoMap', group = "Esri.WorldTopoMap",
options = providerTileOptions(zIndex=-10)) %>%
addProviderTiles(providers$Esri.WorldImagery, group = "Esri.WorldImagery",
options = providerTileOptions(zIndex=-10)) %>%
addProviderTiles(providers$Esri.WorldStreetMap, group = "Esri.WorldStreetMap",
options = providerTileOptions(zIndex=-10)) %>%
addLayersControl(baseGroups = c('Esri.WorldTopoMap', 'Esri.WorldImagery', "Esri.WorldStreetMap"),
overlayGroups = "Flow fraction",
options = layersControlOptions(collapsed = T,
autoZindex = FALSE))
map
```