Skip to content

Instantly share code, notes, and snippets.

@kimberlyh66
Created January 9, 2019 21:52
Show Gist options
  • Save kimberlyh66/85dd71f23847a38520d60f781e1f60ba to your computer and use it in GitHub Desktop.
Save kimberlyh66/85dd71f23847a38520d60f781e1f60ba to your computer and use it in GitHub Desktop.
#install and load in the traits package
install.packages("traits")
library(traits)
#set default options
#find your api key at terraref.ncsa.illinois.edu/bety/users and save it to a file in your current directory named '.betykey'
options(betydb_key = readLines('.betykey', warn = FALSE),
betydb_url = "https://terraref.ncsa.illinois.edu/bety/",
betydb_api_version = 'v1')
#example query
#extract season 5 canopy height data for January 27, 2018
canopy_height <- betydb_query(table = 'search',
trait = "canopy_height",
method = "~Laser 3d",
sitename = "~Season 5",
date = "2018 Jan 27",
limit = 'none')
########################################################
#data is only available for specific dates
#to determine which dates data is available:
#1.) extract all canopy height data for season 5
canopy_height_all <- betydb_query(table = 'search',
trait = "canopy_height",
method = "~Laser 3d",
sitename = "~Season 5",
limit = 'none')
#2.) get dates available using the unique function
canopy_height_dates <- unique(canopy_height_all$date)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment