Answered step by step
Verified Expert Solution
Question
1 Approved Answer
This is what I have so far. Very confused, obviously no clue what I am doing Download the reference data to C:workspaceGIST315Unit5data. Your task is
This is what I have so far. Very confused, obviously no clue what I am doing
Download the reference data to C:\workspace\GIST315\Unit5\data. Your task is to write a script to write out the X-Y coordinates of each Seaplane Base in Alaska into a file. Your input feature class will be airports.shp in the provided data folder. All your results should be stored in C:\workspace\GIST315\Unit5 esults folder. You may follow these steps to help write your script: 1) Open a file SeaplaneBases.txt in write mode. This file will store all the coordinates of Seaplane bases in Alaska. This file should have three columns to store the ID, X Coordinate, and Y Coordinate separated by spaces. 2) Using the AddField tool, add two fields to airports.shp: LAT & LONG of type DOUBLE. 3) Create an update cursor with a where clause to identify all Seaplane bases in Alaska. Your update cursor should be able to access the following fields: SHAPE@XY, Name, County, LAT, and LONG. a. Use a variable fid to create ids starting at 0 b. Using a for loop to access each seaplane base, perform the following tasks: i. Print out the Name and County associated with the seaplane base. ii. Print out the X and Y coordinates of the seaplane base iii. Update the LAT and LONG fields with the X & Y coordinates iv. Write out the fid, X & Y coordinates in the SeaplaneBases.txt file. Note that each item should be separated by a single space, and each base should be on a new line. v. Increment the variable storing the id #Setup import arcpy from arcpy import env #for cursors from arcpy import da #ALL your results should be stored in C:\workspace GIST315\Unit5 esults folder. env.workspace = "C:/workspace/GIST315/Unit5/results", env.overwriteOutpout = True #Your input feature class will be airports.shp in the provided data folder. in_fc = r"C:/workspace/GIST315/Units/data/airports.shp" #1) Open a file SeaplaneBases.txt in write mode. This file will store all the coordinates of #Seaplane bases in Alaska. This file should have three columns to store the ID, X Coordinate, #and Y Coordinate separated by spaces. log = open("C:/workspace/GIST315/Units/results/SeaplaneBases.txt", 'W') log.write("ID, " ", X Coordinate, " ", Y Coordinate "); #2) Using the AddField tool, add two fields to airports.shp: LAT & LONG of type "DOUBLE. in_table = "C:/workspace/GIST315/Unit5/data/airports.shp", lat field = arcpy.AddField management(in_table, "LAT", "DOUBLE"), long_field = arcpy.AddField_management(in_table, "LONG", "DOUBLE"), #3) Create an update cursor with a where clause to identify all Seaplane bases in Alaska. Your #update cursor should be able to access the following fields: #SHAPE@XY, Name, County, LAT, and LONG. where_clause = """"Seaplane Base " = 'Alaska'""" # Input fields for the search cursor o in_fc_fields = ["SHAPE", "Name", "County", "SHAPE@X", "SHAPE@Y"], o o o o with da.UpdateCursor(in_fc,in_fc_fields) as update_cursor: for row in update_cursor: print(" Shape: {} Name: {} County: {} LAT: {} LONG: {}", format (row[@], row[1], row[2], row[3], row[4])), log.write(" Shape: {} Name: {} County: {} LAT: {} LONG: {}".format(row[@], row[1],row[2], row[3], row[4])) #iv. Write out the fid, X & Y coordinates in the SeaplaneBases.txt file. Note that each #item should be separated by a single space, and each base should be on a new line. #v. Increment the variable storing the id, Download the reference data to C:\workspace\GIST315\Unit5\data. Your task is to write a script to write out the X-Y coordinates of each Seaplane Base in Alaska into a file. Your input feature class will be airports.shp in the provided data folder. All your results should be stored in C:\workspace\GIST315\Unit5 esults folder. You may follow these steps to help write your script: 1) Open a file SeaplaneBases.txt in write mode. This file will store all the coordinates of Seaplane bases in Alaska. This file should have three columns to store the ID, X Coordinate, and Y Coordinate separated by spaces. 2) Using the AddField tool, add two fields to airports.shp: LAT & LONG of type DOUBLE. 3) Create an update cursor with a where clause to identify all Seaplane bases in Alaska. Your update cursor should be able to access the following fields: SHAPE@XY, Name, County, LAT, and LONG. a. Use a variable fid to create ids starting at 0 b. Using a for loop to access each seaplane base, perform the following tasks: i. Print out the Name and County associated with the seaplane base. ii. Print out the X and Y coordinates of the seaplane base iii. Update the LAT and LONG fields with the X & Y coordinates iv. Write out the fid, X & Y coordinates in the SeaplaneBases.txt file. Note that each item should be separated by a single space, and each base should be on a new line. v. Increment the variable storing the id #Setup import arcpy from arcpy import env #for cursors from arcpy import da #ALL your results should be stored in C:\workspace GIST315\Unit5 esults folder. env.workspace = "C:/workspace/GIST315/Unit5/results", env.overwriteOutpout = True #Your input feature class will be airports.shp in the provided data folder. in_fc = r"C:/workspace/GIST315/Units/data/airports.shp" #1) Open a file SeaplaneBases.txt in write mode. This file will store all the coordinates of #Seaplane bases in Alaska. This file should have three columns to store the ID, X Coordinate, #and Y Coordinate separated by spaces. log = open("C:/workspace/GIST315/Units/results/SeaplaneBases.txt", 'W') log.write("ID, " ", X Coordinate, " ", Y Coordinate "); #2) Using the AddField tool, add two fields to airports.shp: LAT & LONG of type "DOUBLE. in_table = "C:/workspace/GIST315/Unit5/data/airports.shp", lat field = arcpy.AddField management(in_table, "LAT", "DOUBLE"), long_field = arcpy.AddField_management(in_table, "LONG", "DOUBLE"), #3) Create an update cursor with a where clause to identify all Seaplane bases in Alaska. Your #update cursor should be able to access the following fields: #SHAPE@XY, Name, County, LAT, and LONG. where_clause = """"Seaplane Base " = 'Alaska'""" # Input fields for the search cursor o in_fc_fields = ["SHAPE", "Name", "County", "SHAPE@X", "SHAPE@Y"], o o o o with da.UpdateCursor(in_fc,in_fc_fields) as update_cursor: for row in update_cursor: print(" Shape: {} Name: {} County: {} LAT: {} LONG: {}", format (row[@], row[1], row[2], row[3], row[4])), log.write(" Shape: {} Name: {} County: {} LAT: {} LONG: {}".format(row[@], row[1],row[2], row[3], row[4])) #iv. Write out the fid, X & Y coordinates in the SeaplaneBases.txt file. Note that each #item should be separated by a single space, and each base should be on a new line. #v. Increment the variable storing the id
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started