phenocamr

Koen Hufkens

2020-03-21

A programmatic interface to the PhenoCam web services. Allows for easy downloads of PhenoCam near-surface remote sensing greenness (Gcc) time series directly to your R workspace or your computer. Post-processing allows for the smoothing of the time-series and the calculation of phenological transition dates as a final product.

The package gives access to the latest generated PhenoCam time series (at most 1-day old for running sites) and allows for the extraction of up-to-date phenological transition dates. However, the data acquired through the package will not be curated and vetted for data quality.

For a quality controlled and fully described dataset I suggest downloading the dataset as described by Richardson et al. (2018). This dataset uses the phenocamr packages in its final processing steps however quality control is gauranteed through careful review of the data. The data can be interactivly explored on explore.phenocam.us and downloaded in full from the ORNL DAAC. If in need of more recent data you can use the package and its functionality but be mindful of quality control especially the region-of-interest (ROI) used and potential unaccounted field-of-view (FOV) shifts in the dataset.

A worked example

Below I describe the most common use of the package, downloading recent PhenoCam time series and generating phenological transition dates for a given site and data type. I intentionally disable most automated processing and step through some of the routines to illustrate the workflow which normally happens internally to the main function download_phenocam(). Generated transition date files can be used in later analysis or modelling exercises using for example the phenor R package.

Select a site

A full list of meta-data for all sites can be queried using the list_sites() function.

sites <- list_sites()
head(sites)
#>             site      lat        lon elev
#> 1         acadia 44.37694  -68.26083  158
#> 2  aguatibiaeast 33.62200 -116.86700 1086
#> 3 aguatibianorth 33.60222 -117.34368 1090
#> 4       ahwahnee 37.74670 -119.58160 1199
#> 5      alleypond 40.74284  -73.74304   61
#> 6 alligatorriver 35.78790  -75.90380    1
#>                                       contact1
#> 1         Dee Morse <dee_morse AT nps DOT gov>
#> 2  Ann E Mebane <amebane AT fs DOT fed DOT us>
#> 3                                             
#> 4         Dee Morse <dee_morse AT nps DOT gov>
#> 5 Mary Martin <mary DOT martin AT unh DOT edu>
#> 6     Asko Noormets <noormets AT tamu DOT edu>
#>                                         contact2 date_start   date_end nimage
#> 1         John Gross <John_Gross AT nps DOT gov> 2007-03-15 2020-03-20  48623
#> 2  Kristi Savig <KSavig AT air-resource DOT com> 2007-08-16 2019-01-25  36615
#> 3                                                2003-10-01 2006-10-25   2639
#> 4         John Gross <John_Gross AT nps DOT gov> 2008-08-28 2020-03-20  51302
#> 5 Nicholas Grant <ngrant02 AT fs DOT fed DOT us> 2014-11-05 2015-10-13   1452
#> 6          John King <john_king AT ncsu DOT edu> 2012-05-03 2020-03-20  54856
#>   tzoffset active infrared   method
#> 1       -5   TRUE        N httppull
#> 2       -8   TRUE        N httppull
#> 3       -8  FALSE        N httppull
#> 4       -8   TRUE        N httppull
#> 5       -5  FALSE        N  ftppush
#> 6       -5   TRUE        Y  ftppush
#>                                               site_description
#> 1 Acadia National Park, McFarland Hill, near Bar Harbor, Maine
#> 2                            Agua Tibia Wilderness, California
#> 3                            Agua Tibia Wilderness, California
#> 4          Ahwahnee Meadow, Yosemite National Park, California
#> 5                                 Alley Pond, Queens, New York
#> 6     Alligator River National Wildlife Refuge, North Carolina
#>                   group camera_description camera_orientation site_type
#> 1 National Park Service            unknown                 NE       III
#> 2                  USFS            unknown                 SW       III
#> 3                  USFS            unknown                 NE       III
#> 4 National Park Service            unknown                  E       III
#> 5          SmartForests  StarDot NetCam SC                  S        II
#> 6    PhenoCam AMERIFLUX  StarDot NetCam SC                  N         I
#>   flux_data flux_networks flux_sitenames MAT_site MAP_site MAT_daymet
#> 1     FALSE                                    NA       NA       7.05
#> 2     FALSE                                    NA       NA      15.75
#> 3     FALSE                                    NA       NA      16.00
#> 4     FALSE                                    NA       NA      12.25
#> 5     FALSE                                    NA       NA      11.90
#> 6      TRUE     AMERIFLUX         US-NC4     16.6     1310      16.75
#>   MAP_daymet MAT_worldclim MAP_worldclim
#> 1       1439           6.5          1303
#> 2        483          14.9           504
#> 3        489          13.8           729
#> 4        871          11.8           886
#> 5       1263          11.7          1109
#> 6       1371          16.4          1312
#>                                                   dominant_species
#> 1                                                                 
#> 2                                                                 
#> 3                                                                 
#> 4                                                                 
#> 5                                                                 
#> 6 Nyssa sylvatica, Taxodium distichum, Nyssa aquatica, Acer rubrum
#>   primary_veg_type secondary_veg_type koeppen_geiger ecoregion wwf_biome
#> 1               DB                 EN            Dfb         8         4
#> 2               SH                               Csa        11        12
#> 3               SH                               Csa        11        12
#> 4               EN                 GR            Csb         6         5
#> 5               DB                               Cfa         8         4
#> 6               DB                 WL            Cfa         8         5
#>   landcover_igbp
#> 1              5
#> 2              7
#> 3              7
#> 4              8
#> 5             13
#> 6              5
#>                                                                                                                                                                                                                 site_acknowledgements
#> 1                                                                                                                   Camera images from Acadia National Park are provided courtesy of the National Park Service Air Resources Program.
#> 2                                                                                                         Camera images from Agua Tibia Wilderness are provided courtesy of the USDA Forest Service Air Resources Management Program.
#> 3                                                                                                         Camera images from Agua Tibia Wilderness are provided courtesy of the USDA Forest Service Air Resources Management Program.
#> 4                                                                                                                 Camera images from Yosemite National Park are provided courtesy of the National Park Service Air Resources Program.
#> 5                                                                                                                                                                                                                                    
#> 6 Research at the Alligator River flux site is supported by DOE NICCR (award 08-SC-NICCR-1072), DOE-TES (awards 11-DE-SC-0006700 and 7090112), USDA Forest Service (award 13-JV-11330110-081) and USDA-NIFA (award 2014-67003-22068).

