Attempting to combined 2 feature classes one lines and one points to the same feature class for arcgis Dashboards

269
1
12-07-2023 12:08 PM
DChavis
New Contributor II
This is the code: both feature classes have the same attributes, so I want all the attributes combined except for geometry which can be ignored. When I attempt this the error code "Test execution error: Unknown Error. Verify test data." keeps popping up. 


 
var p = Portal("https://arcgis.com");
var points = FeatureSetByPortalItem(p, "22e8f851a85f4b99b1a2ce2542e9b09c", 0, [], false);
var lines = FeatureSetByPortalItem(p, "f64502f467a043658818eed4317aa90e", 0, [], false);

 

var combinedFeatures = [];

 

// Combine attributes from points
for (var i = 0; i < Count(points); i++) {
  var attributes = points[i].attributes;
  combinedFeatures.push(attributes);
}

 

// Combine attributes from lines
for (var i = 0; i < Count(lines); i++) {
  var attributes = lines[i].attributes;
  combinedFeatures.push(attributes);
}

 

// Resulting feature set
var joinedFeatureSet = {
  'fields': points.fields, // All feature layers have the same fields
  'features': combinedFeatures
};

 

return joinedFeatureSet;
0 Kudos
1 Reply
KenBuja
MVP Esteemed Contributor

Take a look at this blog post by @jcarlson about how to "memorize" a FeatureSet. You should be able to use the same logic to loop through both FeatureSets to combine them into one.

0 Kudos