Model Builder - Select by Location and Update Attribute

436
8
Jump to solution
05-17-2021 12:11 AM
DeanHowell1
Occasional Contributor III

I am trying to figure out what would seem a fairly normal GIS Process but put into a model so can be replicated.

1. Select feature by location i.e. pointing to a feature on the map

2. Update an attribute of the selected feature only. 

 

Can someone show me how to do this please?

 

Regards

 

Dean

Tags (1)
0 Kudos
1 Solution

Accepted Solutions
DuncanHornby
MVP Frequent Contributor

Dean,

You can automate all that you have discussed in model builder.

Firstly when asking questions about model builder on any forum, include images of your model or even share it, as at the moment everyone is second guessing what they think you are talking about. Also you don't even indicate which software you are using! ArcMap or ArcPro? Tag your question it helps us to help you...

Have a model of nothing more than a select by location feeding into a field calculate. As @curtvprice  says all tools honour selections. Of cause you can shoot yourself in the foot, if no selection is created then the field calculate will apply to all rows in your data and potentially overwrite important data. Something to be aware of, I only have a few toes left  😉

 Typically the select by location takes a layer to do the selection (which it self may have a selection on it). If you want to interactively draw a polygon on the screen that then becomes the geometry that does the selecting you need to expose the parameter as a FeatureSet. You need to expose it as a parameter so it allows you to interact with it and use it to draw a temporary polygon on your map.

So using ArcPro as by way of example (you can do this in ArcMap) here is the model, note some of the parameters have a "P" indicating they are model tool parameters.

DuncanHornby_0-1621348819067.png

The model running as a tool looks like this:

DuncanHornby_1-1621348917037.png

 

Clicking on the pencil icon allows you to draw any geometry and it is that that feeds into the select tool

 

View solution in original post

8 Replies
DanPatterson
MVP Honored Contributor

one of the "Related" questions to the right of you post contains some useful links.  For example...

Solved: Modeling Select By Location - Esri Community


... sort of retired...
DeanHowell1
Occasional Contributor III

Thanks @DanPatterson , yes I have seen that post but still can't get a simple process to work => select features in layer and update the field of the selected feature(s).

0 Kudos
curtvprice
MVP Esteemed Contributor
Most tools that take a layer as input will only operate on selected rows, so the Calculate Field tool in a model would do it.
DeanHowell1
Occasional Contributor III

Thanks @curtvprice but I am still stuck on the selection of features, so I am guessing the selection of features needs to be done outside the model, then run the model to update the attributes. 

0 Kudos
DuncanHornby
MVP Frequent Contributor

Dean,

You can automate all that you have discussed in model builder.

Firstly when asking questions about model builder on any forum, include images of your model or even share it, as at the moment everyone is second guessing what they think you are talking about. Also you don't even indicate which software you are using! ArcMap or ArcPro? Tag your question it helps us to help you...

Have a model of nothing more than a select by location feeding into a field calculate. As @curtvprice  says all tools honour selections. Of cause you can shoot yourself in the foot, if no selection is created then the field calculate will apply to all rows in your data and potentially overwrite important data. Something to be aware of, I only have a few toes left  😉

 Typically the select by location takes a layer to do the selection (which it self may have a selection on it). If you want to interactively draw a polygon on the screen that then becomes the geometry that does the selecting you need to expose the parameter as a FeatureSet. You need to expose it as a parameter so it allows you to interact with it and use it to draw a temporary polygon on your map.

So using ArcPro as by way of example (you can do this in ArcMap) here is the model, note some of the parameters have a "P" indicating they are model tool parameters.

DuncanHornby_0-1621348819067.png

The model running as a tool looks like this:

DuncanHornby_1-1621348917037.png

 

Clicking on the pencil icon allows you to draw any geometry and it is that that feeds into the select tool

 

View solution in original post

DeanHowell1
Occasional Contributor III

Thanks @DuncanHornby , thanks for the advice and the model example. I would normally include screenshots in the forums but in this case I had no idea where to start as all the examples on the Esri help pages are using entire layers as input for clips etc. Thanks again

0 Kudos
DeanHowell1
Occasional Contributor III

Thanks again @DuncanHornby  sorry but need to ask a very basic question. How do you set up the "Selecting Features" and "Input Features" at the start of your example model? I have been trying them as variables but can't get the same output that you are seeing in the geoprocessing screenshot.

0 Kudos
DuncanHornby
MVP Frequent Contributor

In the model right click on the tool itself (square box) and choose Create Variable>From Parameter to show it on the model. Then to turn it into a parameter to allow you to change the value to anything, right click on the input and select parameter. You then run the model directly from the toolbox (so open it not edit it).

I think its worth your time reading up on modelbuilder in the help file or attend a training course. Getting proficient in modelbuilder will unlock all sorts of doors for you in geoprocessing and in my opinion the first steps to learning scripting.

0 Kudos