-
Notifications
You must be signed in to change notification settings - Fork 35
Expand file tree
/
Copy path1_beginning_spatial_analysis.Rmd
More file actions
139 lines (79 loc) · 2.31 KB
/
1_beginning_spatial_analysis.Rmd
File metadata and controls
139 lines (79 loc) · 2.31 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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
---
title: "LAGOS Spatial Analysis"
author: "Matthew Ross"
date: "9/11/2019"
output: html_document
editor_options:
chunk_output_type: console
---
```{r setup, include=FALSE}
library(tidyverse) # Tidy packages
library(sf) #Spatial package that can read and create shapefiles
library(mapview) #Interactive maps
library(LAGOSNE) #Lots and lots of clean lake data
library(USAboundaries) #USA states and counties
```
# LAGOS Analysis
## Loading in data
### First download and then specifically grab the locus (or site lat longs)
```{r data-read}
# #Lagos download script
LAGOSNE::lagosne_get(dest_folder = LAGOSNE:::lagos_path())
#Load in lagos
lagos <- lagosne_load()
#Grab the lake centroid info
lake_centers <- lagos$locus
```
### Convert to spatial data
```{r}
#Look at the column names
#names(lake_centers)
#Look at the structure
#str(lake_centers)
#View the full dataset
#View(lake_centers %>% slice(1:100))
spatial_lakes <- st_as_sf(lake_centers,coords=c('nhd_long','nhd_lat'),
crs=4326) %>%
st_transform(2163)
#Subset for plotting
subset_spatial <- spatial_lakes %>%
slice(1:100)
subset_baser <- spatial_lakes[1:100,]
#Dynamic mapviewer
mapview(subset_spatial)
```
### Subset to only Minnesota
```{r}
states <- us_states()
#Plot all the states to check if they loaded
#mapview(states)
minnesota <- states %>%
filter(name == 'Minnesota') %>%
st_transform(2163)
#Subset lakes based on spatial position
minnesota_lakes <- spatial_lakes[minnesota,]
#Plotting the first 1000 lakes
minnesota_lakes %>%
arrange(-lake_area_ha) %>%
slice(1:1000) %>%
mapview(.,zcol = 'lake_area_ha')
```
# In-Class work
## 1) Show a map outline of Iowa and Illinois (similar to Minnesota map upstream)
```{r}
```
## 2) Subset LAGOS data to these sites, how many sites are in Illinois and Iowa
combined? How does this compare to Minnesota?
```{r}
```
## 3) What is the distribution of lake size in Iowa vs. Minnesota?
- Here I want to see a histogram plot with lake size on x-axis and frequency on
y axis (check out geom_histogram)
```{r}
```
## 4) Make an interactive plot of lakes in Iowa and Illinois and color them
by lake area in hectares
```{r}
```
## 5) What other data sources might we use to understand how reservoirs and
natural lakes vary in size in these three states?