PRISM API

Table of Contents

GET GetMetricsList

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

URL:

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

Parameters:

This endpoint does not require any parameters

Response:

[
    {
        "metric": "ppt",
    },
    {
        "metric": "tdmean",
    },
    {
        "metric": "tmax",
    },
    {
        "metric": "tmean",
    },
    {
        "metric": "tmin",
    },
    {
        "metric": "vpdmax",
    },
    {
        "metric": "vpdmin",
    }
]

GET GetDerivedAnnualMetricsList

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

URL:

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

Parameters:

This endpoint does not require any parameters

Response:

[
    {
        "metric": "Maxppt",
        "temporal": "Annual",
        "maxDate": "2022-01-01T00:00:00"
    },
    {
        "metric": "Maxtdmean",
        "temporal": "Annual",
        "maxDate": "2022-01-01T00:00:00"
    },
    {
        "metric": "Maxtmax",
        "temporal": "Annual",
        "maxDate": "2022-01-01T00:00:00"
    },
    {
        "metric": "Maxtmean",
        "temporal": "Annual",
        "maxDate": "2022-01-01T00:00:00"
    },
    {
        "metric": "Maxtmin",
        "temporal": "Annual",
        "maxDate": "2022-01-01T00:00:00"
    },
    {
        "metric": "Maxvpdmax",
        "temporal": "Annual",
        "maxDate": "2022-01-01T00:00:00"
    },
    {
        "metric": "Maxvpdmin",
        "temporal": "Annual",
        "maxDate": "2022-01-01T00:00:00"
    },
    {
        "metric": "Meanppt",
        "temporal": "Annual",
        "maxDate": "2022-01-01T00:00:00"
    },
    {
        "metric": "Meantdmean",
        "temporal": "Annual",
        "maxDate": "2022-01-01T00:00:00"
    },
    {
        "metric": "Meantmax",
        "temporal": "Annual",
        "maxDate": "2022-01-01T00:00:00"
    },
    {
        "metric": "Meantmean",
        "temporal": "Annual",
        "maxDate": "2022-01-01T00:00:00"
    },
    {
        "metric": "Meantmin",
        "temporal": "Annual",
        "maxDate": "2022-01-01T00:00:00"
    },
    {
        "metric": "Meanvpdmax",
        "temporal": "Annual",
        "maxDate": "2022-01-01T00:00:00"
    },
    {
        "metric": "Meanvpdmin",
        "temporal": "Annual",
        "maxDate": "2022-01-01T00:00:00"
    },
    {
        "metric": "Medianppt",
        "temporal": "Annual",
        "maxDate": "2022-01-01T00:00:00"
    },
    {
        "metric": "Mediantdmean",
        "temporal": "Annual",
        "maxDate": "2022-01-01T00:00:00"
    },
    {
        "metric": "Mediantmax",
        "temporal": "Annual",
        "maxDate": "2022-01-01T00:00:00"
    },
    {
        "metric": "Mediantmean",
        "temporal": "Annual",
        "maxDate": "2022-01-01T00:00:00"
    },
    {
        "metric": "Mediantmin",
        "temporal": "Annual",
        "maxDate": "2022-01-01T00:00:00"
    },
    {
        "metric": "Medianvpdmax",
        "temporal": "Annual",
        "maxDate": "2022-01-01T00:00:00"
    },
    {
        "metric": "Medianvpdmin",
        "temporal": "Annual",
        "maxDate": "2022-01-01T00:00:00"
    },
    {
        "metric": "Sumppt",
        "temporal": "Annual",
        "maxDate": "2022-01-01T00:00:00"
    }
]

GET GetDerivedMonthlyMetricsList

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

URL:

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

Parameters:

This endpoint does not require any parameters

Response:

