DAYMET API

Table of Contents

GET GetMetricsList

This endpoint retrieves a list of all available metrics from the DAYMET database

URL:

https://devise.uwyo.edu/Umbraco/api/DaymetApi/GetMetricsList

Parameters:

This endpoint does not require any parameters

Response:

[
    {
        "metric": "prcp",
    },
    {
        "metric": "swe",
    },
    {
        "metric": "tmax",
    },
    {
        "metric": "tmin",
    }
]

GET GetDerivedAnnualMetricsList

This endpoint retrieves a list of all available DAYMET annual derived metrics 

URL:

https://devise.uwyo.edu/Umbraco/api/DaymetApi/GetDerivedAnnualMetricsList

Parameters:

This endpoint does not require any parameters

Response:

[
    {
        "metric": "Maxprcp",
        "temporal": "Annual",
        "maxDate": "2022-01-01T00:00:00"
    },
    {
        "metric": "Maxswe",
        "temporal": "Annual",
        "maxDate": "2022-01-01T00:00:00"
    },
    {
        "metric": "Maxtmax",
        "temporal": "Annual",
        "maxDate": "2022-01-01T00:00:00"
    },
    {
        "metric": "Maxtmin",
        "temporal": "Annual",
        "maxDate": "2022-01-01T00:00:00"
    },
    {
        "metric": "Meanprcp",
        "temporal": "Annual",
        "maxDate": "2022-01-01T00:00:00"
    },
    {
        "metric": "Meanswe",
        "temporal": "Annual",
        "maxDate": "2022-01-01T00:00:00"
    },
    {
        "metric": "Meantmax",
        "temporal": "Annual",
        "maxDate": "2022-01-01T00:00:00"
    },
    {
        "metric": "Meantmin",
        "temporal": "Annual",
        "maxDate": "2022-01-01T00:00:00"
    },
    {
        "metric": "Medianprcp",
        "temporal": "Annual",
        "maxDate": "2022-01-01T00:00:00"
    },
    {
        "metric": "Medianswe",
        "temporal": "Annual",
        "maxDate": "2022-01-01T00:00:00"
    },
    {
        "metric": "Mediantmax",
        "temporal": "Annual",
        "maxDate": "2022-01-01T00:00:00"
    },
    {
        "metric": "Mediantmin",
        "temporal": "Annual",
        "maxDate": "2022-01-01T00:00:00"
    },
    {
        "metric": "Sumprcp",
        "temporal": "Annual",
        "maxDate": "2022-01-01T00:00:00"
    }
]

GET GetDerivedMonthlyMetricsList

This endpoint retrieves a list of all available DAYMET monthly derived metrics

URL:

https://devise.uwyo.edu/Umbraco/api/DaymetApi/GetDerivedMonthlyMetricsList

Parameters:

This endpoint does not require any parameters

Response:

[
    {
        "metric": "Maxprcp",
        "temporal": "Monthly",
        "maxDate": "2022-12-01T00:00:00"
    },
    {
        "metric": "Maxswe",
        "temporal": "Monthly",
        "maxDate": "2022-12-01T00:00:00"
    },
    {
        "metric": "Maxtmax",
        "temporal": "Monthly",
        "maxDate": "2022-12-01T00:00:00"
    },
    {
        "metric": "Maxtmin",
        "temporal": "Monthly",
        "maxDate": "2022-12-01T00:00:00"
    },
    {
        "metric": "Meanprcp",
        "temporal": "Monthly",
        "maxDate": "2022-12-01T00:00:00"
    },
    {
        "metric": "Meanswe",
        "temporal": "Monthly",
        "maxDate": "2022-12-01T00:00:00"
    },
    {
        "metric": "Meantmax",
        "temporal": "Monthly",
        "maxDate": "2022-12-01T00:00:00"
    },
    {
        "metric": "Meantmin",
        "temporal": "Monthly",
        "maxDate": "2022-12-01T00:00:00"
    },
    {
        "metric": "Medianprcp",
        "temporal": "Monthly",
        "maxDate": "2022-12-01T00:00:00"
    },
    {
        "metric": "Medianswe",
        "temporal": "Monthly",
        "maxDate": "2022-12-01T00:00:00"
    },
    {
        "metric": "Mediantmax",
        "temporal": "Monthly",
        "maxDate": "2022-12-01T00:00:00"
    },
    {
        "metric": "Mediantmin",
        "temporal": "Monthly",
        "maxDate": "2022-12-01T00:00:00"
    },
    {
        "metric": "Sumprcp",
        "temporal": "Monthly",
        "maxDate": "2022-12-01T00:00:00"
    }
]

