Help with Intersect / Intersection Attribute Rule

1287
6
Jump to solution
09-30-2021 09:25 AM
Robswann
New Contributor III

Hello, I am trying to determine the correct rule code for determining the amount of acreage within another polygon. 

For Example: I have a feature named Tracts that may or may not contain floodplain acreage (Feature name Floodplain). 

Could someone help me out? ..... This is what I have now.... but it is not pulling the correct acreage, and I think the correct function would be INTERSECTION, but not sure.

Thanks again

 

 

VAR FLOODPLAIN = FeatureSetByName($datastore, "RES_FLOOD_HAZARD")

VAR INTERSECTSFLOOD = INTERSECTS($FEATURE,FLOODPLAIN)

 

area(intersectsflood, 'acres')

Tags (1)
0 Kudos
2 Solutions

Accepted Solutions
jcarlson
MVP Esteemed Contributor

You guess correctly, you'll need Intersection to get the geometry of the overlapping area. However, this function requires two geometries as parameters, and you're working with a FeatureSet.

Simple Version: Getting Intersection of Single Feature

var floodplain = FeatureSetByName($datastore, "RES_FLOOD_HAZARD")

// Grab the first item for the intersects featureset
var flood_feat = First(Intersects($FEATURE, floodplain))

// Get intersection, calculate area
var xs = Intersection(flood_feat, $feature)

// Calculate acreage
return Area(xs) // multiply by some value, depending on the area units in use

 

However, a single tract may intersect with multiple flood zones, and we may want to capture this information.

Complex: Return a List of Intersected Areas

var floodplain = FeatureSetByName($datastore, "RES_FLOOD_HAZARD")

// Get FeatureSet of intersecting flood zones
var flood_fs = Intersects($FEATURE, floodplain))

// Instantiate output string
var out_str = 'Flood Zone Acreage:'

// Iterate over FeatureSet
for(var f in flood_fs){
    // Get intersection, calculate area
    var xs = Intersection(f, $feature)

    // Calculate acreage
    var a = Area(xs) // multiply by some value, depending on the area units in use

    // Append to output string
    out_str += `\n${f.flood_zone_identifier_field} | ${a} ac`
}

return out_str

This will return something like

Flood Zone Acreage:
Zone AE | 12.1 ac
Zone X | 6.23 ac 
- Josh Carlson
Kendall County GIS

View solution in original post

0 Kudos
jcarlson
MVP Esteemed Contributor

Oh, sure! Instead of an output string, you could just use a numeric value. Make these changes to the "complex" expression and see how it works.

Line  7 → var out_area = 0
...
Line 18 → out_area += a
...
Line 21 → return out_area

So instead of creating a cumulative string, you're adding up cumulative sum.

- Josh Carlson
Kendall County GIS

View solution in original post

0 Kudos
6 Replies
jcarlson
MVP Esteemed Contributor

You guess correctly, you'll need Intersection to get the geometry of the overlapping area. However, this function requires two geometries as parameters, and you're working with a FeatureSet.

Simple Version: Getting Intersection of Single Feature

var floodplain = FeatureSetByName($datastore, "RES_FLOOD_HAZARD")

// Grab the first item for the intersects featureset
var flood_feat = First(Intersects($FEATURE, floodplain))

// Get intersection, calculate area
var xs = Intersection(flood_feat, $feature)

// Calculate acreage
return Area(xs) // multiply by some value, depending on the area units in use

 

However, a single tract may intersect with multiple flood zones, and we may want to capture this information.

Complex: Return a List of Intersected Areas

var floodplain = FeatureSetByName($datastore, "RES_FLOOD_HAZARD")

// Get FeatureSet of intersecting flood zones
var flood_fs = Intersects($FEATURE, floodplain))

// Instantiate output string
var out_str = 'Flood Zone Acreage:'

// Iterate over FeatureSet
for(var f in flood_fs){
    // Get intersection, calculate area
    var xs = Intersection(f, $feature)

    // Calculate acreage
    var a = Area(xs) // multiply by some value, depending on the area units in use

    // Append to output string
    out_str += `\n${f.flood_zone_identifier_field} | ${a} ac`
}

return out_str

This will return something like

Flood Zone Acreage:
Zone AE | 12.1 ac
Zone X | 6.23 ac 
- Josh Carlson
Kendall County GIS
0 Kudos
Robswann
New Contributor III

Thanks again for the help. For some reason the expression states it is valid, but will not save? I have tried everything from saving closing out, restarting ? 

0 Kudos
Robswann
New Contributor III

Thanks @jcarlson Any way I could just sum all the zones within that feature to return a value of the total flood acreage? 

0 Kudos
jcarlson
MVP Esteemed Contributor

Oh, sure! Instead of an output string, you could just use a numeric value. Make these changes to the "complex" expression and see how it works.

Line  7 → var out_area = 0
...
Line 18 → out_area += a
...
Line 21 → return out_area

So instead of creating a cumulative string, you're adding up cumulative sum.

- Josh Carlson
Kendall County GIS
0 Kudos
Robswann
New Contributor III

This is very helpful. Thanks again!

0 Kudos
Robswann
New Contributor III

Thanks I figured it out, any way I could just sum all the zones within that feature?

0 Kudos