Python: Map Automation with ArcGIS Pro...New at Pro. The entire layer data source object model is...
Transcript of Python: Map Automation with ArcGIS Pro...New at Pro. The entire layer data source object model is...
Python: Map Automation withArcGIS ProGerhard Trichtl
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
Python within ArcGIS ProPython is “embedded” within ArcGIS Pro
- Python Window
- GP Tools (Script tools)- GP Tools with Python requirement
(Field Calculator)- Advanced Labeling
Tour of arcpy.mapping / arcpy.mp
• Overview
sada ga mapping/mp
arcpy
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
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
Demo
ImportingDocuments
Demo Source Code
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
Updating Data Sources – Improvements
1. Changing a folder
2. Changing FGDB to SDE
3. Changing PGDB to FGDB
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.
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
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
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.
Demo
UpdatingDatasources
Updating Data Sources – demo source code
DEMO
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
DemoUpdate Symbology
Sample to Update Symbology – demo source code
Demo
Publish HostedService
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
Demo
Publish ToStandalone Server
Publish to Standalone ArcGIS Server – demo source code
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
Questions?
Thank You to Our Sponsors
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”