-
Notifications
You must be signed in to change notification settings - Fork 0
/
01-load-data.Rmd
97 lines (78 loc) · 3.12 KB
/
01-load-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
90
91
92
93
94
95
96
---
title: "Coastal watersheds delineation"
author: "Kelly Hondula"
date: "3/21/2019"
output: html_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
```{r}
library(sf)
library(dplyr)
library(leaflet)
library(readr)
library(tidyr)
```
```{r}
data_dir_coastalsheds <- "/nfs/khondula-data/coastalsheds"
```
# coastal sampling point coordinates
```{r}
download.file("https://raw.githubusercontent.com/ecodasXIII/StoichPatterns/master/data/assessed_ncca2010_siteinfo.revised.06212016.csv", destfile = file.path(data_dir_coastalsheds, "ncaa_coords.csv"))
```
```{r}
ncaa_coords <- readr::read_csv(file.path(data_dir_coastalsheds, "ncaa_coords.csv"))
table(ncaa_coords$MAP_DATUM)
```
95 sites without a reported map datum, and another 11 with NA - need to decide which datum to use for those. For now make them all into wgs84 since that is what the majority of them are
```{r}
ncaa_coords_wgs84 <- ncaa_coords %>%
mutate(MAP_DATUM = replace_na("WGS84")) %>%
filter(MAP_DATUM %in% c("WGS84", "NOT REPORTED")) %>%
st_as_sf(coords = c("ALON_DD", "ALAT_DD"), crs = 4326)
ncaa_coords_nad83 <- ncaa_coords %>%
filter(MAP_DATUM == "NAD83") %>%
st_as_sf(coords = c("ALON_DD", "ALAT_DD"), crs = 4269)
ncaa_coords_sf <- ncaa_coords_nad83 %>%
st_transform(crs = 4326) %>%
rbind(ncaa_coords_wgs84)
rm(ncaa_coords, ncaa_coords_nad83, ncaa_coords_wgs84)
ncaa_coords_sf %>% st_write(file.path(data_dir_coastalsheds, "ncaa_coords_wgs84.shp"))
```
```{r}
wbd <- "https://hydro.nationalmap.gov/arcgis/services/wbd/MapServer/WMSServer"
nlcd <- "https://smallscale.nationalmap.gov/arcgis/services/LandCover/MapServer/WMSServer"
ncaa_coords_sf %>%
st_transform(4326) %>%
leaflet() %>%
addTiles() %>%
# addProviderTiles(providers$Esri.WorldImagery) %>%
addMarkers(group = "points",
clusterOptions = markerClusterOptions()) %>%
addWMSTiles(nlcd, layers = "1",
options = WMSTileOptions(format = "image/png", transparent = TRUE),
group = "NLCD") %>%
addWMSTiles(wbd, layers = "7",
options = WMSTileOptions(format = "image/png", transparent = TRUE),
group = "WBD transparent") %>%
addLayersControl(overlayGroups = c("NLCD", "WBD transparent", "points"))
```
```{r}
nhdp <- "https://basemap.nationalmap.gov/arcgis/services/USGSHydroCached/MapServer/WMSServer"
wbd <- "https://hydro.nationalmap.gov/arcgis/services/wbd/MapServer/WMSServer"
ncaa_coords_sf %>%
st_transform(4326) %>%
leaflet() %>%
addTiles(group = "OSM") %>%
addProviderTiles(providers$Esri.WorldImagery, group = "Esri imagery") %>%
addMarkers(data = ncaa_coords_sf, group = "points", label = ~SITE_ID,
clusterOptions = markerClusterOptions()) %>%
addWMSTiles(nhdp, layers = "0",
options = WMSTileOptions(format = "image/png", transparent = TRUE),
group = "NHD") %>%
addWMSTiles(wbd, layers = "7",
options = WMSTileOptions(format = "image/png", transparent = TRUE),
group = "WBD transparent") %>%
addLayersControl(baseGroups = c("OSM", "Esri imagery"), overlayGroups = c("NLCD","NHD", "WBD transparent", "points"))
```