Select to view content in your preferred language

Help using Arcade FeatureSets to return text

562
1
12-12-2023 01:25 PM
Labels (1)
AdamAull
New Contributor II

Hi everyone. I've been working on an Arcade script in Portal 11.1 that is supposed to return a string when a residential building intersecting a selected tax parcel intersects an enterprise zone polygon. The script returns the subset of building features when intersecting the buildings and tax parcels. But when the subset of building features is intersected with the enterprise zone polygon, nothing is returned.

Three screenshots have been included illustrating this concept.

Image 1 shows a simple script returning the number of buildings intersecting the selected tax parcel.

Image 2 shows nothing is returned when the buildings inside the tax parcel are intersected with the enterprise zone.

Image 3 shows an attempt to loop through each building feature and intersect it with the enterprise zone layer, then return the count of buildings. Nothing is counted and the default 0 is returned.

Image 4 I've written the full script to check for all of the allowable conditions. This script is following the pattern of not returning the required string when any of the conditions are met. The intersecting FeatureSets isn't able to work properly, nor are the conditional statements.

if($feature.InDanville == "Y"){
 
  //Create FeatureSet from Enterprise Zone layer
  var ez_layer = FeatureSetByName($map, "Enterprise Zone", ["OBJECTID"], false);

  //Create a negative buffer of the selected Tax Parcel feature
  var parcel_buffer = Buffer($feature, -10, "feet");

  // Create a FeatureSet from the Buildings layer
  var bld_layer = FeatureSetByName($map, "Buildings", ["ResidentialUnits"], false);

  // Filter the Buildings FeatureSet by Buildings that have residential units
  var bld_filter = Filter(bld_layer, "ResidentialUnits > 0");

  // Intersect the filtered Buildings with the selected Tax Parcel buffered feature
  var bld_result = Intersects(bld_filter, parcel_buffer);

  // Intersect the selected Tax Parcel buffered feature with the Enterprise Zone FeatureSet
  var parcel_inside_ez = Intersects(parcel_buffer, ez_layer);
 
  // Check to see if the selected Tax Parcel buffered feature intersected the Enterprise Zone FeatureSet
  // Check to see if the filtered Buildings intersected the Tax Parcel buffered feature
  if(Count(parcel_inside_ez) > 0 && Count(bld_result > 0)){
      return "This residential property is within the enterprise zone."  
  }

  // Check to see if the selected Tax Parcel buffered feature intersected the Enterprise Zone FeatureSet
  // Check to see if the filtered Buildings did not intersect the Tax Parcel buffered feature
  else if(Count(parcel_inside_ez) > 0 && Count(bld_result == 0)){
    return "This is not a residential property."
  }

  // Check to see if the selected Tax Parcel buffered feature intersected the Enterprise Zone FeatureSet
  // Check to see if the filtered Buildings intersected the Tax Parcel buffered feature
  else if(Count(parcel_inside_ez) == 0 && Count(bld_result > 0)){
    return "This residential property is not within the enterprise zone."
  }
}
else{
  return "This property is not in the city."
}

0 Kudos
1 Reply
KenBuja
MVP Esteemed Contributor

In your if statements, you have misplaced parenthesis for the Count functions on bld_result (lines 1, 7, and 13). And you should have a return if both counts are zero.

  if(Count(parcel_inside_ez) > 0 && Count(bld_result) > 0){
      return "This residential property is within the enterprise zone."  
  }

  // Check to see if the selected Tax Parcel buffered feature intersected the Enterprise Zone FeatureSet
  // Check to see if the filtered Buildings did not intersect the Tax Parcel buffered feature
  else if(Count(parcel_inside_ez) > 0 && Count(bld_result) == 0){
    return "This is not a residential property."
  }

  // Check to see if the selected Tax Parcel buffered feature intersected the Enterprise Zone FeatureSet
  // Check to see if the filtered Buildings intersected the Tax Parcel buffered feature
  else if(Count(parcel_inside_ez) == 0 && Count(bld_result) > 0){
    return "This residential property is not within the enterprise zone."
  } 
  // If both counts are zero
  else {
    return "This property is not residential and is not within the enterprise zone."
  }

 

0 Kudos