Quiz: Python in ArcGIS Pro
1 Calculation of August precipitation 30-year normal in North Carolina
In this quiz, you want to analyze the zonal mean of August precipitation 30-year normal in North Carolina using nc_spm_08_grass7_exercise.zip. You will use two Shapefiles in this ZIP file:
- precip_30ynormals.shp: Point Shapefile with precipitation 30-year normals; Use the 
augfield for August precipitation - boundary_county.shp: Polygon Shapefile with county boundaries; Use the 
NAMEfield for zonal statistics 
The procedure is simple.
- Create Thiessen polygons from point precipitation data for August.
 - Convert the precipitation Thiessen polygons to raster.
 - Calculate the mean zonal statistics of the precipitation for each county.
 
Since this class is a programming class, I don’t accept any output files. Please submit three Python scripts in FirstLastname_quiz1.zip.
2 Penalties
Filenames: -2 each (total up to -8)
- FirstLastname
_quiz1.zipshould containthiessen.pypolygon_to_raster.pyzonal_stats.pythiessen_zonal_stats.py(optional for 10 bonus points)
 
Debugging: -3 per line added, removed, or edited
- Hard-coded arguments (marked by * in each question) will be debugged!
 
3 Question 1: Thiessen polygons
Create a Python script called thiessen.py that executes the Create Thiessen Polygons tool. You may use precip_30ynormals.shp as input.
Requirements:
- Filename: 
thiessen.py - Tool parameters:
- Input Features*: precip_30ynormals.shp
 - Output Feature Class*: precip_thiessen.shp
 - Output Fields: All fields
 
 - Two arguments from the command line (marked by * above)
 - Usage:
python thiessen.py precip_30ynormals.shp .\precip_thiessen.shp 
4 Question 2: Polygon to raster
Create a Python script called polygon_to_raster.py that executes the Polygon to Raster tool. You may use the output from thiessen.py as input.
Requirements:
- Filename: 
polygon_to_raster.py - Tool parameters:
- Input Features*: precip_thiessen.shp
 - Value field*: aug
 - Output Raster Dataset*: precip_aug.tif
 - Cell assignment type: Cell center
 - Priority field: NONE
 - Cellsize*: 30
 
 - Four arguments from the command line (marked by * above)
 - Usage:
python polygon_to_raster.py precip_thiessen.shp aug .\precip_aug.tif 30 
5 Question 3: Zonal statistics
Create a Python script called zonal_stats.py that executes the Zonal Statistics tool. You may use boundary_county.shp and the output from polygon_to_raster.py as input.
Requirements:
- Filename: 
zonal_stats.py - Tool parameters:
- Input raster or feature zone data*: boundary_county.shp
 - Zone field*: NAME
 - Input value raster*: precip_aug.tif
 - Output raster*: precip_aug_county.tif
 - Statistics type*: Mean
 
 - Five arguments from the command line (marked by * above)
 - Usage:
python zonal_stats.py boundary_county.shp NAME precip_aug.tif .\precip_aug_county.tif Mean 
6 Bonus question: Combined script
10 points
Combine the three Python scripts into one script file called thiessen_zonal_stats.py.
Requirements:
- Filename: 
thiessen_zonal_stats.py - Arguments
- Point data feature class
 - Output Thiessen polygon feature class
 - Data field
 - Output Thiessen raster
 - Cell size
 - Polygon zone feature class
 - Zone name field
 - Statistics type
 - Output zonal statistics raster
 
 - Usage:
python thiessen_zonal_stats.py precip_30ynormals.shp .\precip_thiessen.shp aug .\precip_aug.tif 30 boundary_county.shp NAME Mean .\precip_aug_county.tif