- Focus on ArcPy, not scripting
- Go back to Jupyter notebooks
- Ditch things you can do with spatial dataframes
- More on raster calculations
- Why learn ArcPy??
Proficiencies
-
Extending Python
- Conda/Pip
- ArcPy, Pandas, GeoPandas, ArcGIS API
-
ArcPy
- Using geoprocessing tools
- Classes & Functions
- Modules
ArcGIS Python Libraries
https://www.esri.com/en-us/arcgis/products/arcgis-python-libraries/libraries/arcpy
https://pro.arcgis.com/en/pro-app/latest/arcpy/get-started/installing-python-for-arcgis-pro.htm
Uses
- Automating workflows
- More control over execution
- Extending analyses
- Python = glue
ArcPy
https://pro.arcgis.com/en/pro-app/latest/arcpy/get-started/what-is-arcpy-.htm
Much finer control of tool execution
- Tool usage & results
- Exercise: Run a tool
- Exercise: Run a workflow
- Environment settings
- Function
- Classes
- Modules
- Toolbox
- Helpers
- Charts
- Data Access
- Image Analysis
4.1 Intro to ArcPy
Jupyter notebooks in ArcGIS Pro
- Access to layers in map
- Tool autofill & getting other help
- Converting history to Python
- WHAT DOES ARCPY DO? WHY USEFUL?
ArcPy - an overview
- Geoprocessing tools
- Additional functions and classes
- Links to other Python libraries
GIS Workflows with ArcPy
- LiDAR fetching tool
- [Other tools I’ve created? MaxEnt? GeoHAT?]
- Demos with ArcGIS API
Section Outline: Hurricane Mapping tool
- First a notebook, then a script tool
- Flow of a notebook: packages, data [paths], processing, results
- Notebook to script
- Script to tool
4.2 Hurricane Tracking in Jupyter
4.2.1 - Setup
- Project folder structure
- Notebook creation and front matter
- Packages
- Data
- Relative paths!
4.2.2 Processes
- Select
- Point to line
- Select by location
- Copy features
4.2.3
- Add variables
- Widgets!
4.3 Creating a script based tool
4.3.1 Notebook to script|Noteboook vs script
- Code cells to script sections
4.3.2 Adding a script based tool to ArcGIS Pro
- Parameters
GetParameterAsText
- Environments
- Messages
Lab: Hurricane Tracker - Revisited
Jupyter Notebook (in ArcGIS Pro vs separate)
- Markdown - describe workflow
- Import packages
- Set data paths [
pathlib
]- Input
- Output
- Set variables
- Process 1: Select records [
ArcPy
] - Process 2: Point to Line
- Process 3: Select counties that intersect the track
Embellishments
- Summarize output: pyArrow
- Create chart
- Widgets to select input & output
- Need to create lists: all years, and storm for a given year
Ideas
- User puts in a range of years, create plot of # of people affected by year (by state)
Python Script tool
- Jupyter -> Python
- Add tool to ArcGIS Pro
- Inputs:
GetParameterAsText()
- Outputs:
SetParameterAsText()
Assignment - ArcGIS Pro tool
Goals
- Run a geoprocessing workflow in a notebook
- Relative path to data
- Use dynamic inputs
Scenario
- Malaria case rates for provinces in Loreto, Peru from 2000-2020
- Specify a province, year range, and a buffer distance
- Compute the mean case rate
- Create a plot of weekly malaria case rates for the selected province
- Identify all provinces within the buffer distance of the selected province
- Compute mean case rate and compare to that of the selected province
Additional ArcPy topics