-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.Rmd
More file actions
77 lines (56 loc) · 1.48 KB
/
Copy pathscript.Rmd
File metadata and controls
77 lines (56 loc) · 1.48 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
---
title: 'Microclimate monitoring: FL panhandle'
author: "J. Alex Baecher"
date: "11/15/2019"
output: html_document
---
```{r load libraries, include=FALSE}
library(spatstat)
library(rgdal)
library(maps)
library(maptools)
library(ggplot2)
library(spocc)
library(ggmap)
library(sp)
library(lidR)
library(RSQLite)
library(tidyverse)
library(raster)
library(ggthemes)
library(spatialEco)
library(tigris)
library(cowplot)
library(rgeos)
```
```{r load data and take random sample of 100 locations from sampling area, message=FALSE, warning=FALSE}
# creat polygon from extent to random sample
states <- readShapePoly("data/tl_2019_us_state.shp", proj4string=crs(raster), verbose=TRUE)
fl_state <- states[states$NAME=="Florida",]
crs(fl_state)
e <- as(
extent(c(-87.05, -83.99944, 30.2, 30.8)),
"SpatialPolygons")
proj4string(e) <- crs(proj4string(fl_state))
sample_area <- gIntersection(fl_state, e, byid=T)
# sampling
r <- spsample(sample_area, n=500, "random")
# extrating coords
x <- r@coords[,1]
y <- r@coords[,2]
plot(sample_area)
points(coords)
# loading NicheMapR's global meteorological layers
#get.global.climate()
```
```{r apply microclimate model to 100 random points}
# for loop of microclimate model
panhandle_climate <- vector(mode="list", length=440)
data <- list()
for (i in 1:length(coords)){
data <- micro_global(loc = cbind(x[i],y[i]),
timeinterval = 12)
panhandle_climate[[i]] <- data$soil
}
df <- as.data.frame(panhandle_climate[[1]])
```