GET GetDerivedWeeklyMetricsList

This endpoint retrieves a list of all available DAYMET weekly derived metrics

URL:

https://devise.uwyo.edu/Umbraco/api/DaymetApi/GetDerivedWeeklyMetricsList

Parameters:

This endpoint does not require any parameters

Response:

[
    {
        "metric": "Maxprcp",
        "temporal": "Weekly",
        "maxDate": "2022-12-26T00:00:00"
    },
    {
        "metric": "Maxswe",
        "temporal": "Weekly",
        "maxDate": "2022-12-26T00:00:00"
    },
    {
        "metric": "Maxtmax",
        "temporal": "Weekly",
        "maxDate": "2022-12-26T00:00:00"
    },
    {
        "metric": "Maxtmin",
        "temporal": "Weekly",
        "maxDate": "2022-12-26T00:00:00"
    },
    {
        "metric": "Meanprcp",
        "temporal": "Weekly",
        "maxDate": "2022-12-26T00:00:00"
    },
    {
        "metric": "Meanswe",
        "temporal": "Weekly",
        "maxDate": "2022-12-26T00:00:00"
    },
    {
        "metric": "Meantmax",
        "temporal": "Weekly",
        "maxDate": "2022-12-26T00:00:00"
    },
    {
        "metric": "Meantmin",
        "temporal": "Weekly",
        "maxDate": "2022-12-26T00:00:00"
    },
    {
        "metric": "Medianprcp",
        "temporal": "Weekly",
        "maxDate": "2022-12-26T00:00:00"
    },
    {
        "metric": "Medianswe",
        "temporal": "Weekly",
        "maxDate": "2022-12-26T00:00:00"
    },
    {
        "metric": "Mediantmax",
        "temporal": "Weekly",
        "maxDate": "2022-12-26T00:00:00"
    },
    {
        "metric": "Mediantmin",
        "temporal": "Weekly",
        "maxDate": "2022-12-26T00:00:00"
    },
    {
        "metric": "Sumprcp",
        "temporal": "Weekly",
        "maxDate": "2022-12-26T00:00:00"
    }
]

GET GetAllMetricMaxDate

This endpoint retrieves a list of all available metrics along with the maximum date stored in the DAYMET database.

URL:

https://devise.uwyo.edu/Umbraco/api/DaymetApi/GetAllMetricMaxDate

Parameters:

This endpoint does not require any parameters

Response:

[
    {
        "dataset": null,
        "metric": "prcp",
        "temporal": null,
        "maxDate": "2022-12-31T00:00:00"
    },
    {
        "dataset": null,
        "metric": "swe",
        "temporal": null,
        "maxDate": "2022-12-31T00:00:00"
    },
    {
        "dataset": null,
        "metric": "tmax",
        "temporal": null,
        "maxDate": "2022-12-31T00:00:00"
    },
    {
        "dataset": null,
        "metric": "tmin",
        "temporal": null,
        "maxDate": "2022-12-31T00:00:00"
    }
]

POST GetData

This endpoint retrieves filtered DAYMET data to facilitate downloading of files

URL:

https://devise.uwyo.edu/Umbraco/api/DaymetApi/GetData

