SNODAS API

Table of Contents

GET GetMetricsList

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

URL:

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

Parameters:

This endpoint does not require any parameters

Response:

[
    {
        "metric": "SnowDepth"
    },
    {
        "metric": "SWE"
    }
]

GET GetDerivedAnnualMetricsList

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

URL:

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

Parameters:

This endpoint does not require any parameters

Response:

[
    {
        "metric": "MaxSnowDepth",
        "temporal": "Annual",
        "maxDate": "2022-01-01T00:00:00"
    },
    {
        "metric": "MaxSWE",
        "temporal": "Annual",
        "maxDate": "2022-01-01T00:00:00"
    },
    {
        "metric": "MeanSnowDepth",
        "temporal": "Annual",
        "maxDate": "2022-01-01T00:00:00"
    },
    {
        "metric": "MeanSWE",
        "temporal": "Annual",
        "maxDate": "2022-01-01T00:00:00"
    },
    {
        "metric": "MedianSnowDepth",
        "temporal": "Annual",
        "maxDate": "2022-01-01T00:00:00"
    },
    {
        "metric": "MedianSWE",
        "temporal": "Annual",
        "maxDate": "2022-01-01T00:00:00"
    }
]

GET GetDerivedMonthlyMetricsList

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

URL:

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

Parameters:

This endpoint does not require any parameters

Response:

[
    {
        "metric": "MaxSnowDepth",
        "temporal": "Monthly",
        "maxDate": "2023-06-01T00:00:00"
    },
    {
        "metric": "MaxSWE",
        "temporal": "Monthly",
        "maxDate": "2023-06-01T00:00:00"
    },
    {
        "metric": "MeanSnowDepth",
        "temporal": "Monthly",
        "maxDate": "2023-06-01T00:00:00"
    },
    {
        "metric": "MeanSWE",
        "temporal": "Monthly",
        "maxDate": "2023-06-01T00:00:00"
    },
    {
        "metric": "MedianSnowDepth",
        "temporal": "Monthly",
        "maxDate": "2023-06-01T00:00:00"
    },
    {
        "metric": "MedianSWE",
        "temporal": "Monthly",
        "maxDate": "2023-06-01T00:00:00"
    }
]

GET GetDerivedWeeklyMetricsList

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

URL:

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

Parameters:

This endpoint does not require any parameters

Response:

[
    {
        "metric": "MaxSnowDepth",
        "temporal": "Weekly",
        "maxDate": "2023-06-26T00:00:00"
    },
    {
        "metric": "MaxSWE",
        "temporal": "Weekly",
        "maxDate": "2023-06-26T00:00:00"
    },
    {
        "metric": "MeanSnowDepth",
        "temporal": "Weekly",
        "maxDate": "2023-06-26T00:00:00"
    },
    {
        "metric": "MeanSWE",
        "temporal": "Weekly",
        "maxDate": "2023-06-26T00:00:00"
    },
    {
        "metric": "MedianSnowDepth",
        "temporal": "Weekly",
        "maxDate": "2023-06-26T00:00:00"
    },
    {
        "metric": "MedianSWE",
        "temporal": "Weekly",
        "maxDate": "2023-06-26T00:00:00"
    }
]

GET GetAllMetricMaxDate

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

URL:

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

Parameters:

This endpoint does not require any parameters

Response:

[
    {
        "dataset": null,
        "metric": "SWE",
        "temporal": null,
        "maxDate": "2023-07-04T00:00:00"
    },
    {
        "dataset": null,
        "metric": "SnowDepth",
        "temporal": null,
        "maxDate": "2023-07-04T00:00:00"
    }
]

POST GetData

This endpoint retrieves filtered SNODAS data to facilitate downloading of files

URL:

https://devise.uwyo.edu/Umbraco/api/SnodasApi/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 SNODAS metrics.
{
    "StartDate":"2021-01-01",
    "EndDate":"2021-01-02",
    "Metrics": ["SWE", "SnowDepth"]
}

Response:

