![]() ![]() ![]() Run the following lines of code in the Python window (be sure to update the paths to reflect your old and new workspaces). If the path to map layers has changed, with just a few lines of code you can quickly find the old workspace path and replace it with the new workspace path for all layers and tables in your map document at once. Have you ever seen the dreaded red exclamation marks? The last line of code prints (displays) the name of each layer and its definition query.Īt some point, you have probably moved map data from one workspace to another.Because not all layer types support all properties, the supports method is used to test which properties a layer supports. The Layer class has many properties that can be accessed, including the definition query for a layer.The ListLayers function is used to create a list of all the layers in the map document and the for loop is used to iterate through each layer in the map.The first line of code creates a variable called mxd that references the open map document using the CURRENT keyword.The name and definition query of all the map layers will be “printed” (i.e., displayed in the Python window). Solution: Open the Python window instead and run the code below. Opening the Layer Properties dialog box for each layer is a pain. Suppose you need to check if any of the layers in your map document have a definition query applied, and if so, view the definition queries. Snippet 1: Check Layer Definition Queries Simply enter the code into the Python window and check out the results. ![]() You don’t have to know any Python syntax to use these snippets. Each snippet below works with ArcMap 10.x, an existing map document (MXD file), arcpy.mapping module, and Python 2.x.You’ll soon see how useful a few Python tricks can be for map management tasks. Make a copy of an MXD file and move it somewhere to test out these snippets. Have you been meaning to try out the ArcMap Python window, but just aren’t sure how to start? Well, the five code snippets below are a great tool to familiarize yourself with the Python window and the arcpy.mapping module. ![]()
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |