MOOC, Cartography and ArcGIS PRO

03-03-2022 02:47 PM
New Contributor


I'm well into Week 3 of the MOOC Program and thoroughly enjoying the experience.

However, after digging a bit deeper by poking around the Python Notebook and viewing a few videos on Python and ArcPy I've come to the conclusion that there's a V8 under the hood!

The trouble is I don't know how to get it out of first gear.

Here is a question for you. In week three, we were asked to  build a definition query. I was wondering can this definition query be exported/imported into Python Notebook?

The reason is that I would like to view the query as a python string. Does that make sense? I understand that python can accomplish all of the analysis tools + more and that the language is intuitive and easy to learn.

Well, I have to say I'm ready to venture into the unknown. I know that model builder can be exported to Python Notebook so I'm asking what about definition a query etc, etc. 

I figure that beginning with concepts that are familiar to me might help me learn python. I want to get out of first gear and see what this baby can really do, but need your help!



Tags (2)
0 Kudos
2 Replies
MVP Notable Contributor

Not exactly sure what you are asking, but the definition query can be read or set using the arcpy mapping module on the layer class.

So, if you set a definition query in Pro, you can use something like 


 to get the current query in python format.  you can use this same property to set a definition query on a layer as well.




0 Kudos
Regular Contributor

The layer supports method will tell you if your layer supports a definition query:

The layer DefinitionQuery property will set a definition query on a layer:



0 Kudos