library(phenocamapi)
library(phenocamr)
library(jpeg)
library(purrr)
library(magick)
library(lubridate)
library(ggplot2)
library(pals)
library(maps)
library(plotly)
Explore PhenoCam Data
DEMO: Phenocam Workshop (MEFA) by Dr. Alison Post
Some code adapted from the 2020 NEON Tutorial by Bijan Seyednasrollah
Introduction to PhenoCam
Established in 2008, the PhenoCam Network is a collection of >700 digital cameras that take regular (~ every 30 min) pictures of ecosystem canopies around the world. The name PhenoCam comes from the combination of the words “phenology” and “camera”, because the images are an easy and effective way to study the phenology, or the timing of seasonal changes, of vegetation across diverse ecosystems. The images are available in near-real time to view on the PhenoCam website, and can also be downloaded through the phenocamapi
R package, which we’ll cover in this tutorial. There are currently over 60 million images available!
Quantifying Greenness
Beyond being pretty pictures, PhenoCam images also provide a quantitative way to track vegetation phenology by measuring the intensity of canopy greenness. Digital images are stored as three different color channels - red, green, and blue (RGB) - which are the primary colors of light, and combine in different ratios to create all the visible colors in a photograph. Old-style TVs use this same method, as does your smartphone.
Each digital pixel has a numerical value for each color channel (RGB) that represents its intensity. We can use these values to quantify the relative intensity of green compared to the overall brightness of the image. We call this the Green Chromatic Coordinate (GCC) and calculate it using the equation below.
However, since PhenoCam images usually capture other things besides just the vegetation canopy (e.g., sky, ground, roads, buildings), each site has established portions of the image, or regions of interest (ROIs), that are analyzed for greenness. For example, at this forested site in Canada (lacclair), only the trees in the foreground are included in the GCC calculation:
And at this shrub site, only the shrub plants are included in the ROI and bare ground is excluded.
When GCC is calculated over a long time period at a site, a timeseries of vegetation greenness can be created. Below is the GCC timeseries for the “laccair” forest site shown above over the past 9 years. Notice the clear seasonal cycle of vegetation green-up in the spring followed by leaf color change and senescence (brown-down/death) in autumn.
Seasonal Transition Dates
These GCC timeseries can be used to extract seasonal transition dates across the years. For example, to determine the timing of spring green-up, we can use the amplitude (height) of each annual peak to determine when (what day of the year) vegetation at the site has reached either 10%, 25%, or 50% of its maximum greenness. We consider this to be the start of spring green-up. We use a similar method to extract the start of autumn brown-down.
Over a long time period, the timing of seasonal transition dates can be used to track shifts in vegetation phenology, such as with climate change. This dataset can also be used to determine which environmental and biologic factors (e.g., temperature, rainfall, sunlight) influence the timing of spring leaf-out and autumn color changes.
Your turn!
Thanks for learning about PhenoCam. Now you’ll have the chance to access images and data from a PhenoCam site of your choosing following the tutorial below!
Accessing PhenoCam Data
We’ll be using the phenocamapi
R package to directly download PhenoCam data. An API is an application programming interface (API), which is a way for two or more applications/computers to talk with one another. In this case, it allows us to directly access data from the PhenoCam database.
Then, you’ll choose a site to view some images and download greenness data. Finally, you’ll create a gif (short movie) of your site through time.
First, we need to open the required packages. A package is a collection of functions/tools to complete a desired task. For example, you need a certain set of tools to build a birdhouse, but a different set of tools to bake a cake. In this case, the phenocamapi
and phenocamr
packages have the tools to interact with and download phenocam data. The other packages listed below assist with visualization and formatting.
Next, indicate a location (file path) where you want the PhenoCam images to save. For this workshop, we’ll create a new file within GitHub Codespaces called pheno_images
.
In the future, if you’re using R Studio locally on your computer, you can enter the path to a local directory, or folder, on your computer instead (e.g., “/Users/username/Desktop/pheno_images”). Make sure to use the forward slash (/
) to separate folder names. Notice that we use the file.path()
function, which produces the correct path no matter what setup you are using.
# Designate directory (file path)
= file.path('.', 'pheno_images')
dir
# Create test_images folder
dir.create(dir)
# View directory
dir
[1] "./pheno_images"
First, we’ll download a table to see all the available PhenoCam sites and associated metadata. For example, each entry lists a site’s geographic coordinates, date of first and last image, primary vegetation type (see table below for abbreviations), and mean annual temperature and precipitation, among other things.
Vegetation types:
Abbreviation | Vegetation Type |
---|---|
AG | Agriculture |
DB | Deciduous Broadleaf |
EB | Evergreen Broadleaf |
EN | Evergreen Needleleaf |
DN | Deciduous Needleleaf |
GR | Grassland |
MX | Mixed Forest |
NV | Non-vegetated |
SH | Shrub |
TN | Tundra |
UN | Understory |
WL | Wetland |
# List metadata of all sites
<- get_phenos() sitelist_table
site | lat | lon | elev | active | utc_offset | date_first | date_last | infrared | contact1 | contact2 | site_description | site_type | group | camera_description | camera_orientation | flux_data | flux_networks | flux_sitenames | dominant_species | primary_veg_type | secondary_veg_type | site_meteorology | MAT_site | MAP_site | MAT_daymet | MAP_daymet | MAT_worldclim | MAP_worldclim | koeppen_geiger | ecoregion | landcover_igbp | dataset_version1 | site_acknowledgements | modified | flux_networks_name | flux_networks_url | flux_networks_description |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
aafcottawacfiaf14e | 45.29210 | -75.76640 | 90 | TRUE | -5 | 2020-04-27 | 2024-10-09 | N | Elizabeth Pattey <elizabeth.pattey@canada.ca> | Luc Pelletier <luc.pelletier3@canada.ca> | AAFC Site - Ottawa (On) - CFIA - Field F14 - East Flux Tower | II | NA | Campbell Scientific CCFC | NE | TRUE | NULL | NA | Zea mays, Triticum aestivum, Brassica napus, Glycine max | AG | AG | TRUE | 6.4 | 943 | 6.30 | 952 | 6.0 | 863 | Dfb | 8 | 12 | NA | Camera funded by Agriculture and Agri-Food Canada (AAFC) Project J-001735 - Commercial inhibitors’ impact on crop productivity and emissions of nitrous oxide led by Dr. Elizabeth Pattey; Support provided by Drs, Luc Pelletier and Elizabeth Pattey, Micrometeorologiccal Laboratory of AAFC - Ottawa Research and Development Centre. | 2021-08-23T12:12:59.295391-04:00 | NA | NA | NA |
aafcottawacfiaf14n | 45.29290 | -75.76700 | 90 | TRUE | -5 | 2021-09-03 | 2024-09-19 | Y | Elizabeth Pattey <elizabeth.pattey@agr.gc.ca> | Luc Pelletier <luc.pelletier3@agr.gc.ca> | AAFC Site - Ottawa (On) - CFIA - Field F14 - North Section | I | NA | StarDot NetCam SC | NNW | TRUE | NULL | Zea mays, Triticum aestivum, Brassica napus, Glycine max | AG | AG | TRUE | 6.4 | 943 | 6.30 | 953 | 5.9 | 863 | Dfb | 8 | 12 | NA | Cameras funded by Agriculture and Agri-Food Canada (AAFC) Project J-001735 - Commercial inhibitors’ impact on crop productivity and emissions of nitrous oxide led by Dr. Elizabeth Pattey; Support provided by Drs, Luc Pelletier and Elizabeth Pattey, Micrometeorologiccal Laboratory of AAFC - Ottawa Research and Development Centre. | 2021-08-13T10:49:30.502306-04:00 | NA | NA | NA | |
aafcottawacfiaf14w | 45.29210 | -75.76640 | 90 | TRUE | -5 | 2020-05-01 | 2024-10-11 | N | Elizabeth Pattey <elizabeth.pattey@canada.ca> | Luc Pelletier <luc.pelletier3@canada.ca> | AAFC Site - Ottawa (On) - CFIA - Field F14 - West Flux Tower | II | NA | Campbell Scientific CCFC | WNW | TRUE | OTHER , , Other/Unaffiliated | NA | Zea mays, Triticum aestivum, Brassica napus, Glycine max | AG | AG | TRUE | 6.4 | 943 | 6.30 | 952 | 6.0 | 863 | Dfb | 8 | 12 | NA | Cameras funded by Agriculture and Agri-Food Canada (AAFC) Project J-001735 - Commercial inhibitors’ impact on crop productivity and emissions of nitrous oxide led by Dr. Elizabeth Pattey; Support provided by Drs, Luc Pelletier and Elizabeth Pattey, Micrometeorologiccal Laboratory of AAFC - Ottawa Research and Development Centre. | 2021-08-23T12:13:11.193254-04:00 | OTHER | Other/Unaffiliated | |
acadia | 44.37694 | -68.26083 | 158 | FALSE | -5 | 2007-03-15 | 2022-01-07 | N | Dee Morse <dee_morse@nps.gov> | John Gross <John_Gross@nps.gov> | Acadia National Park, McFarland Hill, near Bar Harbor, Maine | III | National Park Service | unknown | NE | FALSE | NULL | DB | EN | FALSE | NA | NA | 7.05 | 1439 | 6.5 | 1303 | Dfb | 8 | 5 | NA | Camera images from Acadia National Park are provided courtesy of the National Park Service Air Resources Program. | 2016-11-01T15:42:15.016778-04:00 | NA | NA | NA | ||
admixpasture | -43.64930 | 172.34950 | 33 | FALSE | 12 | 2021-03-04 | 2022-09-08 | Y | John Hunt <huntj@landcareresearch.co.nz> | Scott Graham <grahams@landcareresearch.co.nz> | Eddy site, mixed species irrigated dairy pasture, Ashley Dene Research & Development Station, South Island, New Zealand | I | NA | StarDot NetCam SC | TRUE | NULL | NZ-ADw | Lolium perenne, Lolium multiflorum, Trifolium pratense, Trifolium repens, Plantago lanceolata | AG | TRUE | NA | NA | NA | NA | 11.6 | 640 | Cfb | NA | NA | NA | Ministry of Business, Innovation and Employment; New Zealand Agricultural Greenhouse Gas Research Centre; Manaaki Whenua | 2021-03-09T17:03:10.816039-05:00 | NA | NA | NA | ||
adrycpasture | -43.65130 | 172.35010 | 31 | FALSE | 12 | 2021-03-02 | 2022-09-08 | Y | John Hunt <huntj@landcareresearch.co.nz> | Scott Graham <grahams@landcareresearch.co.nz> | Ryegrass-clover irrigated dairy pasture, Ashley Dene Research & Development Station, South Island, New Zealand | I | NA | StarDot NetCamSC | TRUE | NULL | Lolium perenne, Trifolium repens | AG | TRUE | NA | NA | NA | NA | 11.6 | 639 | Cfb | NA | NA | NA | Ministry of Business, Innovation and Employment; New Zealand Agricultural Greenhouse Gas Research Centre; Manaaki Whenua | 2021-03-09T17:03:11.773814-05:00 | NA | NA | NA |
You can filter the table by any of the available attributes (column names). For example, I created a subset of only grasslands (GR) sites below.
# Create a subset of only grassland sites
<- subset(sitelist_table, primary_veg_type == "GR") GR_sites
site | lat | lon | elev | active | utc_offset | date_first | date_last | infrared | contact1 | contact2 | site_description | site_type | group | camera_description | camera_orientation | flux_data | flux_networks | flux_sitenames | dominant_species | primary_veg_type | secondary_veg_type | site_meteorology | MAT_site | MAP_site | MAT_daymet | MAP_daymet | MAT_worldclim | MAP_worldclim | koeppen_geiger | ecoregion | landcover_igbp | dataset_version1 | site_acknowledgements | modified | flux_networks_name | flux_networks_url | flux_networks_description |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
archboldbahia | 27.16560 | -81.21611 | 8 | TRUE | -5 | 2017-03-21 | 2024-11-09 | Y | Amartya Saha <asaha@archbold-station.org> | Elizabeth Boughton <eboughton@archbold-station.org> | Archbold Biological Station, Florida, USA | I | LTAR | StarDot NetCam SC | N | FALSE | NULL | NA | GR | NA | FALSE | NA | NA | 22.85 | 1302 | 22.5 | 1208 | Cfa | 8 | 14 | NA | This research was a contribution from the Long-Term Agroecosystem Research (LTAR) network. LTAR is supported by the United States Department of Agriculture. | 2022-10-19T13:24:12.256706-04:00 | NA | NA | NA | |
arsgacp2 | 31.43950 | -83.59146 | 101 | FALSE | 2 | 2016-04-27 | 2018-01-23 | Y | David Bosch <David.Bosch@ars.usda.gov> | Southeast Watershed Research Laboratory EC2 Tifton, Georgia | I | LTAR | NA | NA | FALSE | NULL | NA | GR | NA | FALSE | NA | NA | 19.00 | 1251 | 18.7 | 1213 | Cfa | 8 | 14 | NA | This research was a contribution from the Long-Term Agroecosystem Research (LTAR) network. LTAR is supported by the United States Department of Agriculture. | 2022-10-19T13:26:15.042047-04:00 | NA | NA | NA | ||
bitterbrush001 | 48.15400 | -119.94560 | 667 | TRUE | -8 | 2020-09-20 | 2024-10-12 | Y | Brandon Sackmann <bssackmann@gsi-net.com> | Brandon Sackmann <bssackmann@gsienv.com> | Parcel 1 East at Midpoint (Shrub-Steppe - Post Wildfire ca. 2014), Methow, Washington | I | NA | StarDot NetCam SC | W | FALSE | NULL | GR | SH | FALSE | 8.7 | 323 | 8.35 | 420 | 7.3 | 340 | Dsb | 10 | 1 | NA | Research at this site is supported by GSI Environmental Inc. (http://www.gsi-net.com), Olympia, WA. | 2020-10-30T10:48:53.990761-04:00 | NA | NA | NA | ||
blueoakheadquarters | 37.38270 | -121.73930 | 572 | TRUE | -8 | 2022-01-24 | 2024-11-09 | Y | Zachariah Tuhtill <ztuthill@berkeley.edu> | Zachary Harlow <harlow@berkeley.edu> | Residence Meadow, Blue Oak Ranch Reserve, Santa Clara County, CA | I | NA | StarDot NetCam SC | N | FALSE | NULL | Avena spp., Quercus lobata, Elymus trachycaulus | GR | DB | FALSE | 13.4 | 600 | 14.35 | 501 | 14.3 | 646 | Csb | 11 | 8 | NA | Blue Oak Ranch Reserve is part of the University of California Natural Reserve System. Blue Oak Ranch is administered bu the University of California, Berkeley | 2021-04-12T09:54:24.431967-04:00 | NA | NA | NA | |
bozeman | 45.78306 | -110.77778 | 2332 | FALSE | -7 | 2015-08-16 | 2019-12-18 | Y | Paul Stoy <paul.stoy@gmail.com> | Bangtail Study Area, Montana State University, Montana | I | AmericaView AMERIFLUX | StarDot NetCam SC | N | TRUE | AMERIFLUX , http://ameriflux.lbl.gov, AmeriFlux Network | US-MTB (forthcoming) | Festuca idahoensis | GR | EN | FALSE | 5.0 | 850 | 2.30 | 981 | 0.9 | 728 | Dfb | 6 | 10 | NA | Research at the Bozeman site is supported by Colorado State University and the AmericaView program (grants G13AC00393, G11AC20461, G15AC00056) with phenocam equipment and deployment sponsored by the Department of Interior North Central Climate Science Center. | 2016-11-01T15:42:19.771057-04:00 | AMERIFLUX | http://ameriflux.lbl.gov | AmeriFlux Network | |
butte | 45.95304 | -112.47964 | 1682 | TRUE | -7 | 2008-04-01 | 2024-11-09 | N | James Gallagher <jgallagher@opendap.org> | Martha Apple <MApple@mtech.edu> | Continental Divide, Butte, Montana | I | PhenoCam | StarDot NetCam SC | E | FALSE | NULL | Agropyron cristatum, Poa pratensis, Phalaris arundinaceae, Carex. sp., Geum triflorum, Ericameria nauseousa, Centaurea macula, Achillea millefolium, Senecio sp., Lupinus sp., Penstemon sp., Linaria vulgaris, Cirsium arvense; Alnus incana, Salix sp., Populus tremuloides | GR | SH | FALSE | NA | NA | 5.05 | 365 | 4.3 | 311 | BSk | 6 | 10 | NA | Research at the Continental Divide PhenoCam Site in Butte, Montana is supported by the National Science Foundation-EPSCoR (grant NSF-0701906), OpenDap, Inc., and Montana Tech of the University of Montana | 2016-11-01T15:42:19.846100-04:00 | NA | NA | NA |
Can you subset the sitelist_table by a different primary vegetation type? How about by a different variable (table column)? Use the code cell below.
Create a Map of the PhenoCam Sites
Now, we’ll create an interactive map to view all the PhenoCam sites colored by their primary vegetation type. First, using our sitelist_table
that we downloaded above, we filter out any sites for which a primary vegetation type isn’t listed or an “NA” is entered. We’ll call this new data table “sitelist_table2”.
# Remove sites with NA and empty cells for primary_veg_type
<- sitelist_table[
sitelist_table2 !(is.na(sitelist_table$primary_veg_typ) |
$primary_veg_typ==""),
sitelist_table ]
Then, we’ll create a static map of the PhenoCam sites using their latitude and longitude (included in “sitelist_table2”). We’ll overlay this onto a basemap of the world and US states.
# Download basemaps of the world and US states
<- map_data("world")
world_map <- map_data("state")
state_map
## Create map of sites
<- ggplot() +
Site_map # Add world map
geom_polygon(data = world_map, aes(x = long, y = lat, group = group),
fill = "white", color = "black") +
# Add state map
geom_polygon(data = state_map, aes(x = long, y = lat, group = group),
fill = NA, color = "black") +
# Add PhenoCam sites as points
geom_point(data = sitelist_table2, aes(x = lon, y = lat,
color = primary_veg_type,
text = paste("Site:", site)), size = 3) +
# Choose legend colors
scale_color_manual(values=as.vector(trubetskoy(11))) +
# Add title and labels
labs(title = "PhenoCam Sites by Vegetation Type", x = "Longitude",
y = "Latitude", color = "Primary Veg Type") +
# Indicate map theme (general appearance)
theme_minimal() +
# Center title and increase font size
theme(plot.title = element_text(hjust = 0.5, size = 20))
# View map
Site_map
Can you change the title of the map? Make the change and re-run the code cell above.
Let’s make the map interactive! You can hover over sites to see their details, draw a box around a specific area to zoom into the region, and click on various legend entries to toggle them on or off. Double click on the map to zoom back out.
# Make map interactive
ggplotly(Site_map)
Download & Plot Canopy Greenness
Now, let’s view some PhenoCam images and greenness data. Choose a site to explore, and enter the site name and relevant information in the cell below. For example, I chose the site “lacclair”, which represents a deciduous broadleaf (“DB”) vegetation type, and I chose to look at images from the year 2022. You’ll also need to specify which region of interest (ROI) to use for your site. Recall that some sites have multiple ROIs, each with a unique ID number. You can view the possible ROIs for your site on the PhenoCam website.
# Choose site to explore
# Enter name exactly as it appears in the table/on the website
= "lacclair"
site_name
# Indicate vegetation type (listed on site page)
= "DB"
veg
# Choose data year (for downloading images later)
= 2022
year
# Indicate ROI ID
= 1000
ROI
# View the objects to make sure correct
site_name
[1] "lacclair"
veg
[1] "DB"
year
[1] 2022
ROI
[1] 1000
First, we’ll download canopy greenness (GCC = green chromatic coordinate) timeseries data for your chosen site. The GCC data are already condensed down to 1-day and 3-day data products (type = ‘3day’ or ‘1day’). See (Richardson et al. (2018)) for more information about PhenoCam data processing.
# Download GCC timeseries
<- get_pheno_ts(
GCC_timeseries site = site_name,
vegType = veg,
roiID = ROI,
type = "3day"
)
date | year | doy | image_count | midday_filename | midday_r | midday_g | midday_b | midday_gcc | midday_rcc | r_mean | r_std | g_mean | g_std | b_mean | b_std | gcc_mean | gcc_std | gcc_50 | gcc_75 | gcc_90 | rcc_mean | rcc_std | rcc_50 | rcc_75 | rcc_90 | max_solar_elev | snow_flag | outlierflag_gcc_mean | outlierflag_gcc_50 | outlierflag_gcc_75 | outlierflag_gcc_90 | YEAR | DOY | YYYYMMDD |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
2014-08-24 | 2014 | 236 | 48 | lacclair_2014_08_24_120005.jpg | 112.4952 | 107.31002 | 64.79199 | 0.37706 | 0.39528 | 101.2134 | 10.45700 | 97.89047 | 7.24635 | 60.17627 | 3.34001 | 0.37778 | 0.00470 | 0.37674 | 0.37769 | 0.38626 | 0.38951 | 0.01273 | 0.39466 | 0.39571 | 0.39645 | 54.28096 | NA | NA | NA | NA | NA | 2014 | 236 | 2014-08-24 |
2014-08-27 | 2014 | 239 | 11 | lacclair_2014_08_27_100006.jpg | 102.9682 | 99.27311 | 58.65611 | 0.38051 | 0.39467 | 99.8069 | 7.75972 | 96.45416 | 5.20932 | 57.23162 | 3.03065 | 0.38071 | 0.00416 | 0.37808 | 0.38492 | 0.38687 | 0.39336 | 0.00810 | 0.39596 | 0.40017 | 0.40124 | 53.23820 | NA | NA | NA | NA | NA | 2014 | 239 | 2014-08-27 |
2014-08-30 | 2014 | 242 | 12 | lacclair_2014_08_29_140006.jpg | 101.5794 | 96.23061 | 61.00618 | 0.37181 | 0.39248 | 105.6391 | 3.39082 | 99.59658 | 3.11701 | 61.88915 | 1.38803 | 0.37282 | 0.00109 | 0.37296 | 0.37386 | 0.37391 | 0.39544 | 0.00168 | 0.39603 | 0.39664 | 0.39692 | 52.16943 | NA | NA | NA | NA | NA | 2014 | 242 | 2014-08-30 |
2014-09-02 | 2014 | 245 | 0 | None | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | 2014 | 245 | 2014-09-02 |
2014-09-05 | 2014 | 248 | 0 | None | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | 2014 | 248 | 2014-09-05 |
2014-09-08 | 2014 | 251 | 34 | lacclair_2014_09_08_120005.jpg | 107.3645 | 100.17020 | 62.23183 | 0.37132 | 0.39799 | 100.3327 | 8.52167 | 94.27381 | 6.62527 | 58.44414 | 4.80790 | 0.37275 | 0.00428 | 0.37085 | 0.37625 | 0.37959 | 0.39626 | 0.00779 | 0.39837 | 0.40123 | 0.40235 | 48.48855 | NA | NA | NA | NA | NA | 2014 | 251 | 2014-09-08 |
Now, we’ll plot the GCC timeseries to see how canopy greenness changes over time at your chosen site. From the “GCC_timeseries” table, we’ll plot the variable called “gcc_90”, which corresponds to the 90th percentile of GCC values across the 3-day window within the designated ROI. Using the 90th percentile (rather than the mean) reduces the influence of changing weather and brightness across the images. See Richardson et al. (2018) for more details on data products and processing.
# Put date into date format
:= as.Date(date)]
GCC_timeseries[, date
# Create line plot
plot(
$date, GCC_timeseries$gcc_90,
GCC_timeseries# Choose line color & type
col = "darkgreen", type = "b",
# Add axis labels
xlab = "Date", ylab = "GCC",
# Add title
main = paste0(site_name, ": Canopy Greenness Timeseries")
)
Since this plot isn’t saved as an object, it only appears in the built-in plot viewer for R. However, you can right click on the plot to copy and paste it elsewhere. If you accidentally close a plot and want to see it again, you can re-run the code cell that created it.
Explore Seasonal Transition Dates
We can also download and plot the 50% seasonal transition dates (spring green-up and fall brown-down) for your site. We’ll use another package called phenocamr
to download the transition dates.
# Download csv files of (1) GCC timeseries and (2) transition dates
# They will save in your designated directory (dir)
download_phenocam(
site = site_name,
veg_type = veg,
frequency = 3,
phenophase = TRUE,
out_dir = dir
)
# Read in the transition date csv file:
# Designate file location
<- file.path(
trans_dates_path
dir,paste0(
"_", veg, "_", ROI,
site_name, "_3day_transition_dates.csv"
)
)
# Read in file
<- read.table(trans_dates_path,
trans_dates header = TRUE,
sep = ","
)
site | veg_type | roi_id | direction | gcc_value | transition_10 | transition_25 | transition_50 | transition_10_lower_ci | transition_25_lower_ci | transition_50_lower_ci | transition_10_upper_ci | transition_25_upper_ci | transition_50_upper_ci | threshold_10 | threshold_25 | threshold_50 | min_gcc | max_gcc |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
lacclair | DB | 1000 | rising | gcc_90 | 2015-05-08 | 2015-05-13 | 2015-05-19 | 2015-05-06 | 2015-05-12 | 2015-05-17 | 2015-05-11 | 2015-05-14 | 2015-05-20 | 0.32106 | 0.33873 | 0.37776 | 0.31121 | 0.42854 |
lacclair | DB | 1000 | rising | gcc_90 | 2016-05-15 | 2016-05-18 | 2016-05-23 | 2016-05-14 | 2016-05-17 | 2016-05-21 | 2016-05-17 | 2016-05-20 | 2016-05-24 | 0.32244 | 0.33845 | 0.37759 | 0.31392 | 0.43161 |
lacclair | DB | 1000 | rising | gcc_90 | 2017-05-13 | 2017-05-17 | 2017-05-23 | 2017-05-11 | 2017-05-16 | 2017-05-21 | 2017-05-15 | 2017-05-19 | 2017-05-24 | 0.32248 | 0.33773 | 0.37307 | 0.31231 | 0.42586 |
lacclair | DB | 1000 | rising | gcc_90 | 2018-05-15 | 2018-05-19 | 2018-05-23 | 2018-05-14 | 2018-05-18 | 2018-05-22 | 2018-05-18 | 2018-05-20 | 2018-05-24 | 0.32262 | 0.34170 | 0.37191 | 0.31386 | 0.42995 |
lacclair | DB | 1000 | rising | gcc_90 | 2019-05-19 | 2019-05-23 | 2019-05-30 | 2019-05-18 | 2019-05-22 | 2019-05-28 | 2019-05-22 | 2019-05-25 | 2019-05-31 | 0.32253 | 0.33885 | 0.37437 | 0.31314 | 0.43380 |
lacclair | DB | 1000 | rising | gcc_90 | 2020-05-18 | 2020-05-20 | 2020-05-24 | 2020-05-17 | 2020-05-19 | 2020-05-23 | 2020-05-19 | 2020-05-22 | 2020-05-25 | 0.32535 | 0.33622 | 0.37202 | 0.31401 | 0.42981 |
Now we’ll plot the transition dates on the GCC timeseries.
# Pull out transition dates from the trans_dates table
# Select the rising (spring dates) for 50% threshold of Gcc 90
<- trans_dates[
td_rise $direction == "rising" & trans_dates$gcc_value == "gcc_90",
trans_dates
]
# Select the falling (fall dates) for 50% threshold of Gcc 90
<- trans_dates[
td_fall $direction == "falling" & trans_dates$gcc_value == "gcc_90",
trans_dates
]
# As above, create a simple line graph of the Green Chromatic Coordinate (GCC)
# Plot- this time use "type = 1" to create a smooth line graph
plot(GCC_timeseries$date, GCC_timeseries$gcc_90,
col = "black", type = "l",
xlab = "Date", ylab = "GCC",
main = paste0(site_name, ": ", "Seasonal Transition Dates")
)
# Add points to show transition dates:
# Spring green-up
points(
x = as.Date(td_rise$transition_50, origin = "1970-01-01"),
y = td_rise$threshold_50,
pch = 19,
col = "green"
)
# Fall brown-down
points(
x = as.Date(td_fall$transition_50, origin = "1970-01-01"),
y = td_fall$threshold_50,
pch = 19,
col = "brown"
)
Now, let’s explore the variability of seasonal transition dates throughout the available data years. This works best if you chose a site with a longer timeseries. We’ll first convert the transition dates into a “day-of-year” (DOY) format (e.g., Jan 1 = DOY 1, Jan 2 = DOY 2, etc.), and then plot those by year.
# Convert green-up dates to date format and then DOY
<- as.Date(td_rise$transition_50,format='%Y-%m-%d')
td_spring_dates <- lubridate::yday(td_spring_dates)
td_spring_DOY
# Convert brown-down dates to date format and then DOY
<- as.Date(td_fall$transition_50,format='%Y-%m-%d')
td_fall_dates <- lubridate::yday(td_fall_dates)
td_fall_DOY
# Extract spring data years
<- as.numeric(format(td_spring_dates,'%Y'))
years_spr
# Create table of years and spring transition dates
<- data.frame(years_spr, td_spring_DOY)
trans_table_spring
# Plot spring green-up dates
plot(trans_table_spring[,1],trans_table_spring[,2],
type = "b", col = "darkgreen",
xlab = 'Year', ylab = 'Spring Transition Date (DOY)',
main = paste0(site_name, ': ', 'Date of Spring Onset Through the Years'))
And now plot the fall brown-down transition dates.
# Extract fall data years
<- as.numeric(format(td_fall_dates,'%Y'))
years_fall
# Create table of years and fall transition dates
<- data.frame(years_fall, td_fall_DOY)
trans_table_fall
# Plot fall brown-down dates
plot(trans_table_fall[,1], trans_table_fall[,2],
type = "b", col = "brown",
xlab = 'Year', ylab = 'Autumn Transition Date (DOY)',
main = paste0(site_name, ': ', 'Date of Autumn Onset Through the Years'))
As you can see, there is a decent amount of year-to-year variability in when a site greens up (spring) or browns down (fall), directly impacting the total length of the growing sesason. This variability is largely due to differences in weather, such as precipitation and temperature. Climate change is also shifting seasonal transition dates, which can impact many other variables, such as plant-animal interactions and ecosystem carbon and water storage.
Download PhenoCam Images
Next, we’ll download some photos from your chosen site. Images are typically taken every 30 minutes, but for simplicity, we’ll just download 1 image per month in order to visualize phenology changes. This code downloads the midday (~12 pm) image for the 15th day (“days = 15”) of each month (“months = 1:12”) for the year you chose above. The images will appear in the folder you designated above (dir).
# Download PhenoCam images
download_midday_images(
site = site_name,
y = year,
months = 1:12,
days = 15,
download_dir = dir
)
Now, we’ll use those images to create a photo collage that displays changes in phenology throughout the year. First, we’ll set it up and check that it’s working correctly. You should have 12 images (1 per month), so when you run the code below, “n” should equal 12. If not, look in your “dir” (pheno_images) folder and make sure it only includes images for a single PhenoCam site. If you have more than 12, right click on the images you don’t want and delete them from the folder.
# Isolate images from your designated directory
# Pics are jpeg format
<- dir(dir, pattern = "*.jpg", full.names = TRUE)
middays_path
# See a sample of image directory paths to make sure it worked
head(middays_path)
[1] "./pheno_images/lacclair_2022_01_15_120011.jpg"
[2] "./pheno_images/lacclair_2022_02_15_120010.jpg"
[3] "./pheno_images/lacclair_2022_03_15_120007.jpg"
[4] "./pheno_images/lacclair_2022_04_15_120008.jpg"
[5] "./pheno_images/lacclair_2022_05_15_120005.jpg"
[6] "./pheno_images/lacclair_2022_06_15_120006.jpg"
# Determine number of images (should be 12, 1 per month)
<- length(middays_path)
n n
[1] 12
Then we’ll create the layout.
# Set up image layout (4 rows & 3 columns)
par(
mar = c(0, 0, 0, 0),
mfrow = c(4, 3)
)
# Create monthly image layout with labels (this can take 1-2 min)
for (i in 1:n) {
<- jpeg::readJPEG(middays_path[i])
img plot(0:1, 0:1, type = "n", axes = FALSE, xlab = "", ylab = "")
rasterImage(img, 0, 0, 1, 1)
mtext(month.name[i], line = -2)
}
# Add title (feel free to edit the title below)
mtext(
paste0(site_name, ": ", "Canopy Greenness Through the Months"),
outer = TRUE
)
Finally, we’ll use those same images to create a gif that shows changes in phenology over time. This is great to use in presentations to visualize seasonal transitions!
# Make timelapse gif of images
<- list.files(path = dir, pattern = "*.jpg", full.names = T) %>%
gif
::map(image_read) %>%
purrr
image_join() %>%
# Add text to each image - you can change the size, location, color below
image_annotate(paste(site_name,"Jan-Dec", year),
location = "+900+30",
size = 35,
color = "black") %>%
# Frames per second (higher number = faster, lower number = slower)
image_animate(fps=0.5) %>%
# Designate file name & save to your directory
image_write(file.path(dir, "MonthlyGreenness_gif.gif"))
# The gif will be saved to the directory you indicated at the beginning
# You can check the directory path below
dir
[1] "./pheno_images"
As an example, here’s the gif I made for the lacclair site. Your gif will be saved to the directory you indicated at the beginning (dir). If you want to save it, right click on the gif file name and select “download”.
Explore another site!
Now try this exercise with another PhenoCam site. Perhaps choose a different ecosystem type. Think about how seasonal greenness patterns differ between sites. What do you think causes these differences?
To do this, edit the cell near the beginning where you assign the site name, vegetation type, year, and ROI (in the “Download & Plot Canopy Greenness” section). Be sure to re-run that cell and all cells below it in sequential order.
But before trying a new site, run this code cell to re-set your plotting parameters and delete all the downloaded files in your “pheno_images” (dir) folder. Be sure to download your gif first if you want to save a copy.
# Reset plotting parameters
dev.off()
# List all files in "pheno_images"
<- list.files(dir, include.dirs = F, full.names = T, recursive = T)
f
# Remove the files
file.remove(f)
Thank you
Thanks for exploring PhenoCam data. Hopefully, you have a stronger appreciation for phenology now!