Skip to content

Commit 6188ffb

Browse files
committed
minor edits
1 parent 6709fea commit 6188ffb

1 file changed

Lines changed: 9 additions & 4 deletions

File tree

scripts/maricopa_field_metadata.Rmd

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ knitr::opts_chunk$set(echo = TRUE)
1515

1616
```{r}
1717
library(googlesheets)
18+
library(dplyr)
1819
(my_sheets <- gs_ls())
1920
metadata_gs <- googlesheets::gs_url("https://docs.google.com/spreadsheets/d/1s-kQc3K0h4-hfwMzKOU_zpRXN5loByIpKW8Rvw76mh0")
2021
@@ -59,7 +60,7 @@ boundingbox <- rbind(elevation[longitude > -111.975][latitude == max(latitude)],
5960
elevation[longitude < -111.975][latitude == max(latitude)],
6061
elevation[longitude > -111.975][latitude == max(latitude)])
6162

62-
write.csv(boundingbox, "/tmp/macboundingbox.csv", row.names = FALSE)
63+
write.csv(boundingbox, "macboundingbox.csv", row.names = FALSE)
6364

6465
```
6566
@@ -76,6 +77,7 @@ write.csv(boundingbox, "/tmp/macboundingbox.csv", row.names = FALSE)
7677

7778
require(udunits2)
7879
library(dplyr)
80+
library(tidyr)
7981
library(ggplot2)
8082

8183
x_origin = 0
@@ -95,8 +97,8 @@ x <- x_origin + (1:columns - 1) * dx
9597
y <- y_origin + (1:ranges - 1) * (length + alley)
9698

9799
grid <- data.frame(expand.grid(x,y)) %>%
98-
transmute(plot = 1:(ranges*columns), x1 = Var1, y1 = Var2, x2 = x1 + dx, y2 = y1 + dy) %>%
99-
tidyr::gather(key = 'lat', )
100+
transmute(plot = 1:(ranges*columns), x1 = Var1, y1 = Var2, x2 = x1 + dx, y2 = y1 + dy) #%>%
101+
#tidyr::gather(key = 'lat', )
100102

101103

102104
theme_set(theme_bw())
@@ -110,7 +112,10 @@ ggplot(data = grid) +
110112
grid2 <- grid %>% gather(key, value = x, starts_with("x")) %>% gather(key2, value = y, starts_with("y")) %>% select(-starts_with("key")) %>% arrange(plot) %>% setDT
111113

112114
library(spatstat)
113-
plots <- grid2[,polygon(as.data.frame(spatstat::bounding.box.xy(x, y))),by=plot]
115+
library(wellknown)
116+
plots <- grid2[,wellknown::polygon(as.data.frame(spatstat::bounding.box.xy(x, y))), by=plot]
117+
write.csv(grid, file = '20160421_grid.csv')
118+
write.csv(plots, file = '20160421_plots.csv')
114119

115120
```
116121

0 commit comments

Comments
 (0)