Python: Map Automation with ArcGIS Pro...New at Pro. The entire layer data source object model is...

30
Python: Map Automation with ArcGIS Pro Gerhard Trichtl

Transcript of Python: Map Automation with ArcGIS Pro...New at Pro. The entire layer data source object model is...

Page 1: Python: Map Automation with ArcGIS Pro...New at Pro. The entire layer data source object model is exposed as a Python dictionary. Use if you need more fine grained control than what’s

Python: Map Automation withArcGIS ProGerhard Trichtl

Page 2: Python: Map Automation with ArcGIS Pro...New at Pro. The entire layer data source object model is exposed as a Python dictionary. Use if you need more fine grained control than what’s

Session Contents

• Python in ArcGIS Pro• Language changes between 2x and 3x• Converting your scripts from ArcGIS for Desktop to

ArcGIS Pro• API changes

- arcpy.mapping > arcpy.mp

Page 3: Python: Map Automation with ArcGIS Pro...New at Pro. The entire layer data source object model is exposed as a Python dictionary. Use if you need more fine grained control than what’s

Python within ArcGIS ProPython is “embedded” within ArcGIS Pro

- Python Window

- GP Tools (Script tools)- GP Tools with Python requirement

(Field Calculator)- Advanced Labeling

Page 4: Python: Map Automation with ArcGIS Pro...New at Pro. The entire layer data source object model is exposed as a Python dictionary. Use if you need more fine grained control than what’s

Tour of arcpy.mapping / arcpy.mp

• Overview

sada ga mapping/mp

arcpy

Page 5: Python: Map Automation with ArcGIS Pro...New at Pro. The entire layer data source object model is exposed as a Python dictionary. Use if you need more fine grained control than what’s

arcpy.(m)a(p)ping samples

http://esriurl.com/8899

Page 6: Python: Map Automation with ArcGIS Pro...New at Pro. The entire layer data source object model is exposed as a Python dictionary. Use if you need more fine grained control than what’s

Migrating to ArcGIS Pro

http://esriurl.com/9785

Page 7: Python: Map Automation with ArcGIS Pro...New at Pro. The entire layer data source object model is exposed as a Python dictionary. Use if you need more fine grained control than what’s

Language Changes between 2x and 3x: Highlights- Printing

- print >>> print()- Division

- Float is know returned- Dictionaries

- {}.iteritems >>> {}.items- Miscellaneous

- raw_input() >>> input()- range() >>> range object

- Related modules are now packages:- urllib, urllib2, urlparse >>> urllib- pep-3108

- https://docs.python.org/3/whatsnew/3.0.html

Page 8: Python: Map Automation with ArcGIS Pro...New at Pro. The entire layer data source object model is exposed as a Python dictionary. Use if you need more fine grained control than what’s

Function to Import 8.x/9.x/10.x documents into ArcGISProjects

• ArcGISProject.importDocument (document_path, {include_layout})

.MXDsArcGIS Pro

Projects

Looping through MXDs in a folder.

Reference a template APRX.Import MXD into the APRX.Save the project.

DEMO

Page 9: Python: Map Automation with ArcGIS Pro...New at Pro. The entire layer data source object model is exposed as a Python dictionary. Use if you need more fine grained control than what’s

Demo

ImportingDocuments

Page 10: Python: Map Automation with ArcGIS Pro...New at Pro. The entire layer data source object model is exposed as a Python dictionary. Use if you need more fine grained control than what’s

Demo Source Code

Page 11: Python: Map Automation with ArcGIS Pro...New at Pro. The entire layer data source object model is exposed as a Python dictionary. Use if you need more fine grained control than what’s

Updating Data Sources – improvements at Pro

Project/Map/Layer/Table/LayerFile.updateConnectionProperties (current_connection_info, new_connection_info, {auto_update_joins_and_relates}, {validate})

Find this path:

Replace it with this path:

.APRXs

Page 12: Python: Map Automation with ArcGIS Pro...New at Pro. The entire layer data source object model is exposed as a Python dictionary. Use if you need more fine grained control than what’s

Updating Data Sources – Improvements

1. Changing a folder

2. Changing FGDB to SDE

3. Changing PGDB to FGDB

Page 13: Python: Map Automation with ArcGIS Pro...New at Pro. The entire layer data source object model is exposed as a Python dictionary. Use if you need more fine grained control than what’s

Updating Data Sources advanced concepts – Layer.connectionProperties

• New at Pro • The entire layer data source object model is exposed as a Python dictionary.• Use if you need more fine grained control than what’s available in

Project/Map/Layer/Table/LayerFile.updateConnectionproperties()• Useful when dealing with joins and relates or Enterprise Geodatabase

Access a layer in a map.

File Geodatabase layer connection properties dictionary

Get layer’s connection properties.

Page 14: Python: Map Automation with ArcGIS Pro...New at Pro. The entire layer data source object model is exposed as a Python dictionary. Use if you need more fine grained control than what’s

Updating Data Sources advanced concepts – Layer.connectionProperties• File Geodatabase layer connection Properties (with joins and relates)• It gets complicated!

