31
Kimberly McCarty Python: Map Automation in ArcGIS Pro Beyond The Basics

Python: Map Automation in ArcGIS Pro Beyond The Basics...Python CIM Access in Pro (released with Pro 2.4) •CIM (Cartographic Information Model)-Specification for how project and

  • Upload
    others

  • View
    16

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Python: Map Automation in ArcGIS Pro Beyond The Basics...Python CIM Access in Pro (released with Pro 2.4) •CIM (Cartographic Information Model)-Specification for how project and

Kimberly McCarty

Python:

Map Automation in ArcGIS Pro

Beyond The Basics

Page 2: Python: Map Automation in ArcGIS Pro Beyond The Basics...Python CIM Access in Pro (released with Pro 2.4) •CIM (Cartographic Information Model)-Specification for how project and

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

Page 3: Python: Map Automation in ArcGIS Pro Beyond The Basics...Python CIM Access in Pro (released with Pro 2.4) •CIM (Cartographic Information Model)-Specification for how project and

arcpy.(m)a(p)ping samples

http://esriurl.com/8899

Page 4: Python: Map Automation in ArcGIS Pro Beyond The Basics...Python CIM Access in Pro (released with Pro 2.4) •CIM (Cartographic Information Model)-Specification for how project and

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

Page 5: Python: Map Automation in ArcGIS Pro Beyond The Basics...Python CIM Access in Pro (released with Pro 2.4) •CIM (Cartographic Information Model)-Specification for how project and

Sharing Maps

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

Page 6: Python: Map Automation in ArcGIS Pro Beyond The Basics...Python CIM Access in Pro (released with Pro 2.4) •CIM (Cartographic Information Model)-Specification for how project and

Demo

Publish To

Standalone Server

Page 7: Python: Map Automation in ArcGIS Pro Beyond The Basics...Python CIM Access in Pro (released with Pro 2.4) •CIM (Cartographic Information Model)-Specification for how project and

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

Page 8: Python: Map Automation in ArcGIS Pro Beyond The Basics...Python CIM Access in Pro (released with Pro 2.4) •CIM (Cartographic Information Model)-Specification for how project and
Page 9: Python: Map Automation in ArcGIS Pro Beyond The Basics...Python CIM Access in Pro (released with Pro 2.4) •CIM (Cartographic Information Model)-Specification for how project and

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

Page 10: Python: Map Automation in ArcGIS Pro Beyond The Basics...Python CIM Access in Pro (released with Pro 2.4) •CIM (Cartographic Information Model)-Specification for how project and

Cartographic Information

Model - CIM

Page 11: Python: Map Automation in ArcGIS Pro Beyond The Basics...Python CIM Access in Pro (released with Pro 2.4) •CIM (Cartographic Information Model)-Specification for how project and

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

Page 12: Python: Map Automation in ArcGIS Pro Beyond The Basics...Python CIM Access in Pro (released with Pro 2.4) •CIM (Cartographic Information Model)-Specification for how project and

Show CIM -

Renderer

Page 13: Python: Map Automation in ArcGIS Pro Beyond The Basics...Python CIM Access in Pro (released with Pro 2.4) •CIM (Cartographic Information Model)-Specification for how project and

CIM-Version & Renderer Sample

1

1 2

2

3

3

4

4

Level 1

Level 2

5

5

6

6

Page 14: Python: Map Automation in ArcGIS Pro Beyond The Basics...Python CIM Access in Pro (released with Pro 2.4) •CIM (Cartographic Information Model)-Specification for how project and

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

Page 15: Python: Map Automation in ArcGIS Pro Beyond The Basics...Python CIM Access in Pro (released with Pro 2.4) •CIM (Cartographic Information Model)-Specification for how project and

Basic workflow

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

### Do something to the CIM object

Object.setDefinition(cim_obj)

* Object = Map, Layer, Table or Layout

Page 16: Python: Map Automation in ArcGIS Pro Beyond The Basics...Python CIM Access in Pro (released with Pro 2.4) •CIM (Cartographic Information Model)-Specification for how project and

Simple Samples

working with CIM

Page 17: Python: Map Automation in ArcGIS Pro Beyond The Basics...Python CIM Access in Pro (released with Pro 2.4) •CIM (Cartographic Information Model)-Specification for how project and

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

Page 18: Python: Map Automation in ArcGIS Pro Beyond The Basics...Python CIM Access in Pro (released with Pro 2.4) •CIM (Cartographic Information Model)-Specification for how project and

Modify Symbology

Page 19: Python: Map Automation in ArcGIS Pro Beyond The Basics...Python CIM Access in Pro (released with Pro 2.4) •CIM (Cartographic Information Model)-Specification for how project and

Modify Symbology

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

Page 20: Python: Map Automation in ArcGIS Pro Beyond The Basics...Python CIM Access in Pro (released with Pro 2.4) •CIM (Cartographic Information Model)-Specification for how project and

Modify Chart

Page 21: Python: Map Automation in ArcGIS Pro Beyond The Basics...Python CIM Access in Pro (released with Pro 2.4) •CIM (Cartographic Information Model)-Specification for how project and

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

Page 22: Python: Map Automation in ArcGIS Pro Beyond The Basics...Python CIM Access in Pro (released with Pro 2.4) •CIM (Cartographic Information Model)-Specification for how project and

Modify Layout

Page 23: Python: Map Automation in ArcGIS Pro Beyond The Basics...Python CIM Access in Pro (released with Pro 2.4) •CIM (Cartographic Information Model)-Specification for how project and

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

Page 24: Python: Map Automation in ArcGIS Pro Beyond The Basics...Python CIM Access in Pro (released with Pro 2.4) •CIM (Cartographic Information Model)-Specification for how project and

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

Page 25: Python: Map Automation in ArcGIS Pro Beyond The Basics...Python CIM Access in Pro (released with Pro 2.4) •CIM (Cartographic Information Model)-Specification for how project and
Page 26: Python: Map Automation in ArcGIS Pro Beyond The Basics...Python CIM Access in Pro (released with Pro 2.4) •CIM (Cartographic Information Model)-Specification for how project and

CIM Repo

• Getting started with the CIM

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

Page 27: Python: Map Automation in ArcGIS Pro Beyond The Basics...Python CIM Access in Pro (released with Pro 2.4) •CIM (Cartographic Information Model)-Specification for how project and

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/

Page 28: Python: Map Automation in ArcGIS Pro Beyond The Basics...Python CIM Access in Pro (released with Pro 2.4) •CIM (Cartographic Information Model)-Specification for how project and

Questions?

Page 29: Python: Map Automation in ArcGIS Pro Beyond The Basics...Python CIM Access in Pro (released with Pro 2.4) •CIM (Cartographic Information Model)-Specification for how project and

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

Page 30: Python: Map Automation in ArcGIS Pro Beyond The Basics...Python CIM Access in Pro (released with Pro 2.4) •CIM (Cartographic Information Model)-Specification for how project and

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

Page 31: Python: Map Automation in ArcGIS Pro Beyond The Basics...Python CIM Access in Pro (released with Pro 2.4) •CIM (Cartographic Information Model)-Specification for how project and