Plot API
Table of Contents
- GetAgencyList
- GetForm
- GetStateList
- GetAllMetricMaxDate
- GetAgencyGeometries
- GetPlot
- GetYearList
- GetManagementSources
- R Examples
GET GetAgencyList
This endpoint retrieves a list of all available agencies to populate the agency dropdown.
URL:
https://devise.uwyo.edu/Umbraco/api/AgencyMetricsApi/GetAgencyList
Parameters:
This endpoint does not require any parameters
Response:
[
{
"text": "Fish & Wildlife Service",
"value": "Fish & Wildlife Service",
"tooltip": "Select Agency"
},
{
"text": "National Park Service",
"value": "National Park Service",
"tooltip": "Select Agency"
},
{
"text": "Wyoming Game & Fish",
"value": "Wyoming Game & Fish",
"tooltip": "Select Agency"
}
]
GET GetForm
This endpoint retrieves the model used in creating all of the dropdown options in the app.
URL:
https://devise.uwyo.edu/umbraco/api/AgencyUnitUiApi/GetForm
https://devise.uwyo.edu/umbraco/api/AppUiApi/GetForm
Parameters:
This endpoint does not require any parameters
Response:
{
"states": [
{
"disabled": false,
"group": null,
"selected": false,
"text": "Colorado",
"value": "Colorado"
},
{
"disabled": false,
"group": null,
"selected": false,
"text": "Idaho",
"value": "Idaho"
},
{
"disabled": false,
"group": null,
"selected": true,
"text": "Wyoming",
"value": "Wyoming"
}
],
"agencies": null,
"selectedAgency": null,
"selectedState": null,
"layers": [
{
"disabled": false,
"group": null,
"selected": true,
"text": "Herd Units",
"value": "Herd Units"
},
...
GET GetStateList
This endpoint retrieves a list of all available states to populate the state dropdown for game units.
URL:
https://devise.uwyo.edu/Umbraco/api/GameUnitMetricsApi/GetStatesList
Parameters:
This endpoint does not require any parameters
Response:
[
{
"text": "Colorado",
"value": "Colorado",
"tooltip": "Select State"
},
{
"text": "Idaho",
"value": "Idaho",
"tooltip": "Select State"
},
{
"text": "Wyoming",
"value": "Wyoming",
"tooltip": "Select State"
}
]
GET GetAllMetricMaxDate
This endpoint retrieves a list of ALL available metrics across ALL datasets.
URL:
https://devise.uwyo.edu/Umbraco/api/AgencyMetricsApi/GetAllMetricMaxDate
https://devise.uwyo.edu/Umbraco/api/GameUnitMetricsApi/GetAllMetricMaxDate
Parameters:
This endpoint does not require any parameters
Response:
[
{
"dataset": "DAYMET",
"metric": "Sumprcp",
"temporal": "Annual",
"maxDate": "2022-01-01T00:00:00",
"description": null
},
{
"dataset": "DAYMET",
"metric": "Maxtmax",
"temporal": "Weekly",
"maxDate": "2022-12-26T00:00:00",
"description": null
},
{
"dataset": "DAYMET",
"metric": "Maxswe",
"temporal": "Weekly",
"maxDate": "2022-12-26T00:00:00",
"description": null
},
{
"dataset": "EROS",
"metric": "DUR",
"temporal": "Annual",
"maxDate": "2021-01-01T00:00:00",
"description": null
},....
GET GetAgencyGeometries
This endpoint retrieves a list of geometries for all agency units.
URL:
https://devise.uwyo.edu/Umbraco/api/AgencyMetricsApi/GetAgencyGeometries
Parameters:
This endpoint does not require any parameters
Response:
[
{
"ogrFid": 1,
"ogrGeometry": "POLYGON ((-12535896.780709136 4369759.9634724259, -12535879.471454309 4369760.7515004044, -12535878.979863903 4369760.7739195665, -12535830.455947364 4369769.51618859, -12535814.375021562 4369771.3524625273, -12535813.836053211 4369771.414006752, -12535789.755808095 4369774.1634686971, -12535747.542865615 4369766.9459203621, -12535678.809417862 4369746.9622939406, -12535661.328998819 4369742.5382509492, -12535595.58892631 4369725.9002422672, -12535575.143257054 4369716.9772203909, -12535551.863465633 4369706.8169989865, -12535517.244833471 4369683.0049609113, -12535510.614210794 4369678.4443456428,
... )),
"agency": "National Park Service",
"layertype": "Federal Boundaries",
"unitId": "GCNP",
"name": "Grand Canyon National Park",
"shapearea": 4619777584.50033,
"shapelength": 1436101.12037727
},
...
POST GetPlot
This endpoint retrieves a list of aggregated points based on the model that was passed in.
URL:
https://devise.uwyo.edu/Umbraco/api/AgencyUnitUiApi/GetPlot
Parameters:
- selectedAgency (string): Agency used in aggregation.
- selectedLayer (string): Layer used in aggregation.
- selectedUnits (string): Agency units representing the extent used in aggregation.
- selectedMetric (string): Metric used in aggregation.
- selectedMetric2 (string): When comparing metrics both, are used for aggregation.
- selectedMetricGroup (string): The metric group used in aggregation.
- selectedMetricGroup2 (string): When comparing metrics, both are used for aggregation.
- selectedDataSet (string): The dataset used in aggregation.
- selectedDataSet2 (string): When comparing metrics, both are used for aggregation.
- selectedTemporal (string): The temporal aggregation used.
- selectedMonths (string array): Months aggregated over.
- selectedYears (string array): Years aggregated over.
- groupByYear (logical): A comma separated array of PRISM metrics.
- convertUnits (logical): A comma separated array of PRISM metrics.
{
"selectedAgency": "Wyoming Game & Fish",
"selectedLayer": "WY Game Warden Districts",
"selectedUnits": [
"WY_GWD_3"
],
"selectedMetric": "Maxprcp",
"selectedMetric2": "",
"selectedMetricGroup": "Precipitation",
"selectedMetricGroup2": "Precipitation",
"selectedDataSet": "DAYMET",
"selectedDataSet2": "",
"selectedTemporal": "Annual",
"selectedMonths": [],
"selectedYears": [],
"groupByYear": false,
"convertUnits": false
}
Response:
{
"results": [
[
{
"agencyUnit": null,
"agencyName": null,
"unit": "WY_GWD_3",
"name": "East Cheyenne",
"dataset": "DAYMET",
"metric": "Maxprcp",
"metricGroup": "Precipitation",
"temporal": "Annual",
"sampDate": "1980-01-01T00:00:00",
"sampYear": 1980,
"sampMonth": 1,
"sampDay": 1,
"mean": 8.8173,
"median": 8.8367,
"sd": 0.731,
"ci95": 0.0215,
"q25": 7.2452,
"q975": 10.063,
"thirtyYearAvg": 10.9469
},
{
"agencyUnit": null,
"agencyName": null,
"unit": "WY_GWD_3",
"name": "East Cheyenne",
"dataset": "DAYMET",
"metric": "Maxprcp",
"metricGroup": "Precipitation",
"temporal": "Annual",
"sampDate": "1981-01-01T00:00:00",
"sampYear": 1981,
"sampMonth": 1,
"sampDay": 1,
"mean": 11.5094,
"median": 11.269,
"sd": 0.9652,
"ci95": 0.0284,
"q25": 10.1228,
"q975": 14.2042,
"thirtyYearAvg": 10.9469
}
....
POST GetYearList
This endpoint retrieves a list of all the available years for the provided dataset and metric.
URL:
https://devise.uwyo.edu/Umbraco/api/AgencyUnitUiApi/GetYearList
Parameters:
- selectedMetric (string): Aggregated metric of interest
- selectedDataSet (string): Dataset of interest.
{
"selectedMetric": "Maxprcp",
"selectedDataSet": "DAYMET"
}
Response:
{
"agencies": null,
"selectedAgency": null,
"layers": null,
"selectedLayer": null,
"units": null,
"selectedUnits": null,
"datasets": null,
"selectedDataset": "DAYMET",
"datasets2": null,
"selectedDataset2": null,
"metrics": null,
"selectedMetric": "Maxprcp",
"metrics2": null,
"selectedMetric2": null,
"metricGroups": null,
"selectedMetricGroup": null,
"metricGroups2": null,
"selectedMetricGroup2": null,
"temporal": null,
"selectedTemporal": null,
"selectedMonths": null,
"selectedYears": null,
"groupByYear": false,
"years": [
{
"disabled": false,
"group": null,
"selected": false,
"text": "1980",
"value": "1980"
},
...
],
"convertUnits": false
}
POST GetManagementSources
This endpoint retrieves a list of all the management sources used given a state name, species, and layer type.
URL:
https://devise.uwyo.edu/Umbraco/api/GameUnitMetricsApi/GetManagementSources
Parameters:
- States (string): A string representing the currently selected state of the plot.
- Species (string): A string representing the currently selected species of the plot.
- Layers (string): A string representing the current layer type of the plot
{
"States": "Wyoming",
"Species": "Bighorn Sheep",
"Layers": "Herd Units"
}
Response:
[
{
"species": "Bighorn Sheep",
"layerType": "Herd Units",
"stateName": "Wyoming",
"sourceGeoJson": "https://opendata.arcgis.com/datasets/e88689c4b2b84631add5c3b70416f4ca_0.geojson",
"sourceGeoService": "https://services6.arcgis.com/cWzdqIyxbijuhPLw/arcgis/rest/services/BighornSheepHerdUnits/FeatureServer/0/query?outFields=*&where=1%3D1"
},
{
"species": "Bighorn Sheep",
"layerType": "Hunt Areas",
"stateName": "Wyoming",
"sourceGeoJson": "https://opendata.arcgis.com/datasets/3912346a5aa94f558f49d4882581e798_0.geojson",
"sourceGeoService": "https://services6.arcgis.com/cWzdqIyxbijuhPLw/arcgis/rest/services/BighornSheepHuntAreas/FeatureServer/0/query?outFields=*&where=1%3D1"
}
]
R Examples
The following is a collection of R examples to show how to utilize the Plot API to obtain data independent of the DEVISE app
Get Points on Plot:
- First, we need to obtain a list of some of the possible options we have for our aggregation.
require(terra) require(sf) require(httr) require(jsonlite) require(tidyverse) myGmuFormData<- httr::GET( "https://devise.uwyo.edu/umbraco/api/AppUiApi/GetForm", content_type_json() ) %>% content()
- Next, we extract the parameters we're interested in.
myStates <- as.data.frame(do.call(rbind, myGmuFormData$states)) myLayers <- as.data.frame(do.call(rbind, myGmuFormData$layers)) mySpecies <- as.data.frame(do.call(rbind, myGmuFormData$species)) myUnits <- as.data.frame(do.call(rbind, myGmuFormData$units)) myMetrics <- as.data.frame(do.call(rbind, myGmuFormData$metrics))
- Now that we have some options we can call our 'GetPlot' method to obtain the aggregated data for your selected options.
dat<- httr::POST( "https://devise.uwyo.edu/umbraco/api/AppUiApi/GetPlot", httr::content_type_json(), body = jsonlite::toJSON( list( selectedState = unlist(myStates$value[3]), selectedLayer = unlist(myLayers$value[1]), selectedSpecies = unlist(mySpecies$value[1]), selectedUnits = c(myUnits$value[9]), selectedMetric = unlist(myMetrics$value[1]) , selectedMetricGroup = "Precipitation", selectedDataSet = "DAYMET", selectedTemporal = "Annual", selectedMonths = character(0), # Empty character vector for an empty array selectedYears = numeric(0), # Empty numeric vector for an empty array groupByYear = FALSE, convertUnits = FALSE ), auto_unbox = TRUE ) ) %>% content() - Now that we have our data, let's manipulate it into an easier to read format.
resultList <- dat$results[[1]] result_df <- as.data.frame(do.call(rbind, resultList))