Layer’s database

List of relates on the layer

Relate properties

Page 15: Python: Map Automation with ArcGIS Pro...New at Pro. The entire layer data source object model is exposed as a Python dictionary. Use if you need more fine grained control than what’s

Updating Data Sources advanced concepts – Layer.connectionProperties• Two ways to use the connection properties dictionary

1. Write directly to the dictionary

2. UpdateConnectionProperties will also do find and replace for full and partial dictionaries

Access a layer in a map.Get it’s connection properties.

Update connection properties dictionary.

Find this dictionary key/value pair.

Replace it with this key/value pair

Page 16: Python: Map Automation with ArcGIS Pro...New at Pro. The entire layer data source object model is exposed as a Python dictionary. Use if you need more fine grained control than what’s

Updating Data Sources advanced concepts – Layer.connectionProperties• Enterprise Geodatabase examples – change instance or server

Enterprise Geodatabase connection properties dictionary

Old database info

New database info

Update connection properties for project

Get layer’s connection properties.

Page 17: Python: Map Automation with ArcGIS Pro...New at Pro. The entire layer data source object model is exposed as a Python dictionary. Use if you need more fine grained control than what’s

Demo

UpdatingDatasources

Page 18: Python: Map Automation with ArcGIS Pro...New at Pro. The entire layer data source object model is exposed as a Python dictionary. Use if you need more fine grained control than what’s

Updating Data Sources – demo source code

DEMO

Page 19: Python: Map Automation with ArcGIS Pro...New at Pro. The entire layer data source object model is exposed as a Python dictionary. Use if you need more fine grained control than what’s

Layer

Symbology

Simple

UniqueValue

GraduatedColor

GraduatedSymbol

SymbolClassBreak

Group Item

ColorRamp

.symbology

.renderer / .updateRenderer

Renderer

.symbol

.classBreaks

.backgroundSymbol

.symbolTemplate

.groups .items.colorRamp

.symbol

.symbol

.applySymbolFromGallery()

Symbology Model

Page 20: Python: Map Automation with ArcGIS Pro...New at Pro. The entire layer data source object model is exposed as a Python dictionary. Use if you need more fine grained control than what’s

DemoUpdate Symbology

Page 21: Python: Map Automation with ArcGIS Pro...New at Pro. The entire layer data source object model is exposed as a Python dictionary. Use if you need more fine grained control than what’s

Sample to Update Symbology – demo source code

Page 22: Python: Map Automation with ArcGIS Pro...New at Pro. The entire layer data source object model is exposed as a Python dictionary. Use if you need more fine grained control than what’s

Demo

Publish HostedService

Page 23: Python: Map Automation with ArcGIS Pro...New at Pro. The entire layer data source object model is exposed as a Python dictionary. Use if you need more fine grained control than what’s

Publish Hosted Feature Service

• CreateWebLayerSDDraft would be used to create a ServiceDefinitionFile (SD)• See details of parameter in

http://pro.arcgis.com/en/pro-app/arcpy/mapping/createweblayersddraft.htm

Page 24: Python: Map Automation with ArcGIS Pro...New at Pro. The entire layer data source object model is exposed as a Python dictionary. Use if you need more fine grained control than what’s

Demo

Publish ToStandalone Server

Page 25: Python: Map Automation with ArcGIS Pro...New at Pro. The entire layer data source object model is exposed as a Python dictionary. Use if you need more fine grained control than what’s

Publish to Standalone ArcGIS Server – demo source code

Page 26: Python: Map Automation with ArcGIS Pro...New at Pro. The entire layer data source object model is exposed as a Python dictionary. Use if you need more fine grained control than what’s

Publish To Standalone Server – comming with 2.3

• Publishing ArcGIS Pro Maps directly to ArcGIS Server• Target to Support ArcGIS Server 10.4+

- Symbology/Mapping functioned based on the ArcGIS Pro-Version which is in the Server included

ArcGIS Server Version Included ArcGIS Pro Runtime10.4 1.2

10.4.1 1.310.5 1.4

10.5.1 2.010.6 2.1

10.6.1 2.2

Page 27: Python: Map Automation with ArcGIS Pro...New at Pro. The entire layer data source object model is exposed as a Python dictionary. Use if you need more fine grained control than what’s

Questions?

Page 28: Python: Map Automation with ArcGIS Pro...New at Pro. The entire layer data source object model is exposed as a Python dictionary. Use if you need more fine grained control than what’s

Thank You to Our Sponsors

Page 29: Python: Map Automation with ArcGIS Pro...New at Pro. The entire layer data source object model is exposed as a Python dictionary. Use if you need more fine grained control than what’s

Please Take Our Survey!

Download the Esri Events app and go to DevSummit

Select the session you attended

Scroll down to the “Feedback” section

Complete Answers,add a Comment,

and Select “Submit”

Page 30: Python: Map Automation with ArcGIS Pro...New at Pro. The entire layer data source object model is exposed as a Python dictionary. Use if you need more fine grained control than what’s