python: beyond the basics - esri...python: beyond the basics, 2016 esri federal gis...

Post on 14-Jul-2020

11 Views

Category:

Documents

0 Downloads

Preview:

Click to see full reader

TRANSCRIPT

Python: Beyond the BasicsCarl Eichenberger

February 24–25, 2016 | Washington, DC

FedGIS Conference

Agenda

• Perform non-GIS and GIS functions in a script tool• Data Access Module: Cursors• Geometries• Hot spot analysis• Mapping Module

Scenario

Create a script tool that performs an Optimized Hotspot Analysis from values originating from a CSV file, add the results of the hotspot analysis to a MXD, and export the MXD to a PDF. This tool will use core Python functions (from Python CSV module) and GIS functions from the ArcPy site package.

Script Workflow

Define parameters for script tool

• Import modules (CSV and arcpy)• arcpy.GetParameterAsText()• Begin with index position 0

Create points from CSV file

• CSV reader object (Python CSV module)- Read coordinates from each row of CSV

• Working with cursors and geometries- Add coordinates to arcpy.Point() object- arcpy.da.InsertCursor()

- Create a new row- Add point object into shape field

Run Optimized Hot Spot Analysis tool

Two hot spot analysis options• Hot Spot Analysis (Getis-Ord Gi*)• Optimized Hot Spot Analysis (new at 10.2) Hot spot vs density• Density shows where features are concentrated• Hot spot identifies spatial clusters statistically

Modify MXD and export to PDF

• arcpy.mapping moduleInventory map documents

Update or repair layer data sources

Update layer symbology

Update or change layout elements

Save a map document to a previous version of ArcGIS

Update map document metadata

Export map contents

Create a map book series in PDF

DemoRun script tool

Resources

• Accessing data with cursors: http://desktop.arcgis.com/en/desktop/latest/analyze/python/data-access-using-cursors.htm

• Working with geometries: http://desktop.arcgis.com/en/desktop/latest/analyze/python/reading-geometries.htm

http://desktop.arcgis.com/en/desktop/latest/analyze/python/writing-geometries.htm• Mapping module: http://desktop.arcgis.com/en/desktop/latest/analyze/arcpy-

mapping/introduction-to-arcpy-mapping.htm• Error Handling: http://desktop.arcgis.com/en/arcmap/latest/analyze/python/error-

handling-with-python.htm

Resources

• Extra info based off of questions

64-bit Background Geoprocessing (If you are processing lots of data)http://desktop.arcgis.com/en/arcmap/latest/analyze/executing-tools/64bit-background.htmWorking with Oracle databaseshttp://cx-oracle.sourceforge.net/index.html

top related