Use a Definition Query in a Model

873
4
Jump to solution
10-20-2021 08:55 AM
BarryFosberg
New Contributor III

I am using ArcPro 2.8.

1. In a model, can  run a definition query?

2. If yes, Is there any advantage in a model to using a definition query over just adding a Select tool?

The examples I have tend to be a matter of one or more select by attribute statements which would be the same in either a definition query or a Select By tool. 

 

 

0 Kudos
1 Solution

Accepted Solutions
JonathanNeal
Esri Contributor

@BarryFosberg You will first set up your definition query in the Map layer.  Then the tools that are ran within ModelBuilder will honor them.  Any tool that operates against the map layer will check selected and definition queries.  Note if you run Copy Features against the data on disk, it will not check definition queryies or selections.

View solution in original post

0 Kudos
4 Replies
JonathanNeal
Esri Contributor

@BarryFosberg How all tools think of definition queries and selections are the same.  There is no advantage to using one over the other.  Some of the ModelBuilder iterators use definition queries to perform their functions.  But, for triva night, there is a Gotcha you can find yourself in that you may consider.

Definition Query + Selection != Selection + Definition Query

That is, if you do a selection first, that has elements that your definition query would have excluded, the tool will still act on those elements.  The result the tool will act on will be all elements that qualify in the selection and all elements that qualify in the definition query.

But, if you did the Definition query first, and the selection second, it will be the result will be the intersection of both filters.

BarryFosberg
New Contributor III

Thanks for the fast reply.

What started the quest was tiring to figure out how to put a definition query into a model. Definition query were not listing as a geoprocessing tool and copy feature did not have a place to enter a definition query.

How do you place the DQ into the model?

 

0 Kudos
JonathanNeal
Esri Contributor

@BarryFosberg You will first set up your definition query in the Map layer.  Then the tools that are ran within ModelBuilder will honor them.  Any tool that operates against the map layer will check selected and definition queries.  Note if you run Copy Features against the data on disk, it will not check definition queryies or selections.

0 Kudos
BarryFosberg
New Contributor III

And thank you also.

The advice about how selects and DQ interact is subtle and important. Worth the thread by themselves.

 

I had been using , without knowing it, this solution. Part of my immediate problem is that I need the original data to be geo-located, then divided into 6 sub tables. I was hoping it would be more elegant to DQ this within the model.  As of now I have copy's in the Map Layer each with itsown DQ. I think that can be cleaned up using an iterator. Next I will be learning about iterators. 

0 Kudos