Last active
March 17, 2020 12:07
-
-
Save mstrimas/c6f305ea490ff2b842b848071bd4b138 to your computer and use it in GitHub Desktop.
eBird Status & Trends - Tompkins County
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(rasterVis) | |
library(ebirdst) | |
library(sf) | |
library(tigris) | |
library(dplyr) | |
# download data from aws | |
species <- "Swainson's Thrush" | |
dl_path <- ebirdst_download(species) | |
# tompkins boundary | |
ny_counties <- tigris::counties(state = "NY", class = "sf") | |
tompkins <- filter(ny_counties, NAME == "Tompkins") | |
# occurrence data | |
occ <- load_raster("occurrence", dl_path) | |
# abundance data | |
abd <- load_raster("abundance", dl_path) | |
# define space-time extent | |
e <- ebirdst_extent(tompkins, t = c("2018-08-01", "2018-11-30")) | |
# subset | |
occ_tmpkn <- ebirdst_subset(occ, e) | |
abd_tmpkn <- ebirdst_subset(abd, e) | |
# these are the layer dates | |
parse_raster_dates(occ_tmpkn) | |
# plot occurrence | |
lbls <- parse_raster_dates(occ_tmpkn) %>% | |
format(format = "%b %d, %y") | |
levelplot(occ_tmpkn, | |
xlab = NULL, ylab = NULL, | |
scales = list(draw=FALSE), | |
names.attr = lbls) | |
# plot abundance | |
lbls <- parse_raster_dates(abd_tmpkn) %>% | |
format(format = "%b %d, %y") | |
levelplot(abd_tmpkn, | |
xlab = NULL, ylab = NULL, | |
scales = list(draw=FALSE), | |
names.attr = lbls) | |
# save to geotiff | |
writeRaster(occ_tmpkn, "swathr_occ_tompkins.tif") | |
writeRaster(abd_tmpkn, "swathr_abd_tompkins.tif") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment