Hi,
I'm kinda noob in arcade. I'm trying to achieve an interactive map where a person clicks on a parcel and pop-up shown information about whether the land is affected by any restrictions or what land-use it is in. Unfortunately, a parcel can be in two or more land-uses/study area etc. and I don't know how to display information for more than one variable.
Showcase is for study area. I'm using arcgis online map viewer pop-up arcade ("newly" allowing use html).
I would like to achieve of format:
■ X% of parcel in STUDY AREA:
US.01
US.02
■ Insert study US.01 info
■ Insert study US.02 info
■ Common info for all studies
I know its kinda confused in "var DefUS01 = IIF(percentage > 0 && US_info == 'US.01'" because if it's cnt > 1 → US_info is in format:
US.0X
US.0X
so it's not gonna find any match. If i ty to use IIF(percentage > 0 && Find('US.01', US_info) it's failing too. I need something to to say "if % of area is bigger than 0 and you find value US.01 in US_info return text.
It's even possible to achieve something like this without changing attribute table for easier value calling?
var prunik = Intersects((FeatureSetByName($map, "Územní studie")), $feature);
var cnt = Count(prunik);
var intersectArea = 0;
/////////Calling study ID + info
var US_info = ""
for (var US in prunik) {
if (US_info == "") { US_info = US.Id; }
else { US_info += "<br>" + US.Id; } }
if (cnt > 0) {
// we have overlap
for (var prunikArea in prunik) {
// intersect with polygon, and add area to the total
intersectArea += Area(Intersection($feature, prunikArea), "vymeraparcely");
}
// calculate the percentage of overlap
var zoneArea = Area($feature, "vymeraparcely");
var percentage = Round(intersectArea * 100.0 / zoneArea, 1);
// format the resulting text for > 0 < 100
var result = "<tr><td>■ " + percentage + "% of parcel in <strong>STUDY AREA - " + US_info + "</strong>. " + "</td></tr>";
//format conditions for final text
var hlavicka = IIF(percentage > 0, "<table><tr><th>Územní studie</th>", "")
var RegIN100 = IIf(percentage == 100, "<tr><td>■ Parcel in <strong>STUDY AREA - " + US_info + ". " + "</strong></td></tr>", "")
var RegIN = IIF(percentage > 0 && percentage < 100, result, "")
var konec = IIF(percentage > 0, "</table>", "")
var DefUS01 = IIF(percentage > 0 && US_info == 'US.01', "<tr><td><br>■ <u>Insert study US.01 info</u></tr></td>", "" )
var DefUS02 = IIF(percentage > 0 && US_info == 'US.02', "<tr><td><br>■ <u>Insert study US.02 info</u></tr></td>", "" )
var DefUS04 = IIF(percentage > 0 && US_info == 'US.04', "<tr><td><br>■ <u>Insert study US.04 info</u></tr></td>", "" )
var DefUS05 = IIF(percentage > 0 && US_info == 'US.05', "<tr><td><br>■ <u>Insert study US.05 info</u></tr></td>", "" )
var DefUS06 = IIF(percentage > 0 && US_info == 'US.06', "<tr><td><br>■ <u>Insert study US.06 info</u></tr></td>", "" )
var DefUS07 = IIF(percentage > 0 && US_info == 'US.07', "<tr><td><br>■ <u>Insert study US.07 info</u></tr></td>", "" )
var OBECust = IIF(percentage > 0, "<tr><td><br>■ Common info for all studies</tr></td>", "")
}
///////// Final Text
var finalText = hlavicka + RegIN + RegIN100 + DefUS01 + DefUS02 + DefUS04 + DefUS05 + DefUS06 + DefUS07 + OBECust + konec
return {
type : 'text',
text : finalText //this property supports html tags
}
If intersect with 2 study areas - not working
If intersect with part of the study area - working
If intersect with 1 study area (100% intersect) - working
I meant to get to this today and ran out of time. I didn't get a chance to fully noodle through your script, but below is something where if you click a fire perimeter boundary, it will tell you which Census Tract(s) are under as well as the percent for each (one-to-many). I've tried to use ESRI data so you can make your own map. The expression goes on the current perimeters layer
// Boundaries : https://services.arcgis.com/P3ePLMYs2RVChkJx/arcgis/rest/services/USA_Census_Tracts/FeatureServer/0
// Fires : https://services9.arcgis.com/RHVPKKiFTONKtxq3/ArcGIS/rest/services/USA_Wildfires_v1/FeatureServer/1
var boundaries = FeatureSetByName($map, "USA Census Tract Boundaries",['*'], true)
var intersections = Intersects(Geometry($feature), boundaries)
var output_text = ''
for(var f in intersections) {
var txt = ''
var percent = ''
var intersection_size = ''
// What is the size of the area that intersects the tract and the fire perimeter
intersection_size = Area(Intersection($feature, f), "acre")
// What % of the fire perimeter is inside the tract?
percent = Text(Round(intersection_size / Area(Geometry(f), "acre") * 100))
// Create an individual line for each
txt = Concatenate(['<p>', f['FIPS'],": is ", percent, "% affected by fire.", '</p>'])
// Output
output_text = output_text + txt
}
Console(output_text)
return {
type : 'text',
text : output_text
}