Creating buffers dependent on polygon areas

396
2
Jump to solution
02-09-2021 10:40 AM
COLINGUILFOYLE
New Contributor II

I'm trying to create buffers around polygons with the buffer distance dependent on the size of the polygon. For example, a polygon of <50 hectares would get a buffer of 100m, 51-199 hectares gets a buffer of 200m, and so on. I've been using the Create Buffers tool and trying to use an Expression buffer type. Firstly, I'm not sure if this is the best way to go about this so any advice would be appreciated. Secondly, my expression keeps failing due it not being valid (I'm new to Python). 

The code I've been trying to input has been something like:

when($feature.Area_ha <= 50, 100,
($feature.Area_ha >= 51 && <= 199), 200,
($feature.Area_ha >= 200 && <= 299), 300,
($feature.Area_ha >= 300 && <= 399), 400,
$feature.Area_ha >= 400, 500)

If anyone has any advice on improving the code or another method that would be great. 

Thanks !

0 Kudos
1 Solution

Accepted Solutions
DavidPike
MVP Frequent Contributor

It's an Arcade expression rather than python (most similar to Javascript I believe)

I think you've missed supplying the variable again after each && (AND) statement, and also the default value if no conditions are met (in the below example I've supplied -99999)

when($feature.Area_ha <= 50, 100,
($feature.Area_ha >= 51 && $feature.Area_ha <= 199), 200,
($feature.Area_ha >= 200 && $feature.Area_ha <= 299), 300,
($feature.Area_ha >= 300 && $feature.Area_ha <= 399), 400,
$feature.Area_ha >= 400, 500, -99999)

 

View solution in original post

2 Replies
DavidPike
MVP Frequent Contributor

It's an Arcade expression rather than python (most similar to Javascript I believe)

I think you've missed supplying the variable again after each && (AND) statement, and also the default value if no conditions are met (in the below example I've supplied -99999)

when($feature.Area_ha <= 50, 100,
($feature.Area_ha >= 51 && $feature.Area_ha <= 199), 200,
($feature.Area_ha >= 200 && $feature.Area_ha <= 299), 300,
($feature.Area_ha >= 300 && $feature.Area_ha <= 399), 400,
$feature.Area_ha >= 400, 500, -99999)

 

COLINGUILFOYLE
New Contributor II

Yes that's what the issue was - Thanks for the help!

0 Kudos