Python: Map Automation in ArcGIS Pro Beyond The Basics...Python CIM Access in Pro (released with Pro...

Preview:

Citation preview

Kimberly McCarty

Python:

Map Automation in ArcGIS Pro

Beyond The Basics

Migrating to ArcGIS Pro

http://esriurl.com/9785

• Python module: 2to3

• Applies fixes to

transform Python 2

code to Python 3 code

• https://docs.python.org/2/l

ibrary/2to3.html

• ArcGIS Pro Tool: Analyze

Tools For Pro

• Checks for functionality

not available in Pro

arcpy.(m)a(p)ping samples

http://esriurl.com/8899

Python 2 vs. Python 3

• Python 2.x:

- ArcGIS Desktop, ArcGIS Server Map Runtime

- End of Support: 01.2020

• Python 3.x:

- ArcGIS Pro, ArcGIS Server Pro Runtime, Hosted Notebooks, ArcGIS API for Python

• https://www.esri.com/arcgis-blog/products/arcgis/announcements/how-sunsetting-

python-2-affects-arcgis/

• Windows 7/Windows 2008 R2

- Support from Microsoft ended January 2020 – so ArcGIS also no longer supports those

OS‘s – see Deprection notes

- https://support.esri.com/en/technical-article/000017062

- https://www.esri.com/arcgis-blog/products/arcgis-pro/administration/support-for-windows-

7-and-windows-server-2008-is-ending-what-does-that-mean/4

Sharing Maps

https://pro.arcgis.com/en/pro-app/arcpy/sharing/introduction-to-arcpy-sharing.htm

Demo

Publish To

Standalone Server

Publish to Standalone ArcGIS Server – demo source code

Set the output folder path, Service name,and SDDraft path

Get the current map

Create the service definition draft file

Export the SDD file to specified path

Set the service definitionpath and stage the service

Publish the map service toa standalone server

Publish to Standalone Server – starting with 2.3/UI with 2.4

• Publishing ArcGIS Pro Maps directly to ArcGIS Server

• Target to Support ArcGIS Server 10.4+

- Symbology/Mapping function based on the ArcGIS Pro-Runtime-Version which is in the

Server included

ArcGIS Server Version Included ArcGIS Pro Runtime

10.4 1.2

10.4.1 1.3

10.5 1.4

10.5.1 2.0

10.6 2.1

10.6.1 2.2

10.7 2.3

10.7.1 2.4

Cartographic Information

Model - CIM

Python CIM Access in Pro (released with Pro 2.4)

• CIM (Cartographic Information Model)

- Specification for how project and document information

is persisted and re-created

- MAPX, PAGX, LYRX files are in a JSON format

- Structure is analogous to an object model diagram

• Arcpy.mp can navigate the CIM object model

- Entry points are with the Map, Layer, Table or Layout objects

• Don’t let the name fool you

– you have access to so much more than cartography!

Help topic: http://esriurl.com/15489

Video: http://esriurl.com/15490

Show CIM -

Renderer

CIM-Version & Renderer Sample

1

1 2

2

3

3

4

4

Level 1

Level 2

5

5

6

6

Why CIM Access

• Provide finer grained access to project properties

• Pro is growing so rapidly, the CIM immediately exposes new capabilities

• It has been available to the .NET SDK community since Pro 1.1

• Why not use the CIM

- Doesn’t provide access to everything

- high level project properties, metadata, change spatial reference

- Can’t create new objects. If it is not in the CIM, you can’t access it.

- No life guard (managed UI or API) on duty

- You can break the behavior of the app

- Test thoroughly

… and why not

Basic workflow

cim_obj = Object.getDefinition(version) #’V2’

### Do something to the CIM object

Object.setDefinition(cim_obj)

* Object = Map, Layer, Table or Layout

Simple Samples

working with CIM

Sample Code to modify Alias-Name of Field

Get the project, map, and layerGet the CIM for the layerMake the OBJECTID field not visibleChange the alias of the TestFieldand edit the number formattingCommit the changes to the CIM

Modify Symbology

Modify Symbology

Get the project, map, and layerChange polygon fill colorChange polygon outline colorCommit the changes to the CIMGet the CIM

Modify Chart

Modify Chart - Sample

Get the project, map, and layerGet the CIMGet the chartEdit the chart title, font size, and background colorGet the chart series and change the orientationCommit the changes to the CIM

Modify Layout

Get the CIM of the layoutAdd an extent indicatorChange the distance between gridlinesChange the color of the gridlinesChange the color of the gridline labels

Add a legend title and set the fontDelete fields from the tableEdit symbology of the layout’s titleEdit the paragraph symbologyCommit the changes to the CIM

CIM Repo

• Getting started with the CIM

- Published repo: https://developers.arcgis.com/documentation/

URLs - Migrating from arcpy.mapping: http://esriurl.com/9785

- 2to3: https://docs.python.org/2/library/2to3.html

- Samples for arcpy.mp: http://esriurl.com/8899

- Sunsetting Python 2 blog post: https://www.esri.com/arcgis-

blog/products/arcgis/announcements/how-sunsetting-python-2-affects-arcgis/

- Deprecation plans: https://support.esri.com/en/technical-article/000017062

- OS Deprecation affecting ArcGIS: https://www.esri.com/arcgis-

blog/products/arcgis-pro/administration/support-for-windows-7-and-windows-

server-2008-is-ending-what-does-that-mean/

- CIM help: http://esriurl.com/15489

- CIM Video: http://esriurl.com/15490

- CIM published repo: https://developers.arcgis.com/documentation/

Questions?

Print Your Certificate of Attendance

Print Stations Located in 150 Concourse Lobby

Tuesday12:30 pm – 6:30 pm

Expo

Hall B

5:15 pm – 6:30 pm

Expo Social

Hall B

Wednesday10:45 am – 5:15 pm

Expo

Hall B

6:30 pm – 9:30 pm

Networking Reception

Smithsonian National Museum

of Natural History

Download the Esri

Events app and find

your event

Select the session

you attended

Scroll down to

“Survey”

Log in to access the

survey

Complete the survey

and select “Submit”

Please Share Your Feedback in the App

Recommended