-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmake_polygons.R
25 lines (17 loc) · 914 Bytes
/
make_polygons.R
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
# make circles with 100 km radius centered at trap and ForCenS sites
# used to extract SST from raster data
# Lukas Jonkers, last edit 22 Mar 2019
source('make_polygon_function.R')
dat.sel <- readRDS('dat_sel.RDS')
trap.xy <- as.data.frame(t(sapply(dat.sel, function(i) c(x = i$meta$lon_dec[1], y= i$meta$lat_dec[1]))))
trap.polys <- apply(trap.xy, 1, function(x) get_polygon_function(x, 1e5))
plot(NA, ylim = c(-90, 90), xlim = c(-180, 180))
lapply(trap.polys, function(x) plot(x, add= TRUE))
saveRDS(trap.polys, 'trap_polys.RDS')
ForCenS <- readRDS('forcens_trimmed_compare.RDS')
ForCenS.xy <- cbind.data.frame(x = ForCenS$meta$Longitude, y = ForCenS$meta$Latitude)
rm(ForCenS)
ForCenS.polys <- apply(ForCenS.xy, 1, function(i) get_polygon_function(i, 1e5))
plot(NA, ylim = c(-90, 90), xlim = c(-180, 180))
lapply(ForCenS.polys, function(x) plot(x, add= TRUE))
saveRDS(ForCenS.polys, 'ForCenS_polys.RDS')