Parameters:

  • StartDate (string): The start date in YYYY-MM-DD format.
  • EndDate (string): The end date in YYYY-MM-DD format.
  • Metrics (json string array): A comma separated array of DAYMET metrics.

JSON Format:

{
  "StartDate": "2010-01-01",
  "EndDate": "2010-01-02",
  "Metrics": ["prcp"]
}

Response:

[
    {
        "filename": "DAYMET_v4_20100101_prcp.tif",
        "metric": "prcp",
        "version": "v4",
        "sampDate": "2010-01-01T00:00:00",
        "sampYear": 2010,
        "sampMonth": 1,
        "sampDay": 1,
        "doy": 1,
        "url": "https://pathfinder.arcc.uwyo.edu/devise/DAYMET/DAYMET_prcp/DAYMET_v4_20100101_prcp.tif",
        "resolution": "1 km",
        "source": "https://thredds.daac.ornl.gov/thredds/catalog/ornldaac/1840/catalog.html",
        "crs": "epsg:5072"
    },
    {
        "filename": "DAYMET_v4_20100102_prcp.tif",
        "metric": "prcp",
        "version": "v4",
        "sampDate": "2010-01-02T00:00:00",
        "sampYear": 2010,
        "sampMonth": 1,
        "sampDay": 2,
        "doy": 2,
        "url": "https://pathfinder.arcc.uwyo.edu/devise/DAYMET/DAYMET_prcp/DAYMET_v4_20100102_prcp.tif",
        "resolution": "1 km",
        "source": "https://thredds.daac.ornl.gov/thredds/catalog/ornldaac/1840/catalog.html",
        "crs": "epsg:5072"
    }
]

POST GetDerivedAnnualData

This endpoint retrieves filtered DAYMET derived annual data to facilitate downloading of files

URL:

https://devise.uwyo.edu/Umbraco/api/DaymetApi/GetDerivedAnnualData

Parameters:

  • StartDate (string): The start date in YYYY-MM-DD format.
  • EndDate (string): The end date in YYYY-MM-DD format.
  • Years (json int array): A comma separated array of desired years
  • Months (json int array): A comma separated array of desired months
  • Metrics (json string array): A comma separated array of DAYMET metrics.
{
    "StartDate": "1981-01-01",
    "EndDate": "1982-01-01",
    "Years" : null,
    "Months": null,
    "Metrics": ["Maxprcp"]
}

Response:

[
    {
        "filename": "DAYMET_Maxprcp_1981.tif",
        "temporal": "Annual",
        "metric": "Maxprcp",
        "sampDate": "1981-01-01T00:00:00",
        "sampYear": 1981,
        "sampMonth": 1,
        "sampDay": 1,
        "sampWeek": 1,
        "url": "https://pathfinder.arcc.uwyo.edu/devise/DAYMET_DerivedMetrics/DAYMET_Maxprcp_Annual/DAYMET_Maxprcp_1981.tif",
        "resolution": "1 km",
        "source": "DEVISER DAYMET",
        "crs": "epsg:5072"
    },
    {
        "filename": "DAYMET_Maxprcp_1982.tif",
        "temporal": "Annual",
        "metric": "Maxprcp",
        "sampDate": "1982-01-01T00:00:00",
        "sampYear": 1982,
        "sampMonth": 1,
        "sampDay": 1,
        "sampWeek": 1,
        "url": "https://pathfinder.arcc.uwyo.edu/devise/DAYMET_DerivedMetrics/DAYMET_Maxprcp_Annual/DAYMET_Maxprcp_1982.tif",
        "resolution": "1 km",
        "source": "DEVISER DAYMET",
        "crs": "epsg:5072"
    }
]

POST GetDerivedMonthlyData

This endpoint retrieves filtered DAYMET derived monthly data to facilitate downloading of files

URL:

https://devise.uwyo.edu/Umbraco/api/DaymetApi/GetDerivedMonthlyData