To select a site first download an overview meta-data table of all available sites together with their ROI id’s and vegetation type and a limited set of meta-data parameters.

Download a PhenoCam time series.

The below code shows you how to download a PhenoCam time series for the “harvard” site, ROI (roi_id) 1 and a time step frequency of 3-days. In this case the default outlier detection and smoothing routines has been disabled and will be run separately in subsequent steps. In normal use these will be enabled by default. The default output directory is tempdir() but any directory can be specified for data management purposes. If default settings are maintained, outlier detection and smoothing will be performed automatically. If so desired phenology dates can be estimated in one pass. In the latter case new data will be written in the same directory as specified for downloading the time series data.

After downloading we read in the data from disk. The data has a header and is comma separated.

df <- read_phenocam(file.path(tempdir(),"harvard_DB_1000_3day.csv"))
print(str(df))
#> List of 10
#>  $ site          : chr "harvard"
#>  $ veg_type      : chr "DB"
#>  $ roi_id        : chr "1000"
#>  $ frequency     : chr "3day"
#>  $ lat           : num 42.5
#>  $ lon           : num -72.2
#>  $ elev          : num 340
#>  $ solar_elev_min: num 10
#>  $ header        : Named chr [1:24] NA NA NA "harvard" ...
#>   ..- attr(*, "names")= chr [1:24] "#" "# 3-day summary product time series for harvard" "#" "# Site" ...
#>  $ data          :'data.frame':  4549 obs. of  32 variables:
#>   ..$ date                : chr [1:4549] "2008-01-05" "2008-01-06" "2008-01-07" "2008-01-08" ...
#>   ..$ year                : int [1:4549] 2008 2008 2008 2008 2008 2008 2008 2008 2008 2008 ...
#>   ..$ doy                 : int [1:4549] 5 6 7 8 9 10 11 12 13 14 ...
#>   ..$ image_count         : int [1:4549] NA NA NA NA NA NA NA NA NA NA ...
#>   ..$ midday_filename     : chr [1:4549] NA NA NA NA ...
#>   ..$ midday_r            : num [1:4549] NA NA NA NA NA NA NA NA NA NA ...
#>   ..$ midday_g            : num [1:4549] NA NA NA NA NA NA NA NA NA NA ...
#>   ..$ midday_b            : num [1:4549] NA NA NA NA NA NA NA NA NA NA ...
#>   ..$ midday_gcc          : num [1:4549] NA NA NA NA NA NA NA NA NA NA ...
#>   ..$ midday_rcc          : num [1:4549] NA NA NA NA NA NA NA NA NA NA ...
#>   ..$ r_mean              : num [1:4549] NA NA NA NA NA NA NA NA NA NA ...
#>   ..$ r_std               : num [1:4549] NA NA NA NA NA NA NA NA NA NA ...
#>   ..$ g_mean              : num [1:4549] NA NA NA NA NA NA NA NA NA NA ...
#>   ..$ g_std               : num [1:4549] NA NA NA NA NA NA NA NA NA NA ...
#>   ..$ b_mean              : num [1:4549] NA NA NA NA NA NA NA NA NA NA ...
#>   ..$ b_std               : num [1:4549] NA NA NA NA NA NA NA NA NA NA ...
#>   ..$ gcc_mean            : num [1:4549] NA NA NA NA NA NA NA NA NA NA ...
#>   ..$ gcc_std             : num [1:4549] NA NA NA NA NA NA NA NA NA NA ...
#>   ..$ gcc_50              : num [1:4549] NA NA NA NA NA NA NA NA NA NA ...
#>   ..$ gcc_75              : num [1:4549] NA NA NA NA NA NA NA NA NA NA ...
#>   ..$ gcc_90              : num [1:4549] NA NA NA NA NA NA NA NA NA NA ...
#>   ..$ rcc_mean            : num [1:4549] NA NA NA NA NA NA NA NA NA NA ...
#>   ..$ rcc_std             : num [1:4549] NA NA NA NA NA NA NA NA NA NA ...
#>   ..$ rcc_50              : num [1:4549] NA NA NA NA NA NA NA NA NA NA ...
#>   ..$ rcc_75              : num [1:4549] NA NA NA NA NA NA NA NA NA NA ...
#>   ..$ rcc_90              : num [1:4549] NA NA NA NA NA NA NA NA NA NA ...
#>   ..$ max_solar_elev      : num [1:4549] NA NA NA NA NA NA NA NA NA NA ...
#>   ..$ snow_flag           : logi [1:4549] NA NA NA NA NA NA ...
#>   ..$ outlierflag_gcc_mean: logi [1:4549] NA NA NA NA NA NA ...
#>   ..$ outlierflag_gcc_50  : logi [1:4549] NA NA NA NA NA NA ...
#>   ..$ outlierflag_gcc_75  : logi [1:4549] NA NA NA NA NA NA ...
#>   ..$ outlierflag_gcc_90  : logi [1:4549] NA NA NA NA NA NA ...
#>  - attr(*, "class")= chr "phenocamr"
#> NULL