[
    {
        "metric": "Maxppt",
        "temporal": "Monthly",
        "maxDate": "2023-06-01T00:00:00"
    },
    {
        "metric": "Maxtdmean",
        "temporal": "Monthly",
        "maxDate": "2023-06-01T00:00:00"
    },
    {
        "metric": "Maxtmax",
        "temporal": "Monthly",
        "maxDate": "2023-06-01T00:00:00"
    },
    {
        "metric": "Maxtmean",
        "temporal": "Monthly",
        "maxDate": "2023-06-01T00:00:00"
    },
    {
        "metric": "Maxtmin",
        "temporal": "Monthly",
        "maxDate": "2023-06-01T00:00:00"
    },
    {
        "metric": "Maxvpdmax",
        "temporal": "Monthly",
        "maxDate": "2023-06-01T00:00:00"
    },
    {
        "metric": "Maxvpdmin",
        "temporal": "Monthly",
        "maxDate": "2023-06-01T00:00:00"
    },
    {
        "metric": "Meanppt",
        "temporal": "Monthly",
        "maxDate": "2023-06-01T00:00:00"
    },
    {
        "metric": "Meantdmean",
        "temporal": "Monthly",
        "maxDate": "2023-06-01T00:00:00"
    },
    {
        "metric": "Meantmax",
        "temporal": "Monthly",
        "maxDate": "2023-06-01T00:00:00"
    },
    {
        "metric": "Meantmean",
        "temporal": "Monthly",
        "maxDate": "2023-06-01T00:00:00"
    },
    {
        "metric": "Meantmin",
        "temporal": "Monthly",
        "maxDate": "2023-06-01T00:00:00"
    },
    {
        "metric": "Meanvpdmax",
        "temporal": "Monthly",
        "maxDate": "2023-06-01T00:00:00"
    },
    {
        "metric": "Meanvpdmin",
        "temporal": "Monthly",
        "maxDate": "2023-06-01T00:00:00"
    },
    {
        "metric": "Medianppt",
        "temporal": "Monthly",
        "maxDate": "2023-06-01T00:00:00"
    },
    {
        "metric": "Mediantdmean",
        "temporal": "Monthly",
        "maxDate": "2023-06-01T00:00:00"
    },
    {
        "metric": "Mediantmax",
        "temporal": "Monthly",
        "maxDate": "2023-06-01T00:00:00"
    },
    {
        "metric": "Mediantmean",
        "temporal": "Monthly",
        "maxDate": "2023-06-01T00:00:00"
    },
    {
        "metric": "Mediantmin",
        "temporal": "Monthly",
        "maxDate": "2023-06-01T00:00:00"
    },
    {
        "metric": "Medianvpdmax",
        "temporal": "Monthly",
        "maxDate": "2023-06-01T00:00:00"
    },
    {
        "metric": "Medianvpdmin",
        "temporal": "Monthly",
        "maxDate": "2023-06-01T00:00:00"
    },
    {
        "metric": "Sumppt",
        "temporal": "Monthly",
        "maxDate": "2023-06-01T00:00:00"
    }
]

GET GetDerivedWeeklyMetricsList

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

URL:

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

Parameters:

This endpoint does not require any parameters

Response:

