Select to view content in your preferred language

Modeling Select By Location

14881
5
Jump to solution
10-14-2015 09:12 AM
RonaldAbelon
Emerging Contributor

Is there a way of getting Model Builder to perform a Select by Attribute or Select by Location when working with polygons?

When executing the operation manually, I perform a Select by Attribute in the attribute table.  Then I perform a Select by Location, intersection type, which grabs a large set of adjacent and crossing features.  Then I return to the attribute table to deselect items based on a number.  This greatly reduces the number of features chosen and allows me to take advantage of the proximity/adjacency properties of feature classes.

Is it possible to perform this type of operation using grids?

0 Kudos
1 Solution

Accepted Solutions
JohnHendrickson
Esri Contributor

Hi Ronald,

This can be done with a combination of tools in Model Builder. A basic example would be using an iterator to iterate through the different grid features (grouped by a value from the attribute table) and uses that feature to select form a different layer those features that intersect it. That selection can then be seen in the map, added to the table of contents as a feature layer, or exported to a new feature class in a geodatabase. I have included two images for two different models below as examples; one that adds a feature layer (a layer existing in memory and in the map document only) and the second that exports the selection to a new feature class in a geodatabase. Both examples take advantage of the inline variable substitution to name the output and help identify which layer intersected which grid feature. Inline variables are called with %Variable Name% so in this case an output layer name might look like “SelectedFeatures%Value%.

This is just one example of how this can be done. A combination of Select By Attribute and Select By Location can accomplish similar outcomes as well. If you wanted to select one grid feature that you knew the id attribute value for you could use Select By Attribute tool to run the SQL expression on and pass that output selection to the Select Layer By Location tool as the selecting features. Additionally, you could substitute the Make Feature Layer tool for the Select By Attribute tool because it also has a SQL Expression parameter to identify specific grid feature(s).

In the end, workflows such as this can be achieved with Model Builder it will just depend on the data you are working with and what type of output you want to produce. The selection methods can all be adjusted throughout the model and multiple selection tools can be added to build on a current selection or subtract form a selection just as they can be done manually in ArcMap. A few of the key tools to look at when building these tools will be as follows:

- Iterate Feature Selection: http://desktop.arcgis.com/en/desktop/latest/tools/modelbuilder-toolbox/iterate-feature-selection.htm

- A quick tour of using inline variable substitution: http://desktop.arcgis.com/en/desktop/latest/analyze/modelbuilder/a-quick-tour-of-using-inline-variab...

- Make Feature Layer: http://desktop.arcgis.com/en/desktop/latest/tools/data-management-toolbox/make-feature-layer.htm

- Select Layer By Attribute: http://desktop.arcgis.com/en/desktop/latest/tools/data-management-toolbox/select-layer-by-attribute....

- Select Layer By Location: http://desktop.arcgis.com/en/desktop/latest/tools/data-management-toolbox/select-layer-by-location.h...

FeatureLayerExample.pngFeatureClassExample.png

View solution in original post

5 Replies
Luis_ÁngelPascual_Camino
Occasional Contributor

Hi Ronald.

In Model Builder, first you have to convert your feature class to feature layer with 'Make Feature Layer' function, and then you can perform the 'Select by Location' function, with intersect option, or any other, or add a join...

The 'Select By Attribute' function, you can perform it directly on your Feature class with the 'Select (Analysis)' tool.

With grids.... I don't know, but try in this way...

Good luck!
Regards,
Luis

DanPatterson_Retired
MVP Emeritus

Grids can't be used in select by location, but you can emulate select by attributes using this tool

DarrenWiens2
MVP Honored Contributor

I assume you're talking about a vector polygon grid, not the ESRI raster format grid (annoying, but important distinction).

As Luis Ángel Pascual Camino says, use:

Make Feature Layer

Select Layer By Attribute

Select Layer By Location

SusanZwillinger
Frequent Contributor

Ronald,

I created a toolbox with a Python script that iterates through each attribute in one layer and does a "Select by Location" in another layer.  I'm sure that you can edit the script to do what you need.  You can download the zip file on my previous post Select by Location Toolbox - Python script automation used to work and now shows ERROR 000210 (I fixed the error and uploaded the corrected version of the script.)

Regards,

-Susan-

0 Kudos
JohnHendrickson
Esri Contributor

Hi Ronald,

This can be done with a combination of tools in Model Builder. A basic example would be using an iterator to iterate through the different grid features (grouped by a value from the attribute table) and uses that feature to select form a different layer those features that intersect it. That selection can then be seen in the map, added to the table of contents as a feature layer, or exported to a new feature class in a geodatabase. I have included two images for two different models below as examples; one that adds a feature layer (a layer existing in memory and in the map document only) and the second that exports the selection to a new feature class in a geodatabase. Both examples take advantage of the inline variable substitution to name the output and help identify which layer intersected which grid feature. Inline variables are called with %Variable Name% so in this case an output layer name might look like “SelectedFeatures%Value%.

This is just one example of how this can be done. A combination of Select By Attribute and Select By Location can accomplish similar outcomes as well. If you wanted to select one grid feature that you knew the id attribute value for you could use Select By Attribute tool to run the SQL expression on and pass that output selection to the Select Layer By Location tool as the selecting features. Additionally, you could substitute the Make Feature Layer tool for the Select By Attribute tool because it also has a SQL Expression parameter to identify specific grid feature(s).

In the end, workflows such as this can be achieved with Model Builder it will just depend on the data you are working with and what type of output you want to produce. The selection methods can all be adjusted throughout the model and multiple selection tools can be added to build on a current selection or subtract form a selection just as they can be done manually in ArcMap. A few of the key tools to look at when building these tools will be as follows:

- Iterate Feature Selection: http://desktop.arcgis.com/en/desktop/latest/tools/modelbuilder-toolbox/iterate-feature-selection.htm

- A quick tour of using inline variable substitution: http://desktop.arcgis.com/en/desktop/latest/analyze/modelbuilder/a-quick-tour-of-using-inline-variab...

- Make Feature Layer: http://desktop.arcgis.com/en/desktop/latest/tools/data-management-toolbox/make-feature-layer.htm

- Select Layer By Attribute: http://desktop.arcgis.com/en/desktop/latest/tools/data-management-toolbox/select-layer-by-attribute....

- Select Layer By Location: http://desktop.arcgis.com/en/desktop/latest/tools/data-management-toolbox/select-layer-by-location.h...

FeatureLayerExample.pngFeatureClassExample.png