Esri Training Blog - Page 2

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Latest Activity

(118 Posts)
AndrewSharer
Esri Contributor

Explore these activities at the 2019 Esri User Conference to learn about workforce development strategies that will align with your organization's technology and business strategies.

Read more...

more
0 0 568
TimothyHales
Esri Notable Contributor

Learn the steps to perform a density analysis using attributes and the Point Density tool in ArcGIS Pro 2.2.

Read more...

more
0 0 2,124
Suzanne-Boden
Esri Regular Contributor

This post shows how to apply a five-step process to complete a spatial analysis project using ArcMap (the same analysis could be performed just as easily in ArcGIS Pro).

Read more...

more
2 0 94K
Suzanne-Boden
Esri Regular Contributor

The difference between relates (often called table relates) and relationship classes is a source of much confusion, especially for new ArcGIS users. Though they sound similar, the terms refer to different things. Both have benefits and there are reasons to use each one. Here are the main things to know.

Read more...

more
11 15 14.3K
TimothyHales
Esri Notable Contributor

Context and a few basics on how Python scripts benefit GIS workflows (and save GIS professionals time).

Read more...

more
5 0 4,538
Suzanne-Boden
Esri Regular Contributor

ModelBuilder (included with ArcGIS Pro) provides a visual canvas to create geoprocessing models that automate GIS workflows. Use this five-step approach to create your own a model in ArcGIS.

Read more...

more
6 2 8,825
Suzanne-Boden
Esri Regular Contributor

Get a behind-the-scenes look at all the work that goes into developing and maintaining this popular certification exam.

Read more...

more
2 5 6,680
Suzanne-Boden
Esri Regular Contributor

The Esri Technical Certification team has released version 10.5 exams for seven certifications, including the popular Desktop series: ArcGIS Desktop Entry, ArcGIS Desktop Associate, and ArcGIS Desktop Professional. At version 10.5, ArcGIS Desktop includes ArcGIS Pro and ArcMap. Desktop certification exams test knowledge of both applications.

Read more...

more
3 3 3,141
Suzanne-Boden
Esri Regular Contributor

Learn how to access your Excel spreadsheet data in ArcGIS (it's easier than you think!).

Read more...

more
10 10 18K
Suzanne-Boden
Esri Regular Contributor

A previous post shared five Python code snippets to automate mapping tasks in ArcMap. This post walks you through how to accomplish those same tasks using the ArcGIS Pro Python window.

In ArcGIS Pro, the mapping module is called arcpy.mp. To try the snippets below for yourself, make a copy of an ArcGIS Pro project file (APRX) and move it somewhere for testing purposes. You don’t have to be an experienced Python scripter—simply enter the code below into the Python window and check out the results. 

You’ll soon see how a few Python tricks can speed up map management.

  • Each snippet below works with ArcGIS Pro 1.x, an existing project file, arcpy.mp module, and Python 3.x.

Snippet 1: Check Layer Definition Queries

Suppose you need to check if any of the layers in your ArcGIS Pro project have a definition query applied, and if so, view the definition queries. Opening the Layer Properties dialog box for each layer in each map is a pain.

Solution: Open the Python window instead and run the code below. The name and definition query of all the layers will be “printed” (i.e., displayed in the Python window).

Python code snippet to display layer definition queries

Code Breakdown

  • The first line of code creates a variable called aprx that references the open project using the ArcGISProject function with the CURRENT keyword.
  • The next line of code creates a variable called maps using the listMaps method that returns a Python list of Map objects in the project.
  • A for loop is used to iterate through each map.
  • For each map, the listLayers method is used to create a list of the layers.
  • Another for loop is used to iterate through the list of layers.
  • The Layer class has many properties that can be accessed, including the name and definition query of a layer. Because not all layer types support all properties, the supports method is used to test which properties a layer supports.
  • The last line of code prints (displays) the name of each map, the name of each layer, and each layer's definition query.

Snippet 2: Fix Broken Links

At some point, you have probably moved map data from one workspace to another. Have you ever seen the dreaded red exclamation marks?

ArcGIS Pro Contents pane showing broken layer data source paths

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 project at once. Run the following lines of code in the Python window (be sure to update the paths to reflect your old and new workspaces).

Python code snippet to repair broken layer data source paths

Code Breakdown

  • The first line of code is the same as the previous example, creating the variable aprx that references the open ArcGIS Pro project.
  • The updateConnectionProperties method is used to replace the current connection information (first parameter) with new connection information (second parameter) for all layers and tables in the project.
  • Learn more: Updating and fixing data sources

Snippet 3: Identify Layers with a Broken Data Source

Speaking of those red exclamation marks, you can also use arcpy.mp to print out the layers that have broken links using the code below.

Python code snippet to find layers with broken layer data source paths

Code Breakdown

  • The first line of code creates a variable called aprx that references the open project, just like the examples above.
  • Like the first example, the listMaps and listLayers methods are used to create a list of layers in each map in the project.
  • The for loops are used to iterate through each layer in each of the maps, printing out the name and isBroken layer properties for each. The “\n” adds a line before the map name and creates a separation between the layers for each map.

Snippet 4: Inventory Layer Data Sources

If you need to know the data source for all the layers in your project, but don’t want to open the Layer Properties dialog box for each, simply run the lines of code below in the Python window to print out the names and data sources of the layers.

Python code snippet to display maps layers with their data sources

Code Breakdown

  • This example starts the same way as the previous snippet, creating a variable for the project (aprx), and creating lists of the maps and layers in each of the maps.
  • In this example, you print out the name and dataSource properties for each layer in your map. The supports method is used because not all layers support the dataSource property.

Snippet 5: Combine PDF Documents

Maybe you’re creating a map book or maybe you have a few PDF documents you need to combine (like your expense report and receipts). You can use arcpy.mp and the PDFDocument class to manipulate PDF documents. Run the code below to combine two PDF documents.

Python code snippet to append PDF files

Code Breakdown

  • The first line of code creates a variable called pdf that references an existing PDF document.
  • The appendPages method is used to add pages from a PDF to the end of the referenced PDF.
  • To save the changes, the saveAndClose method is used.

Want to learn more?

If you’d like to learn more about working with the ArcGIS Pro Python window or migrating Python scripts from ArcMap to ArcGIS Pro, check out these resources:

If you'd like an introduction to ArcGIS Pro, these courses are recommended:

Esri instructor Brittney White This post was contributed by Esri instructor Brittney White. Based in Washington, D.C., Brittney’s passion is helping customers learn about and apply Esri technology to their own work.

more
7 2 7,617
98 Subscribers