ModelBuilder - Delete Largest Polygon

456
3
Jump to solution
04-04-2013 06:12 AM
MilesTautscher
New Contributor
[ATTACH=CONFIG]23200[/ATTACH]
Hi,

I have a polygons feature class inside a model and I need to delete the largest polygon. The logic I've followed so far is:

- Convert the polygons to a feature layer so that I can use select by attribute
- Select By Attribute (New Selection) all features using the SQL expression "Id > 0"
- Select By Attribute (Remove from selection) the largest feature using the SQL expression Shape_Area=(SELECT MAX(Shape_Area) FROM polygons_Layer (2))

(From there I use copy features to make the selected features a new feature class).

This model works if the polygons feature class already exists (there is nothing wrong with the way the SQL expressions are written). However, since the model is designed to be transferable - and the polygons created within the model - it does not recognize either of the SQL expressions (when I click verify, it says "There was an error with the expression.")

Any ideas how to get around this? Obviously I'm open to completely different methods but the end result has to be a new polygon feature class with the largest polygon removed.

Thanks!
0 Kudos
1 Solution

Accepted Solutions
MelanieSummers
Occasional Contributor III
Hi Miles,

Attached is a 10.0 model that can be run as a GP tool. It is currently set up for a shapefile, to run it on a feature class you'll need to change the expression from FID to OBJECTID.

Best,
Melanie S.

View solution in original post

0 Kudos
3 Replies
MelanieSummers
Occasional Contributor III
Hi Miles,

Attached is a 10.0 model that can be run as a GP tool. It is currently set up for a shapefile, to run it on a feature class you'll need to change the expression from FID to OBJECTID.

Best,
Melanie S.
0 Kudos
MilesTautscher
New Contributor
Awesome, thanks so much.

Just one additional point to anyone who revisits this in the future: make sure that when you change FID to OBJECTID, you don't forget to change the 0 to 1 as well!
0 Kudos
MelanieSummers
Occasional Contributor III
Good point Miles!
0 Kudos