Access Token. Please get in touch with the WaDE Team at WaDE_WSWC@hotmail.com to get an API access token. The token protects the API from bots and attacks. The WaDE team is planning to support a personalized token for each user as part of the WesDAAT user management system. We apologize for the inconvenience.
Water rights are now accessible through the Western States Water Data Access and Analysis Tool (WestDAAT).
You can also use the WaDE API to access water rights data across the West in a consistent JavaScript Object Notation (JSON) structure.
Here is the API endpoint and its parameters
Click on the arrow next to the "response" block in the link below to see the API schema and an example response.
Example Python code for using the API
#!/usr/bin/env python
import pandas as pd
import numpy as np
import os
import json
from pandas.io.json import json_normalize
from urllib.request import urlopen
import gmaps
import gmaps.datasets
import plotly.express as px
# Access WaDE API to get the water allocations JSON
url = 'https://wade-api.azure-api.net/v1/SiteAllocationAmounts?State='
statesShort = ["CO", "UT", "WA", "OR", "CA", "OK", "ND", "AZ"]
df100_list = []
# extract target columns
subcolumns = ['WaterSourceUUID', 'Sites', 'AllocationAmount', 'AllocationMaximum',
'BeneficialUses']
for state in statesShort:
urlwithfilter = url+state
response = urlopen(urlwithfilter)
dataread = response.read().decode("utf-8")
data = json.loads(dataread)
df10 = json_normalize(data, 'Organizations')
df20 = pd.concat([pd.DataFrame(json_normalize(x)) for x in df10['WaterAllocations']],
ignore_index=True)
df30 = df20[subcolumns]
df100_list.append(df30)
df100 = pd.concat(df100_list, sort=True, ignore_index=True)
#df100.drop_duplicates(inplace=True)
print(len(df100.index))
df100.head(5)
# get a data frame that combines lat lon with allocation values
latloncolumns = ['WaterSourceUUID','Longitude', 'Latitude',
'AllocationAmount', 'AllocationMaximum', 'BeneficialUses']
df300 = pd.DataFrame(columns=latloncolumns)
jy = 0
for index, rows in df100.iterrows():
SitesL = rows.Sites
for latlon in SitesL:
#print(latlon)
df300.loc[jy,'WaterSourceUUID'] = rows.WaterSourceUUID
df300.loc[jy,'AllocationAmount'] = rows.AllocationAmount
df300.loc[jy,'AllocationMaximum'] = rows.AllocationMaximum
df300.loc[jy,'BeneficialUses'] = rows.BeneficialUses
df300.loc[jy,'Longitude'] = latlon['Longitude']
df300.loc[jy,'Latitude'] = latlon['Latitude']
jy += 1
print(len(df300.index))
df300.head(5)
# outdf100.WaterSourceUUID = df100['WaterSourceUUID']
print("Drop rows without lat lon values...")
df500 = df300.dropna(subset=['Longitude', 'Latitude'])
df500 = df500.reset_index(drop=True)
print(len(df500.index))
df500.head(5)
print("Drop duplicates if there are any...")
subCols = ['Longitude', 'Latitude']
df500.drop_duplicates(subset = subCols, inplace=True) #
df500 = df500.reset_index(drop=True)
print(len(df500.index))
df500.head(5)
# make sure the data are in the right data types
# plotly complained about allocation types being 'object'
print(df500.dtypes)
df500['AllocationAmount'] = pd.to_numeric(df500['AllocationAmount'], errors='coerce')
df500['AllocationMaximum'] = pd.to_numeric(df500['AllocationMaximum'], errors='coerce')
df500['Latitude'] = pd.to_numeric(df500['Latitude'], errors='coerce')
df500['Longitude'] = pd.to_numeric(df500['Longitude'], errors='coerce')
print(df500.dtypes)
# Plot allocation amount as a gmaps heatmap
APIKey = 'AI.......' # put your Google API key here
gmaps.configure(api_key=APIKey)
logan_coordinates = (41.6, -111.8)
denver_coordinates = (39.78, -104.59)
fig = gmaps.figure(map_type='HYBRID', center=denver_coordinates, zoom_level=4.5)
locations = df500[['Latitude', 'Longitude']]
#locations = locations[0:8701]
weights = df500['AllocationAmount']
#weights = weights1[0:8701]
fig.add_layer(gmaps.heatmap_layer(locations, weights=weights))
fig
# plot allocation amount as plotly heatmap
#need to save your mapbox token file in the same dir
px.set_mapbox_access_token(open(".mapbox_token").read())
fig = px.scatter_mapbox(df500, lat="Latitude", lon="Longitude",
color="AllocationAmount", #size="AllocationMaximum",
color_continuous_scale=px.colors.cyclical.IceFire, size_max=5,
range_color=[0,1000],zoom=3, hover_data=["BeneficialUses"])
fig.show()
retrives water allocations (water rights) data for a site
get
By passing in the appropriate options, you can search for
available inventory in the system
Query parameters
SiteUUIDstringOptional
Search based on a univeral Site identifer across all the states in WaDE
SiteTypeCVstringOptional
Search based on a controlled Site type identifer across all the states in WaDE
BeneficialUseCVstringOptional
Search for aggregate data based on a beneficial Use category (primary?) (i.e. Irrigation) as defined by each state
USGSCategoryNameCVstringOptional
a USGS water use category from the USGS controlled vocabulary (e.g. irrigation, groundwater, fresh)
StartPriorityDatestringOptional
Search for water allocations with priority date later than this end date DD/MM/YYYY (e.g., . Leaving it empty would return all data to the earliest priority date in the database
EndPriorityDatestringOptional
Search for water allocations with priority date earlier than this end date DD/MM/YYYY (e.g., . Leaving it empty would return all data to the last priority date in the database
SearchGeometrystringOptional
Search for water allocations within a geo-spatial boundary within or across state boarders (e.g., Bear River watershed)
HUC8stringOptional
HUC12stringOptional
CountystringOptional
StatestringOptional
Two letter state abbreviation.
StartIndexintegerOptional
0-based index for where to start querying for records. Defaults to 0 if not specified.
RecordCountinteger · min: 1 · max: 10000Optional
Number of records to retrieve. Defaults to 1000 if not specified.
Responses
get
GET /v1/SiteAllocationAmounts HTTP/1.1
Host: wade-api.azure-api.net
Accept: */*