Multiple field Custom Symbology

469
2
04-13-2020 01:28 PM
RVx_GaslineGiS
New Contributor III

I am trying to create a custom symbology in Portal using two different fields and a number of if statement requirements. The feature layer contains fields on Pressure and Pipe Size. I want a custom symbology which has certain sizes of pipe linked to certain pressure. For example, having Medium pressure pipe with a size of 6 - 10".

The problem is the below code only shows three out of the five created categories. I've tried coding it up with nested if statements instead of && but ran into the same issues. It seems no matter how I end up writing it, one or more categories won't show up..and which categories don't show up isn't consistent!

var size = $feature.NOMINALPIPESIZE;
var pressure = $feature.PRESSURECODE;
if(size < 10 && pressure <= 2){
     return 'Low Pressure, Under 10"'}

else if( 10 <= size <= 12 && pressure <= 2){
     return 'Low Pressure, 10-12"'}

else if(size >= 13 && pressure <= 2){
     return 'Low Pressure, 13"+'}

else if(size < 6 && 5 <= pressure <= 25){
     return 'Medium Pressure, Under 6"'}

else if(6>= size <= 10 && 5 <= pressure <= 25){
     return 'Medium Pressure, 6-10"'}

else if( size >= 2 && 60 >= pressure <= 27){
     return 'Intermediate Pressure, 2 and under'}

else {

     return 'Unknown' }

Xander Bakker‌, I'm tagging you on this question as you've helped me out a lot with previous questions and your blog posts have helped answer numerous other questions that didn't make their way to GeoNet.

0 Kudos
2 Replies
XanderBakker
Esri Esteemed Contributor

Hi Robert Domiano , 

I did notice that you validate in the last condition for size larger or equal to 2 and the assigned text is "Intermediate Pressure, 2 and under'" and there are gaps in your classification. 

Can you try this:

var size = $feature.NOMINALPIPESIZE;
var pressure = $feature.PRESSURECODE;

var result = 'Unknown';
if (pressure <= 2) {
    if (size < 10) {
        result = 'Low Pressure, Under 10"';
    } else if (size <= 12) {
        result = 'Low Pressure, 10-12"';
    } else {
        result = 'Low Pressure, 13"+';
    }
} else if (pressure <= 25) {
    if (size < 6) {
        result = 'Medium Pressure, Under 6"';
    } else if (size <= 10) {
        result = 'Medium Pressure, 6-10"';
    } else {
        // Unknown: medium pressure and size > 10
    }
} else if (pressure <= 60) {
    if (size <= 2) {
        result = 'Intermediate Pressure, 2" and under';
    } else {
        // Unknown: Intermediate Pressure and size > 2
    }
} else {
    // Unknown: pressure > 60
}

return result;
0 Kudos
RVx_GaslineGiS
New Contributor III

Hello and thank you for the help!

I decided to only work with a cross-section of the categories to try and get the expression to work correctly before writing/re-writing all of them numerous times. I tried the provided expression in both ArcGIS Pro and our ArcGIS Portal. I had differing results, and neither of them correct.

On Portal, only Low Pressure, Under 10" presented a few results with more being in Unknown. Weirdly (and consistent with previous experience lately) only ~1000 records were given values despite there being over 24k+ feature classes.

On ArcGIS Pro, I ended up with only Low Pressure, Under 10" again with a count that matches every other attempt I've made at the expression (503) with every other feature class being put under Unknown.

I do like the ordered approach of the code you provided above. Do you have any ideas on what could be preventing it from properly classifying features? I'm not really sure what to try and look for or debug to get this concept to work, as I feel it should be possible.

0 Kudos