Skip to content

Instantly share code, notes, and snippets.

@JeffJacobson
Last active September 6, 2018 20:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JeffJacobson/5a3b14b98e2a6305d88f3ee7309e6b7b to your computer and use it in GitHub Desktop.
Save JeffJacobson/5a3b14b98e2a6305d88f3ee7309e6b7b to your computer and use it in GitHub Desktop.
WSDOT Arcade expressions

This gist contains ArcGIS Arcade expressions.

// Gets the Open Data portal URL filtered to just this location
"https://gisdata-wsdot.opendata.arcgis.com/datasets/46a11f7e043842a5bfbbb1b69e7e4900_0/data?where=LocationID%20%3D%20%27" + $feature.LocationID + "%27"
// Extract county identifier and convert to number.
var cid = Number(Mid($feature.RouteId, 2, 3))
// Return the county name corresponding to the county id.
Decode (
cid,
1, "Adams",
3, "Asotin",
5, "Benton",
7, "Chelan",
9, "Clallam",
11, "Clark",
13, "Columbia",
15, "Cowlitz",
17, "Douglas",
19, "Ferry",
21, "Franklin",
23, "Garfield",
25, "Grant",
27, "Grays Harbor",
29, "Island",
31, "Jefferson",
33, "King",
35, "Kitsap",
37, "Kittitas",
39, "Klickitat",
41, "Lewis",
43, "Lincoln",
45, "Mason",
47, "Okanogan",
49, "Pacific",
51, "Pend Oreille",
53, "Pierce",
55, "San Juan",
57, "Skagit",
59, "Skamania",
61, "Snohomish",
63, "Spokane",
65, "Stevens",
67, "Thurston",
69, "Wahkiakum",
71, "Walla Walla",
73, "Whatcom",
75, "Whitman",
77, "Yakima",
"Invalid"
)
// Extract and return the road number.
Mid($feature.RouteId, 5, 5)
function getSpeciesName(abbrev) {
console(abbrev)
return Decode(abbrev, "SO", "Sockeye","CH", "Chum","PK", "Pink","CO", "Coho","CK", "Chinook","SH", "Steelhead","SRCT", "Sea run cutthroat","RT", "Resident","BT", "Bull Trout","Unknown");
}
var list = [];
var abbrevList = Split($feature.Species, ",", 20, true);
console(abbrevList);
for (var i in abbrevList) {
var item = Trim(abbrevList[i]);
console(item);
list[i] = getSpeciesName(item);
}
return Concatenate(Sort(list), ", ");
function parseDateInt(dateInt) {
var day = dateInt % 100;
var month = (((dateInt - day) % 10000) / 100) - 1;
var year = (dateInt - dateInt % 10000) / 10000
return Date(year, month, day)
}
parseDateInt($feature.LRS_Date)
// For use with https://data.wsdot.wa.gov/arcgis/rest/services/Traffic/PTRSites/MapServer
// Outputs a URL to a site where user can download CSV files related to the current site.
'https://www.wsdot.wa.gov/Traffic/API/PermanentTrafficRecorder/?siteId=' + $feature["ADCTrafficSDE.DBO.PTRSites.SiteID"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment