Finding Intersection of two polygons in popup

181
4
Jump to solution
09-23-2021 02:36 PM
JeffreyThompson1
New Contributor II

I am attempting to calculate the area of intersection for two feature layers in a popup field. The layer I am building the popup for is called Parcels and the other layer is Impact Area. This is my best guess at the expression, but it is returning blank. 

 

 

expression: "AreaGeodetic(Intersection($feature, FeatureSetByName($map, 'Impact Area')), 'acres')"

 

 

 

Any suggestions?

0 Kudos
1 Solution

Accepted Solutions
JeffreyThompson1
New Contributor II

I came up with a solution. (For a single impact area shapefile)

 

expression: "AreaGeodetic(Intersection($feature, First(FeatureSetByName($map, 'Impact Area', ['*'], true))), 'acres')"

I found out I also need to handle multiple impact area shapefiles and corrected a couple errors in the original reply to get my final solution.

var impact_areas = Intersects($feature, FeatureSetByName($map, 'Impact Area', ['*'], true))
var impacted_area = 0
for(var ia in impact_areas) {
    impacted_area += AreaGeodetic(Intersection($feature, ia), 'acres')
}
return impacted_area

 

Thanks @JohannesLindner  I wouldn't have got there without you.

View solution in original post

4 Replies
JohannesLindner
Regular Contributor

Intersection takes 2 geometries as input, you use a feature set as second argument.

Assuming that a parcel can intersect multiple impact areas and that impact areas do not overlap:

 

var impact_areas = Intersects($feature, FeatureSetByName($map, 'Impact Area'))
var impacted_area = 0
for(var ia in impact_areas) {
  impacted_area += AreaGeodetic(Intersection($feature, ia), 'acres')
return impacted_area

 

 


Have a great day!
Johannes
JeffreyThompson1
New Contributor II

@JohannesLindner

To clarify, I have one impact area on my map which intersects with multiple parcels that do not overlap with each other. I am looking for the area in a single parcel that falls within the impact area. Based on your suggestion I have tried the following code. It also returns blank with this error: SyntaxError: Unexpected token o in JSON at position 1

 

expression: "AreaGeodetic(Intersection($feature, Geometry(FeatureSetByName($map, 'Impact Area', ['*'], true))), 'acres')"

 

I also attempted your solution and it also returned blank with a Missing Parameters error.

What is the best way to select the geometry from another map layer to use in this function?

0 Kudos
JohannesLindner
Regular Contributor

Ah yes, I missed the $feature in the Intersects function. Should have tested it, sorry.

I edited my original reply for future reference.


Have a great day!
Johannes
0 Kudos
JeffreyThompson1
New Contributor II

I came up with a solution. (For a single impact area shapefile)

 

expression: "AreaGeodetic(Intersection($feature, First(FeatureSetByName($map, 'Impact Area', ['*'], true))), 'acres')"

I found out I also need to handle multiple impact area shapefiles and corrected a couple errors in the original reply to get my final solution.

var impact_areas = Intersects($feature, FeatureSetByName($map, 'Impact Area', ['*'], true))
var impacted_area = 0
for(var ia in impact_areas) {
    impacted_area += AreaGeodetic(Intersection($feature, ia), 'acres')
}
return impacted_area

 

Thanks @JohannesLindner  I wouldn't have got there without you.

View solution in original post