Expanding 3-day data for maximum phenology resolution

The downloaded time series is of a 3-day resolution. However, to correctly evaluate the phenology on a daily time step the time series needs to be expanded to this one day time step. This can be achieved using the expand_phenocam() function.

Detect data outlier

After reading in the data as a data frame you can apply the outlier detection routine. This routine uses an iterative method to detect outlier values in the Gcc time series. This routine filters out most spurious values due contaminiation by snow, mist, rain or otherwise very bright events. Warnings are suppressed as the routine is iterative and might throw warnings if it does not converge on a solution. This has no implications for the routine and data returned.

Smoothing a time series

After detecting outliers you can smooth the data. This function uses an AIC based methodology to find the opitmal loess smoothing window. Warnings are suppressed as the routine uses an optimization in which certain parameter settings return warnings. This has no implications for the routine and data returned.

Calculating phenophases

Finally, if smoothed data is available you can calculate phenological transition dates. This routine uses a PELT changepoint detection based approach to find meaningful seasonal cycles in the data. By default start of growing season dates are returned. If the reverse parameter is set to TRUE the end of growing season dates are returned. Dates are formatted as unix time and will be provided for three default threshold values (10 / 25 / 50%) of the Gcc amplitude.

Alternatively you can use the phenophases() function which is a wrapper of the transition_dates() function. However, as it potentially writes data to disk it needs additional information such as the roi_id, site name etc. The phenophases() function is the function which generated the final data products in the Richardson et al. (2018) paper. If used internally the output will be formatted in unix time, when written to file the dates will be human readable in YYYY-MM-DD format. Both start and end of season estimates will be provided.

With the phenoogy dates calculated we can plot their respective locations on the smoothed time series. In this case the plot will show the 50% amplitude threshold values for both rising and falling parts of the 90th percentile Gcc curve, marked with green and brown vertical lines respectivelly.

References

Hufkens K., Basler J. D., Milliman T. Melaas E., Richardson A.D. 2018 An integrated phenology modelling framework in R: Phenology modelling with phenor. Methods in Ecology & Evolution, 9: 1-10.

Acknowledgements

This project was is supported by the National Science Foundation’s Macro-system Biology Program (awards EF-1065029 and EF-1702697).