I have an expression that buffers a line feature and returns a list of intersecting parcel use code descriptions. Currently this outputs an array but I'd like to make it a featureset so I can use groupby to count up the totals for each use type. Everything in the code below works until I get to the dictionary part. Any suggestions?
Here is the dataset being queried: https://services1.arcgis.com/hGdibHYSPO59RG1h/arcgis/rest/services/L3_TAXPAR_POLY_ASSESS_gdb/Feature...
var ParcInt = Intersects(FeatureSetByName($map, "AllParcels",['USE_CODE']), BufferGeodetic($feature, 50, "feet"))
var arr_index = 0;
var NameList = []
var a ="";
for(var x in ParcInt){
NameList[arr_index] = mid(x.USE_CODE,1,1)
a =NameList[arr_index];
NameList[arr_index]=decode(a,
"0","Multi-USe",
"1","Residential",
"2","Open Space",
"3","Commercial",
"4","Industrial",
"5","Personal Property",
"6","Forest Property - Chapter 61",
"7","Agricultural",
"8","Recreational Property",
"9","Exempt Property",
'');
++arr_index;;
}
//return namelist
var newDict = {
fields: [
{ name: "Use Type", type: "esriFieldTypeString" },
{ name: "Count", type: "esriFieldTypeInteger" },
],
'geometryType': '',
'features':NameList
};
return FeatureSet(Text(newDict));
Solved! Go to Solution.
var ParcInt = Intersects(FeatureSetByName($map, "AllParcels",['USE_CODE']), BufferGeodetic($feature, 50, "feet"))
var arr_index = 0;
var features = [];
var feat;
for(var x in ParcInt){
useCode = mid(x.USE_CODE,1,1)
useCode = decode(useCode,
"0","Multi-USe",
"1","Residential",
"2","Open Space",
"3","Commercial",
"4","Industrial",
"5","Personal Property",
"6","Forest Property - Chapter 61",
"7","Agricultural",
"8","Recreational Property",
"9","Exempt Property",
'');
feat = {
'attributes': {
'UseType': useCode,
}
};
Push(features, feat);
}
var newDict = {
'fields': [
{ name: "UseType", type: "esriFieldTypeString" }
],
'geometryType': '',
'features':features
};
return FeatureSet(Text(newDict));
maybe just missing ' ' around fields: [
Any traceback errors etc?
var newDict = {
'fields': [
{ name: "Use Type", type: "esriFieldTypeString" },
{ name: "Count", type: "esriFieldTypeInteger" },
],
'geometryType': '',
'features':NameList
I just added a screenshot. It's returning nulls in the featureset. I don't think I'm loading the data into the featureset correctly.
var ParcInt = Intersects(FeatureSetByName($map, "AllParcels",['USE_CODE']), BufferGeodetic($feature, 50, "feet"))
var arr_index = 0;
var features = [];
var feat;
for(var x in ParcInt){
useCode = mid(x.USE_CODE,1,1)
useCode = decode(useCode,
"0","Multi-USe",
"1","Residential",
"2","Open Space",
"3","Commercial",
"4","Industrial",
"5","Personal Property",
"6","Forest Property - Chapter 61",
"7","Agricultural",
"8","Recreational Property",
"9","Exempt Property",
'');
feat = {
'attributes': {
'UseType': useCode,
}
};
Push(features, feat);
}
var newDict = {
'fields': [
{ name: "UseType", type: "esriFieldTypeString" }
],
'geometryType': '',
'features':features
};
return FeatureSet(Text(newDict));