Parameters:

  • StartDate (string): The start date in YYYY-MM-DD format.
  • EndDate (string): The end date in YYYY-MM-DD format.
  • Years (json int array): A comma separated array of desired years
  • Months (json int array): A comma separated array of desired months
  • Metrics (json string array): A comma separated array of DAYMET metrics.
{
    "StartDate": "1981-01-01",
    "EndDate": "1981-03-01",
    "Years" : null,
    "Months": null,
    "Metrics": ["Meanswe"]
}

Response:

[
    {
        "filename": "DAYMET_Meanswe_198101.tif",
        "temporal": "Monthly",
        "metric": "Meanswe",
        "sampDate": "1981-01-01T00:00:00",
        "sampYear": 1981,
        "sampMonth": 1,
        "sampDay": 1,
        "sampWeek": 1,
        "url": "https://pathfinder.arcc.uwyo.edu/devise/DAYMET_DerivedMetrics/DAYMET_Meanswe_Monthly/DAYMET_Meanswe_198101.tif",
        "resolution": "1 km",
        "source": "DEVISER DAYMET",
        "crs": "epsg:5072"
    },
    {
        "filename": "DAYMET_Meanswe_198102.tif",
        "temporal": "Monthly",
        "metric": "Meanswe",
        "sampDate": "1981-02-01T00:00:00",
        "sampYear": 1981,
        "sampMonth": 2,
        "sampDay": 1,
        "sampWeek": 5,
        "url": "https://pathfinder.arcc.uwyo.edu/devise/DAYMET_DerivedMetrics/DAYMET_Meanswe_Monthly/DAYMET_Meanswe_198102.tif",
        "resolution": "1 km",
        "source": "DEVISER DAYMET",
        "crs": "epsg:5072"
    },
    {
        "filename": "DAYMET_Meanswe_198103.tif",
        "temporal": "Monthly",
        "metric": "Meanswe",
        "sampDate": "1981-03-01T00:00:00",
        "sampYear": 1981,
        "sampMonth": 3,
        "sampDay": 1,
        "sampWeek": 9,
        "url": "https://pathfinder.arcc.uwyo.edu/devise/DAYMET_DerivedMetrics/DAYMET_Meanswe_Monthly/DAYMET_Meanswe_198103.tif",
        "resolution": "1 km",
        "source": "DEVISER DAYMET",
        "crs": "epsg:5072"
    }
]

POST GetDerivedWeeklyData

This endpoint retrieves filtered DAYMET derived weekly data to facilitate downloading of files

URL:

https://devise.uwyo.edu/Umbraco/api/DaymetApi/GetDerivedWeeklyData

Parameters:

  • StartDate (string): The start date in YYYY-MM-DD format.
  • EndDate (string): The end date in YYYY-MM-DD format.
  • Years (json int array): A comma separated array of desired years
  • Months (json int array): A comma separated array of desired months
  • Metrics (json string array): A comma separated array of DAYMET metrics.
{
    "StartDate": null,
    "EndDate": null,
    "Years" : [2003, 2004],
    "Months": [1],
    "Metrics": ["Maxprcp"]
}

Response:

