896
2
04-25-2021 02:08 PM
Labels (1)
by
New Contributor II

Hello,

I'm using ArcGIS Pro to calculate total percent of parcels in a hazard zone. For this I used the tabulate intersection tool, and successfully was able to get a pivot table that shows each parcel in a city limit that overlaps with a certain hazard. Right now, I am working with flood data, so my pivot table's has A, AE, VE, and X flood zone fields. Since there are over 3,000 parcels, I don't want to calculate what parcel is in what flood zone manually, so I created a new field "High_Zone". I was going to use the stats with city and flood zone as my axes, but the graph repeats parcels because I did not specify any overlap classification.

The classification I need to use is: if a parcel is 45% or more in a zone, then I will say that whole parcel is in that zone. But, I want to make sure that the parcels that are 45% or more in zone X to be prioritized before any other zone since it is more dangerous. So, I tried doing this code block in my High_Zone field, but am running into errors. I am using Arcade (but I did try using python but also ran into issues -- got the error on line 1, identifier expected, but I before I redid my code I kept getting open parenthesis expected).

For more clarity:

My pivot table looks like this:

I want High_Zone field to output a flood zone with more than 45% (I do use 44.5% in my code because I think that range is still very close enough to classify as primary hazard in that parcel)

 Parcel ID City A AE VE X High_Zone 123456 XXXX null 51.2 null 44.5 X (although AE if higher %. because I am going for ~45% I want to include 44.5% of X, the more dangerous hazard) 78910 AAAA 73 10 null null A

``````if (\$feature.A >= 44.5) {
return "A"
} if (\$feature.AE >= 44.5) {
return "AE"
} if (\$feature.VE >= 44.5) {
return "VE"
} if (\$feature.X >= 44.5) {
return "X"
}``````

``````if (\$feature.A >= 44.5) {
return "A";
}
if (\$feature.AE >= 44.5) {
return "AE";
}
if (\$feature.VE >= 44.5) {
return "VE";
}
if (\$feature.X >= 44.5) {
return "X"
}``````

Edit: I just tried the second code and I got no errors, but aside from one AE, and all A, all outputs are null

2 Replies
by
MVP Notable Contributor

With multiple conditions, you should include else in your code to indicate the order in which things are to evaluate. As you state, you want zone X to be prioritized, so you list it first in the series of conditions.

By using "else if" for the following condition, it will evaluate only if the preceding condition is False, that is, X is not greater than the threshold.

``````var f = \$feature
var t = 44.5

if (f.X >= t) {
return 'X'
} else if (f.A >= t) {
return 'A'
} else if (f.AE >= t) {
return 'AE'
} else if (f.VE >= t) {
return 'VE'
} else {
return 'No High Zone'
}``````

Also, by including a final 'else', we give the code an output for when all conditions evaluate as False.

Could you clarify, though: if two zones are above 44.5%, would you want them both in the output field? That would require a different bit of code than this.

- Josh Carlson
Kendall County GIS
by
New Contributor II

Hi,

Thank you for helping me! To answer your question, I would want only one output, prioritized from highest to lowest in risk, but with flood zones in general not sure which is worse. For other hazards I am working on, I am just scaling downwards in class. For example, with seismic I would go from highest shaking intensity to lowest, top-down, in code. To clarify here's what I wrote in my code block for flood:

``````if (\$feature.X >= 44.5) {
return "X"
}
if (\$feature.A >= 44.5) {
return "A";
}
if (\$feature.AE >= 44.5) {
return "AE";
}
if (\$feature.VE >= 44.5) {
return "VE";
}``````

From what I saw, the output looked correct, are there potential problems with my code? I planned on using this general format for all other hazards as well.