[
    {
        "filename": "SNODAS_20210101_SnowDepth.tif",
        "sampDate": "2021-01-01T00:00:00",
        "metric": "SnowDepth",
        "sampYear": 2021,
        "sampMonth": 1,
        "sampDay": 1,
        "doy": 1,
        "url": "https://pathfinder.arcc.uwyo.edu/devise/SNODAS/SNODAS_SnowDepth/SNODAS_20210101_SnowDepth.tif",
        "resolution": "1 km",
        "source": "ftp://sidads.colorado.edu/DATASETS/NOAA/G02158/masked/",
        "crs": "epsg:5072"
    },
    {
        "filename": "SNODAS_20210101_SWE.tif",
        "sampDate": "2021-01-01T00:00:00",
        "metric": "SWE",
        "sampYear": 2021,
        "sampMonth": 1,
        "sampDay": 1,
        "doy": 1,
        "url": "https://pathfinder.arcc.uwyo.edu/devise/SNODAS/SNODAS_SWE/SNODAS_20210101_SWE.tif",
        "resolution": "1 km",
        "source": "ftp://sidads.colorado.edu/DATASETS/NOAA/G02158/masked/",
        "crs": "epsg:5072"
    },
    {
        "filename": "SNODAS_20210102_SnowDepth.tif",
        "sampDate": "2021-01-02T00:00:00",
        "metric": "SnowDepth",
        "sampYear": 2021,
        "sampMonth": 1,
        "sampDay": 2,
        "doy": 2,
        "url": "https://pathfinder.arcc.uwyo.edu/devise/SNODAS/SNODAS_SnowDepth/SNODAS_20210102_SnowDepth.tif",
        "resolution": "1 km",
        "source": "ftp://sidads.colorado.edu/DATASETS/NOAA/G02158/masked/",
        "crs": "epsg:5072"
    },
    {
        "filename": "SNODAS_20210102_SWE.tif",
        "sampDate": "2021-01-02T00:00:00",
        "metric": "SWE",
        "sampYear": 2021,
        "sampMonth": 1,
        "sampDay": 2,
        "doy": 2,
        "url": "https://pathfinder.arcc.uwyo.edu/devise/SNODAS/SNODAS_SWE/SNODAS_20210102_SWE.tif",
        "resolution": "1 km",
        "source": "ftp://sidads.colorado.edu/DATASETS/NOAA/G02158/masked/",
        "crs": "epsg:5072"
    }
]

POST GetDerivedAnnualData

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

URL:

https://devise.uwyo.edu/Umbraco/api/SnodasApi/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 SNODAS metrics.
{
    "StartDate": null,
    "EndDate": null,
    "Years" : [2010],
    "Months": null,
    "Metrics": ["MaxSnowDepth", "MaxSWE"]
}

Response:

[
    {
        "filename": "SNODAS_MaxSnowDepth_2010.tif",
        "temporal": "Annual",
        "metric": "MaxSnowDepth",
        "sampDate": "2010-01-01T00:00:00",
        "sampYear": 2010,
        "sampMonth": 1,
        "sampDay": 1,
        "sampWeek": 1,
        "url": "https://pathfinder.arcc.uwyo.edu/devise/SNODAS_DerivedMetrics/SNODAS_MaxSnowDepth_Annual/SNODAS_MaxSnowDepth_2010.tif",
        "resolution": "1 km",
        "source": "DEVISER SNODAS",
        "crs": "epsg:5072"
    },
    {
        "filename": "SNODAS_MaxSWE_2010.tif",
        "temporal": "Annual",
        "metric": "MaxSWE",
        "sampDate": "2010-01-01T00:00:00",
        "sampYear": 2010,
        "sampMonth": 1,
        "sampDay": 1,
        "sampWeek": 1,
        "url": "https://pathfinder.arcc.uwyo.edu/devise/SNODAS_DerivedMetrics/SNODAS_MaxSWE_Annual/SNODAS_MaxSWE_2010.tif",
        "resolution": "1 km",
        "source": "DEVISER SNODAS",
        "crs": "epsg:5072"
    }
]

