[GIS] ArcGIS Pro arcade if else statements

arcadearcgis-proif else

I am tasked with sorting Zoning codes numbering over 100 to just 5 (Residential, Office, Commercial, Industrial and Misc).

For whatever reason I cannot get Arcade to recognize a text attribute other than the first two statements.

ArcGIS Pro Calculate Field in Arcade with If Else Statement

I've tried the following with no success:

if ($feature.ZONE == "C-1"){     
    $feature.ZONE1; 'Commercial'}
else $feature.ZONE1; 'Miscellaneous'

I want any Field containing a value "C-" or "CB-" to be Commercial,
"I-" to be Industrial, "R-" residential and "Misc" everything else.

var zone = $feature.ZONE;

if (find('C-', zone,0)>0) {

return 'Commercial'
};

if (find('O-', zone,0)>0) {
return 'Office'

};
if (find(['R-',"X-","SH","SR"], zone,0)>0) {
return 'Residential'

};
else {
return 'Misc'
};

Am I just using the wrong processing tool?

Best Answer

I found a way for sorting the Zoning codes. It seemed like a very tedious way of doing the script, but it worked. I was hoping for a way of combining variables to one line.

    var zone = $feature.ZONE;

    if (zone == 'C-1') {
    return 'Commercial'
    }
    else if (zone == 'C-2') {
    return 'Commercial'
    }
    else if (zone == 'C-3') {
    return 'Commercial'
    }
    else if (zone == 'CB-1') {
    return 'Commercial'
    }

    else {
    return 'Misc'
    }  
Related Question