[
    {
        "filename": "DAYMET_Maxprcp_200301.tif",
        "temporal": "Weekly",
        "metric": "Maxprcp",
        "sampDate": "2003-01-06T00:00:00",
        "sampYear": 2003,
        "sampMonth": 1,
        "sampDay": 6,
        "sampWeek": 1,
        "url": "https://pathfinder.arcc.uwyo.edu/devise/DAYMET_DerivedMetrics/DAYMET_Maxprcp_Weekly/DAYMET_Maxprcp_200301.tif",
        "resolution": "1 km",
        "source": "DEVISER DAYMET",
        "crs": "epsg:5072"
    },
    {
        "filename": "DAYMET_Maxprcp_200302.tif",
        "temporal": "Weekly",
        "metric": "Maxprcp",
        "sampDate": "2003-01-13T00:00:00",
        "sampYear": 2003,
        "sampMonth": 1,
        "sampDay": 13,
        "sampWeek": 2,
        "url": "https://pathfinder.arcc.uwyo.edu/devise/DAYMET_DerivedMetrics/DAYMET_Maxprcp_Weekly/DAYMET_Maxprcp_200302.tif",
        "resolution": "1 km",
        "source": "DEVISER DAYMET",
        "crs": "epsg:5072"
    },
    {
        "filename": "DAYMET_Maxprcp_200303.tif",
        "temporal": "Weekly",
        "metric": "Maxprcp",
        "sampDate": "2003-01-20T00:00:00",
        "sampYear": 2003,
        "sampMonth": 1,
        "sampDay": 20,
        "sampWeek": 3,
        "url": "https://pathfinder.arcc.uwyo.edu/devise/DAYMET_DerivedMetrics/DAYMET_Maxprcp_Weekly/DAYMET_Maxprcp_200303.tif",
        "resolution": "1 km",
        "source": "DEVISER DAYMET",
        "crs": "epsg:5072"
    },
    {
        "filename": "DAYMET_Maxprcp_200304.tif",
        "temporal": "Weekly",
        "metric": "Maxprcp",
        "sampDate": "2003-01-27T00:00:00",
        "sampYear": 2003,
        "sampMonth": 1,
        "sampDay": 27,
        "sampWeek": 4,
        "url": "https://pathfinder.arcc.uwyo.edu/devise/DAYMET_DerivedMetrics/DAYMET_Maxprcp_Weekly/DAYMET_Maxprcp_200304.tif",
        "resolution": "1 km",
        "source": "DEVISER DAYMET",
        "crs": "epsg:5072"
    },
    {
        "filename": "DAYMET_Maxprcp_200401.tif",
        "temporal": "Weekly",
        "metric": "Maxprcp",
        "sampDate": "2004-01-05T00:00:00",
        "sampYear": 2004,
        "sampMonth": 1,
        "sampDay": 5,
        "sampWeek": 1,
        "url": "https://pathfinder.arcc.uwyo.edu/devise/DAYMET_DerivedMetrics/DAYMET_Maxprcp_Weekly/DAYMET_Maxprcp_200401.tif",
        "resolution": "1 km",
        "source": "DEVISER DAYMET",
        "crs": "epsg:5072"
    },
    {
        "filename": "DAYMET_Maxprcp_200402.tif",
        "temporal": "Weekly",
        "metric": "Maxprcp",
        "sampDate": "2004-01-12T00:00:00",
        "sampYear": 2004,
        "sampMonth": 1,
        "sampDay": 12,
        "sampWeek": 2,
        "url": "https://pathfinder.arcc.uwyo.edu/devise/DAYMET_DerivedMetrics/DAYMET_Maxprcp_Weekly/DAYMET_Maxprcp_200402.tif",
        "resolution": "1 km",
        "source": "DEVISER DAYMET",
        "crs": "epsg:5072"
    },
    {
        "filename": "DAYMET_Maxprcp_200403.tif",
        "temporal": "Weekly",
        "metric": "Maxprcp",
        "sampDate": "2004-01-19T00:00:00",
        "sampYear": 2004,
        "sampMonth": 1,
        "sampDay": 19,
        "sampWeek": 3,
        "url": "https://pathfinder.arcc.uwyo.edu/devise/DAYMET_DerivedMetrics/DAYMET_Maxprcp_Weekly/DAYMET_Maxprcp_200403.tif",
        "resolution": "1 km",
        "source": "DEVISER DAYMET",
        "crs": "epsg:5072"
    },
    {
        "filename": "DAYMET_Maxprcp_200404.tif",
        "temporal": "Weekly",
        "metric": "Maxprcp",
        "sampDate": "2004-01-26T00:00:00",
        "sampYear": 2004,
        "sampMonth": 1,
        "sampDay": 26,
        "sampWeek": 4,
        "url": "https://pathfinder.arcc.uwyo.edu/devise/DAYMET_DerivedMetrics/DAYMET_Maxprcp_Weekly/DAYMET_Maxprcp_200404.tif",
        "resolution": "1 km",
        "source": "DEVISER DAYMET",
        "crs": "epsg:5072"
    }
]