POST GetDerivedMonthlyData

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

URL:

https://devise.uwyo.edu/Umbraco/api/SnodasApi/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 SNODAS metrics.
{
    "StartDate": null,
    "EndDate": null,
    "Years" : [2010],
    "Months": [1,2],
    "Metrics": ["MaxSnowDepth", "MaxSWE"]
}

Response:

[
    {
        "filename": "SNODAS_MaxSnowDepth_201001.tif",
        "temporal": "Monthly",
        "metric": "MaxSnowDepth",
        "sampDate": "2010-01-01T00:00:00",
        "sampYear": 2010,
        "sampMonth": 1,
        "sampDay": 1,
        "sampWeek": 1,
        "url": "https://pathfinder.arcc.uwyo.edu/devise/SNODAS_DerivedMetrics/SNODAS_MaxSnowDepth_Monthly/SNODAS_MaxSnowDepth_201001.tif",
        "resolution": "1 km",
        "source": "DEVISER SNODAS",
        "crs": "epsg:5072"
    },
    {
        "filename": "SNODAS_MaxSnowDepth_201002.tif",
        "temporal": "Monthly",
        "metric": "MaxSnowDepth",
        "sampDate": "2010-02-01T00:00:00",
        "sampYear": 2010,
        "sampMonth": 2,
        "sampDay": 1,
        "sampWeek": 5,
        "url": "https://pathfinder.arcc.uwyo.edu/devise/SNODAS_DerivedMetrics/SNODAS_MaxSnowDepth_Monthly/SNODAS_MaxSnowDepth_201002.tif",
        "resolution": "1 km",
        "source": "DEVISER SNODAS",
        "crs": "epsg:5072"
    },
    {
        "filename": "SNODAS_MaxSWE_201001.tif",
        "temporal": "Monthly",
        "metric": "MaxSWE",
        "sampDate": "2010-01-01T00:00:00",
        "sampYear": 2010,
        "sampMonth": 1,
        "sampDay": 1,
        "sampWeek": 1,
        "url": "https://pathfinder.arcc.uwyo.edu/devise/SNODAS_DerivedMetrics/SNODAS_MaxSWE_Monthly/SNODAS_MaxSWE_201001.tif",
        "resolution": "1 km",
        "source": "DEVISER SNODAS",
        "crs": "epsg:5072"
    },
    {
        "filename": "SNODAS_MaxSWE_201002.tif",
        "temporal": "Monthly",
        "metric": "MaxSWE",
        "sampDate": "2010-02-01T00:00:00",
        "sampYear": 2010,
        "sampMonth": 2,
        "sampDay": 1,
        "sampWeek": 5,
        "url": "https://pathfinder.arcc.uwyo.edu/devise/SNODAS_DerivedMetrics/SNODAS_MaxSWE_Monthly/SNODAS_MaxSWE_201002.tif",
        "resolution": "1 km",
        "source": "DEVISER SNODAS",
        "crs": "epsg:5072"
    }
]

POST GetDerivedWeeklyData

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

URL:

https://devise.uwyo.edu/Umbraco/api/SnodasApi/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 SNODAS metrics.
{
    "StartDate": null,
    "EndDate": null,
    "Years" : [2005],
    "Months": [1],
    "Metrics": ["MaxSnowDepth"]
}

Response:

