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.
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 pythonimport pandas as pdimport numpy as npimport osimport jsonfrom pandas.io.json import json_normalizefrom urllib.request import urlopenimport gmapsimport gmaps.datasetsimport plotly.express as px
# Access WaDE API to get the water allocations JSON url ='https://wade-api-qa.azure-api.net/v1/SiteAllocationAmounts?State='statesShort = ["CO","UT","WA","OR","CA","OK","ND","AZ"]df100_list = []# extract target columnssubcolumns = ['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 valueslatloncolumns = ['WaterSourceUUID','Longitude','Latitude','AllocationAmount','AllocationMaximum','BeneficialUses']df300 = pd.DataFrame(columns=latloncolumns)jy =0for index, rows in df100.iterrows(): SitesL = rows.Sitesfor 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 +=1print(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 heatmapAPIKey ='AI.......'# put your Google API key heregmaps.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 dirpx.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()