[
    {
        "metric": "Maxppt",
        "temporal": "Weekly",
        "maxDate": "2023-06-26T00:00:00"
    },
    {
        "metric": "Maxtdmean",
        "temporal": "Weekly",
        "maxDate": "2023-06-26T00:00:00"
    },
    {
        "metric": "Maxtmax",
        "temporal": "Weekly",
        "maxDate": "2023-06-26T00:00:00"
    },
    {
        "metric": "Maxtmean",
        "temporal": "Weekly",
        "maxDate": "2023-06-26T00:00:00"
    },
    {
        "metric": "Maxtmin",
        "temporal": "Weekly",
        "maxDate": "2023-06-26T00:00:00"
    },
    {
        "metric": "Maxvpdmax",
        "temporal": "Weekly",
        "maxDate": "2023-06-26T00:00:00"
    },
    {
        "metric": "Maxvpdmin",
        "temporal": "Weekly",
        "maxDate": "2023-06-26T00:00:00"
    },
    {
        "metric": "Meanppt",
        "temporal": "Weekly",
        "maxDate": "2023-06-26T00:00:00"
    },
    {
        "metric": "Meantdmean",
        "temporal": "Weekly",
        "maxDate": "2023-06-26T00:00:00"
    },
    {
        "metric": "Meantmax",
        "temporal": "Weekly",
        "maxDate": "2023-06-26T00:00:00"
    },
    {
        "metric": "Meantmean",
        "temporal": "Weekly",
        "maxDate": "2023-06-26T00:00:00"
    },
    {
        "metric": "Meantmin",
        "temporal": "Weekly",
        "maxDate": "2023-06-26T00:00:00"
    },
    {
        "metric": "Meanvpdmax",
        "temporal": "Weekly",
        "maxDate": "2023-06-26T00:00:00"
    },
    {
        "metric": "Meanvpdmin",
        "temporal": "Weekly",
        "maxDate": "2023-06-26T00:00:00"
    },
    {
        "metric": "Medianppt",
        "temporal": "Weekly",
        "maxDate": "2023-06-26T00:00:00"
    },
    {
        "metric": "Mediantdmean",
        "temporal": "Weekly",
        "maxDate": "2023-06-26T00:00:00"
    },
    {
        "metric": "Mediantmax",
        "temporal": "Weekly",
        "maxDate": "2023-06-26T00:00:00"
    },
    {
        "metric": "Mediantmean",
        "temporal": "Weekly",
        "maxDate": "2023-06-26T00:00:00"
    },
    {
        "metric": "Mediantmin",
        "temporal": "Weekly",
        "maxDate": "2023-06-26T00:00:00"
    },
    {
        "metric": "Medianvpdmax",
        "temporal": "Weekly",
        "maxDate": "2023-06-26T00:00:00"
    },
    {
        "metric": "Medianvpdmin",
        "temporal": "Weekly",
        "maxDate": "2023-06-26T00:00:00"
    },
    {
        "metric": "Sumppt",
        "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 PRISM database.

URL:

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

Parameters:

This endpoint does not require any parameters

Response:

[
    {
        "dataset": null,
        "metric": "ppt",
        "temporal": null,
        "maxDate": "2023-07-04T00:00:00"
    },
    {
        "dataset": null,
        "metric": "tdmean",
        "temporal": null,
        "maxDate": "2023-07-04T00:00:00"
    },
    {
        "dataset": null,
        "metric": "tmax",
        "temporal": null,
        "maxDate": "2023-07-04T00:00:00"
    },
    {
        "dataset": null,
        "metric": "tmean",
        "temporal": null,
        "maxDate": "2023-07-04T00:00:00"
    },
    {
        "dataset": null,
        "metric": "tmin",
        "temporal": null,
        "maxDate": "2023-07-04T00:00:00"
    },
    {
        "dataset": null,
        "metric": "vpdmax",
        "temporal": null,
        "maxDate": "2023-07-04T00:00:00"
    },
    {
        "dataset": null,
        "metric": "vpdmin",
        "temporal": null,
        "maxDate": "2023-07-04T00:00:00"
    }
]

POST GetData

This endpoint retrieves filtered PRISM data to facilitate downloading of files

URL:

https://devise.uwyo.edu/Umbraco/api/PrismApi/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 PRISM metrics.
{
  "StartDate": "2010-01-01",
  "EndDate": "2010-01-02",
  "Metrics": ["tmax"]
}

Response:

[
    {
        "filename": "PRISM_tmax_stable_4kmD2_20100101.tif",
        "metric": "tmax",
        "version": "stable",
        "sampDate": "2010-01-01T00:00:00",
        "sampYear": 2010,
        "sampMonth": 1,
        "sampDay": 1,
        "doy": 1,
        "url": "https://pathfinder.arcc.uwyo.edu/devise/PRISM/PRISM_tmax/PRISM_tmax_stable_4kmD2_20100101.tif",
        "resolution": "4 km",
        "source": "ftp://prism.nacse.org/daily/",
        "crs": "epsg:5072"
    },
    {
        "filename": "PRISM_tmax_stable_4kmD2_20100102.tif",
        "metric": "tmax",
        "version": "stable",
        "sampDate": "2010-01-02T00:00:00",
        "sampYear": 2010,
        "sampMonth": 1,
        "sampDay": 2,
        "doy": 2,
        "url": "https://pathfinder.arcc.uwyo.edu/devise/PRISM/PRISM_tmax/PRISM_tmax_stable_4kmD2_20100102.tif",
        "resolution": "4 km",
        "source": "ftp://prism.nacse.org/daily/",
        "crs": "epsg:5072"
    }
]

POST GetDerivedAnnualData

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

URL:

https://devise.uwyo.edu/Umbraco/api/PrismApi/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 PRISM metrics.
{
    "StartDate": "1981-01-01",
    "EndDate": "1982-01-01",
    "Years" : null,
    "Months": null,
    "Metrics": ["Maxvpdmin"]
}

Response:

[
    {
        "filename": "PRISM_Maxvpdmin_1982.tif",
        "temporal": "Annual",
        "metric": "Maxvpdmin",
        "sampDate": "1982-01-01T00:00:00",
        "sampYear": 1982,
        "sampMonth": 1,
        "sampDay": 1,
        "sampWeek": 1,
        "url": "https://pathfinder.arcc.uwyo.edu/devise/PRISM_DerivedMetrics/PRISM_Maxvpdmin_Annual/PRISM_Maxvpdmin_1982.tif",
        "resolution": "4 km",
        "source": "DEVISER PRISM",
        "crs": "epsg:5072"
    }
]

POST GetDerivedMonthlyData

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

URL:

https://devise.uwyo.edu/Umbraco/api/PrismApi/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 PRISM metrics.
{
    "StartDate": null,
    "EndDate": null,
    "Years" : [2003, 2004],
    "Months": [1, 2],
    "Metrics": ["Maxppt"]
}

Response:

[
    {
        "filename": "PRISM_Maxppt_200301.tif",
        "temporal": "Monthly",
        "metric": "Maxppt",
        "sampDate": "2003-01-01T00:00:00",
        "sampYear": 2003,
        "sampMonth": 1,
        "sampDay": 1,
        "sampWeek": 1,
        "url": "https://pathfinder.arcc.uwyo.edu/devise/PRISM_DerivedMetrics/PRISM_Maxppt_Monthly/PRISM_Maxppt_200301.tif",
        "resolution": "4 km",
        "source": "DEVISER PRISM",
        "crs": "epsg:5072"
    },
    {
        "filename": "PRISM_Maxppt_200302.tif",
        "temporal": "Monthly",
        "metric": "Maxppt",
        "sampDate": "2003-02-01T00:00:00",
        "sampYear": 2003,
        "sampMonth": 2,
        "sampDay": 1,
        "sampWeek": 5,
        "url": "https://pathfinder.arcc.uwyo.edu/devise/PRISM_DerivedMetrics/PRISM_Maxppt_Monthly/PRISM_Maxppt_200302.tif",
        "resolution": "4 km",
        "source": "DEVISER PRISM",
        "crs": "epsg:5072"
    },
    {
        "filename": "PRISM_Maxppt_200401.tif",
        "temporal": "Monthly",
        "metric": "Maxppt",
        "sampDate": "2004-01-01T00:00:00",
        "sampYear": 2004,
        "sampMonth": 1,
        "sampDay": 1,
        "sampWeek": 1,
        "url": "https://pathfinder.arcc.uwyo.edu/devise/PRISM_DerivedMetrics/PRISM_Maxppt_Monthly/PRISM_Maxppt_200401.tif",
        "resolution": "4 km",
        "source": "DEVISER PRISM",
        "crs": "epsg:5072"
    },
    {
        "filename": "PRISM_Maxppt_200402.tif",
        "temporal": "Monthly",
        "metric": "Maxppt",
        "sampDate": "2004-02-01T00:00:00",
        "sampYear": 2004,
        "sampMonth": 2,
        "sampDay": 1,
        "sampWeek": 5,
        "url": "https://pathfinder.arcc.uwyo.edu/devise/PRISM_DerivedMetrics/PRISM_Maxppt_Monthly/PRISM_Maxppt_200402.tif",
        "resolution": "4 km",
        "source": "DEVISER PRISM",
        "crs": "epsg:5072"
    }
]

POST GetDerivedWeeklyData

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

URL:

https://devise.uwyo.edu/Umbraco/api/PrismApi/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 PRISM metrics.
{
    "StartDate": null,
    "EndDate": null,
    "Years" : [2003],
    "Months": [2],
    "Metrics": ["Mediantmax"]
}

Response:

[
    {
        "filename": "PRISM_Mediantmax_200305.tif",
        "temporal": "Weekly",
        "metric": "Mediantmax",
        "sampDate": "2003-02-03T00:00:00",
        "sampYear": 2003,
        "sampMonth": 2,
        "sampDay": 3,
        "sampWeek": 5,
        "url": "https://pathfinder.arcc.uwyo.edu/devise/PRISM_DerivedMetrics/PRISM_Mediantmax_Weekly/PRISM_Mediantmax_200305.tif",
        "resolution": "4 km",
        "source": "DEVISER PRISM",
        "crs": "epsg:5072"
    },
    {
        "filename": "PRISM_Mediantmax_200306.tif",
        "temporal": "Weekly",
        "metric": "Mediantmax",
        "sampDate": "2003-02-10T00:00:00",
        "sampYear": 2003,
        "sampMonth": 2,
        "sampDay": 10,
        "sampWeek": 6,
        "url": "https://pathfinder.arcc.uwyo.edu/devise/PRISM_DerivedMetrics/PRISM_Mediantmax_Weekly/PRISM_Mediantmax_200306.tif",
        "resolution": "4 km",
        "source": "DEVISER PRISM",
        "crs": "epsg:5072"
    },
    {
        "filename": "PRISM_Mediantmax_200307.tif",
        "temporal": "Weekly",
        "metric": "Mediantmax",
        "sampDate": "2003-02-17T00:00:00",
        "sampYear": 2003,
        "sampMonth": 2,
        "sampDay": 17,
        "sampWeek": 7,
        "url": "https://pathfinder.arcc.uwyo.edu/devise/PRISM_DerivedMetrics/PRISM_Mediantmax_Weekly/PRISM_Mediantmax_200307.tif",
        "resolution": "4 km",
        "source": "DEVISER PRISM",
        "crs": "epsg:5072"
    },
    {
        "filename": "PRISM_Mediantmax_200308.tif",
        "temporal": "Weekly",
        "metric": "Mediantmax",
        "sampDate": "2003-02-24T00:00:00",
        "sampYear": 2003,
        "sampMonth": 2,
        "sampDay": 24,
        "sampWeek": 8,
        "url": "https://pathfinder.arcc.uwyo.edu/devise/PRISM_DerivedMetrics/PRISM_Mediantmax_Weekly/PRISM_Mediantmax_200308.tif",
        "resolution": "4 km",
        "source": "DEVISER PRISM",
        "crs": "epsg:5072"
    }
]

R Examples

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