[
    {
        "filename": "SNODAS_MaxSnowDepth_200501.tif",
        "temporal": "Weekly",
        "metric": "MaxSnowDepth",
        "sampDate": "2005-01-03T00:00:00",
        "sampYear": 2005,
        "sampMonth": 1,
        "sampDay": 3,
        "sampWeek": 1,
        "url": "https://pathfinder.arcc.uwyo.edu/devise/SNODAS_DerivedMetrics/SNODAS_MaxSnowDepth_Weekly/SNODAS_MaxSnowDepth_200501.tif",
        "resolution": "1 km",
        "source": "DEVISER SNODAS",
        "crs": "epsg:5072"
    },
    {
        "filename": "SNODAS_MaxSnowDepth_200502.tif",
        "temporal": "Weekly",
        "metric": "MaxSnowDepth",
        "sampDate": "2005-01-10T00:00:00",
        "sampYear": 2005,
        "sampMonth": 1,
        "sampDay": 10,
        "sampWeek": 2,
        "url": "https://pathfinder.arcc.uwyo.edu/devise/SNODAS_DerivedMetrics/SNODAS_MaxSnowDepth_Weekly/SNODAS_MaxSnowDepth_200502.tif",
        "resolution": "1 km",
        "source": "DEVISER SNODAS",
        "crs": "epsg:5072"
    },
    {
        "filename": "SNODAS_MaxSnowDepth_200503.tif",
        "temporal": "Weekly",
        "metric": "MaxSnowDepth",
        "sampDate": "2005-01-17T00:00:00",
        "sampYear": 2005,
        "sampMonth": 1,
        "sampDay": 17,
        "sampWeek": 3,
        "url": "https://pathfinder.arcc.uwyo.edu/devise/SNODAS_DerivedMetrics/SNODAS_MaxSnowDepth_Weekly/SNODAS_MaxSnowDepth_200503.tif",
        "resolution": "1 km",
        "source": "DEVISER SNODAS",
        "crs": "epsg:5072"
    },
    {
        "filename": "SNODAS_MaxSnowDepth_200504.tif",
        "temporal": "Weekly",
        "metric": "MaxSnowDepth",
        "sampDate": "2005-01-24T00:00:00",
        "sampYear": 2005,
        "sampMonth": 1,
        "sampDay": 24,
        "sampWeek": 4,
        "url": "https://pathfinder.arcc.uwyo.edu/devise/SNODAS_DerivedMetrics/SNODAS_MaxSnowDepth_Weekly/SNODAS_MaxSnowDepth_200504.tif",
        "resolution": "1 km",
        "source": "DEVISER SNODAS",
        "crs": "epsg:5072"
    },
    {
        "filename": "SNODAS_MaxSnowDepth_200505.tif",
        "temporal": "Weekly",
        "metric": "MaxSnowDepth",
        "sampDate": "2005-01-31T00:00:00",
        "sampYear": 2005,
        "sampMonth": 1,
        "sampDay": 31,
        "sampWeek": 5,
        "url": "https://pathfinder.arcc.uwyo.edu/devise/SNODAS_DerivedMetrics/SNODAS_MaxSnowDepth_Weekly/SNODAS_MaxSnowDepth_200505.tif",
        "resolution": "1 km",
        "source": "DEVISER SNODAS",
        "crs": "epsg:5072"
    }
]

R Examples

The following is a collection of R examples to show how to utilize the SNODAS 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
      mySnodasMetrics<- httr::POST(
        "https://devise.uwyo.edu/umbraco/api/snodasapi/GetDerivedAnnualMetricsList",
        content_type_json()
      ) %>%
        content()
      
      mySnodasMetrics <- do.call(rbind.data.frame, mySnodasMetrics)
      
    3. Now that we have a list of available metrics for the SNODAS annual dataset, let's pick one we're interested in. For this example we'll use the 'MeanSWE' metric which happens to be the 4th metric in our `mySnodasMetrics` 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/Snodasapi/GetDerivedAnnualData",
        httr::content_type_json(),
        body = jsonlite::toJSON(
          list(StartDate = jsonlite::unbox("2005-01-01"),
               EndDate = jsonlite::unbox("2008-01-01"),
               Metrics = mySnodasMetrics$metric[4]),
          auto_unbox = FALSE
        )
      ) %>%
        content()
      
      dat <- do.call(rbind.data.frame, dat)
      
    4. I've obtained a list of files representing 'MeanSWE' 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
      myMeanSweData<- 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(myMeanSweData)
      
      
      # Use this to manipulate data into an easier to read format and plot the trends    
      dfPts<- cbind(points, myMeanSweData) %>% 
        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()