python

python

Lab exercise 03 | Geography 376 | Spring 2017 Controlling the flow of program execution The main goal of this lab is to practice control of flow using IF ELIF ELSE

statements and to combine the use of previously explored, and new ArcPy functions. Submitting lab 3 assignment: Your submission for lab 3 will include the code you

will develop in Python. Please name your file lab03_yourname.py (e.g., lab03_mckenzie.py). Submit your files to Canvas by the specified date and time (see Canvas

for due date). The main goal for this assignment is to practice controlling the flow of your program, i.e. being able to execute the specific functions based on

certain conditions. Your main goal is to bring all of your datasets into a common projection so that you can then analyze the data. Only one of your datasets is

projected into an actual equal area projection. The other datasets are either in the lat/lon reference system or are missing the projection file all together

(unfortunately this kind of thing happens all the time in the real world). Once you are able to get everything into the same projection and reference system, you will

be able to carry out the analysis to answer the following questions (all should be printed out on the screen and accompanied by a descriptive message in the order they

appear below): 1. How many active fires were detected in tundra? 2. How many active fires were detected in taiga? 3. How many active fires per burn scar were detected

on average in Interior Alaska? 4. How many active fires per burn scar were detected on average in tundra? 5. How many active fires per burn scar were detected on

average in taiga? The output of your lab3 script should look like this (but with appropriate values instead of XXX):
XXX active fires were detected in tundra. XXX active fires were detected in taiga. XXX active fires per burn scare were detected on average in Interior Alaska. XXX

active fires per burn scare were detected on average in tundra. XXX active fires per burn scare were detected on average in taiga.
Your input data can be found in folder lab03_data, downloadable as a zip from Canvas. The folder contains: 1. A shapefile with 2004 active fire detections for

Interior Alaska (the only projected dataset): 2004_af.shp 2. A shapefile with 2004 burned area perimeters for Interior Alaska: 2004perimeters.shp
3. Two shapefiles for tundra and taiga zones of Interior Alaska: AK_tundra.shp and AK_taiga.shp Below are some general guidelines for the implementation (Note that

these are NOT step-by-step instructions): 1. You will need an understanding of the ArcPy functions you employed in previous labs to be able to complete this

assignment. Look back at the previous tasks and your solutions. 2. Download and extract the data for Lab03 from Canvas. 3. Keep checking subcomponents of your code in

ArcGIS window: don’t try to write everything out first and debug later. Focus on working out small details as you go: e.g., “If I phrase the IF ELSE statement this

way, will it work or am I asking the wrong question?” Test, test, test… Then you’ll spend a lot less time debugging. 4. Set up a variable to hold the path to your

working folder at the beginning of the script. And use the variable when you need to define the name of input and output files. For example, if your input resides in

C:GEOG376mckenzielab032004_af.shp, you would set a variable “path” (you can name it whatever you want but this is a good descriptive name similar to): >>> path =

“C:/GEOG376/mckenzie/lab03/” >>> af = “2004_af” And then you would concatenate the variable with the file name as a parameter within the command: >>> desc_af =

arcpy.Describe(path+af+’.shp’) 5. First, you will need to figure out which datasets are missing projections and which are in lat/lon (Hint: that will be your testing

bit for the IF ELIF ELSE structure) and then assign a particular set of steps for execution depending on what type of projection or lack thereof the dataset has. Hint:

if arcpy.Describe(path+af+’.shp’).spatialReference.Name == “Unknown”: 6. When converting from lat/lon system

(i.e. GCS projection) use the following transformation method “WGS_1984_(ITRF00)_To_NAD_1983” within your Project_management function (check the help files for help on

how to implement this). 7. The datasets with missing projection file are actually projected into the proper reference system, therefore, you only need to define the

projection for these data using the spatial reference object of the properly projected data (2004_af.shp). Hint: Use the DefineProjection_management function.
8. To compute the answers to the questions, you will need to use Clip and GetCount functions (both were used in lab02). For example, you know how many active fire

detections per scar on average there were, but you need to count the records (i.e. active fires) in the active fire file and assign it to variable 1, count the number

of records (i.e. scars) in the perimeters file and assign it to variable 2, and then divide variable one by variable 2 (make sure you avoid an integer division error).

To find the answers for those in taiga and tundra, you need to limit each of your datasets to the extent of the taiga and tundra files (that’s where clip comes in).

9. Print out descriptive messages to the screen either using a comma or concatenating string with a plus sign. 10.Make sure you carefully add comments to your code

(header – see your previous lab- and in-line commenting). A script that is uncommented will receive a grade of “0” for this lab (comments are very important).

find the cost of your paper