R Examples

The following is a collection of R examples to show how to utilize the DEVISE API to obtain data independent of the DEVISE app

Extract Data From Points:

    1. Create your point first if you do not already have it
      require(terra)
      require(sf)
      require(httr)
      require(jsonlite)
      require(tidyverse)
      
      points <- data.frame(id = c(1, 2), x = c(-108.36312, -109.36312),  y = c(45.54731, 45.54731)) %>%
        sf::st_as_sf(coords = c("x", "y"), crs = 4326)
      
    2. We also need to obtain the list of all available metrics. Since we are working with annual data, we'll get the annual metric list
      myDaymetMetrics<- httr::POST(
        "https://devise.uwyo.edu/umbraco/api/daymetapi/GetDerivedAnnualMetricsList",
        content_type_json()
      ) %>%
        content()
      
      myDaymetMetrics <- do.call(rbind.data.frame, myDaymetMetrics)
      
    3. Now that we have a list of available metrics for the DAYMET annual dataset, let's pick one we're interested in. For this example we'll use the 'Maxprcp' metric which happens to be the first metric in our `myDaymetMetrics` list. We'll also need to pick dates. Here we will use the years 2005 - 2008
      dat<- httr::POST(
        "https://devise.uwyo.edu/umbraco/api/Daymetapi/GetDerivedAnnualData",
        httr::content_type_json(),
        body = jsonlite::toJSON(
          list(StartDate = jsonlite::unbox("2005-01-01"),
               EndDate = jsonlite::unbox("2008-01-01"),
               Metrics = myDaymetMetrics$metric[1]),
          auto_unbox = FALSE
        )
      ) %>%
        content()
      
      dat <- do.call(rbind.data.frame, dat)
      
    4. I've obtained a list of files representing 'Maxprcp' data annually for the years 2005 - 2008. We want to download these files so we can extract the data. First we want to pick a directory to save the files to.
      outDir <- "D:/examplePath"
      
      Then we want to loop through our list of files and download each one to the desired destination
      # loop through each file and download
      for(j in 1:nrow(dat)){
        try(utils::download.file(url = dat$url[j], destfile = paste0(outDir, "/", dat$filename[j]), quiet = TRUE, mode = "wb"), silent = TRUE)
      }
      
    5. Now that we've got all of our files downloaded, we can stack them into a single raster.
      # Get the newly downloaded files
      rfiles<- dir(outDir, pattern = ".tif$", full.names = TRUE)
      
      # Stack the rasters into one
      rs<- terra::rast(rfiles)
      
      # Change the names of the layers to something more meaningful
      names(rs) <- str_split(dat$filename, "\\.", simplify = TRUE)[,1]
      
    6. Before extracting the data from our raster, we have to ensure our points are in the correct format
      pts<- vect(as(points %>% st_transform(crs = 5072), "Spatial"))
      
    7. Now that our raster and points are in the correct format we can extract our data.
      ## Extract some sort of data here
      myMaxPrcpData<- terra::extract(rs, pts, ID = FALSE)
      
    8. We have the data corresponding to our points. You can see it in R using view or we manipulate into a format that is easier to read and understand.
      # Use this to view the data as is
      View(myMaxPrcpData)
      
      
      # Use this to manipulate data into an easier to read format and plot the trends    
      dfPts<- cbind(points, myMaxPrcpData) %>% 
        st_drop_geometry() %>% 
        pivot_longer(cols = 2:ncol(.), names_to = "Raster", values_to = "Value") %>% 
        separate(Raster, into = c("Source", "Parameter", "SampYear"), sep = "_")
      # plot data
      dfPts %>% 
        ggplot(aes(x = SampYear, y = Value, group = as.factor(id), color = as.factor(id))) +
        geom_line()