Question

In: Computer Science

Create a geoprocessing tool from the .py file included (script from this file included below). Use...

Create a geoprocessing tool from the .py file included (script from this file included below).

Use any csv file you would like. I will work around that.

This is for a programming for GIS class. We work with jupyter, idle, arcgis pro

import os
import arcpy
from arcpy import env

input_table = r"C:\Answers\January2018.CSV"
output_fc = r"C:\Answers\crime.gdb\January2018_Crime"
spRef = arcpy.SpatialReference("NAD 1983 StatePlane Missouri East FIPS 2401 (US Feet)")

gdb_name = os.path.dirname(output_fc)
fc_name = os.path.basename(output_fc)

env.overwriteOutput = True

print("Creating File GDB")
arcpy.CreateFileGDB_management(os.path.dirname(gdb_name),
os.path.basename(gdb_name))

##Create table from csv file
print(gdb_name)
print("Converting CSV to GDB Table")
arcpy.TableToTable_conversion(input_table, "in_memory", "temp", "", "", "")

##Make XY events layer
events_layer = "crime_points"
print("Make FC Layer")
arcpy.MakeXYEventLayer_management("in_memory/temp", "xcoord", "ycoord", events_layer, "", "")

##Output events layer to feature class
print("FC to FC")
arcpy.FeatureClassToFeatureClass_conversion(events_layer, gdb_name, fc_name, "", "", "")

##Define projection
print("Defining Projection.")
arcpy.DefineProjection_management(output_fc, spRef)

print("Done.")

Solutions

Expert Solution

import os
import arcpy
from arcpy import env

input_table = r"C:\Answers\January2018.CSV"
output_fc = r"C:\Answers\crime.gdb\January2018_Crime"
spRef = arcpy.SpatialReference("NAD 1983 StatePlane Missouri East FIPS 2401 (US Feet)")

gdb_name = os.path.dirname(output_fc)
fc_name = os.path.basename(output_fc)

env.overwriteOutput = True

print("Creating File GDB")
arcpy.CreateFileGDB_management(os.path.dirname(gdb_name),
os.path.basename(gdb_name))

##Create table from csv file
print(gdb_name)
print("Converting CSV to GDB Table")
arcpy.TableToTable_conversion(input_table, "in_memory", "temp", "", "", "")

##Make XY events layer
events_layer = "crime_points"
print("Make FC Layer")
arcpy.MakeXYEventLayer_management("in_memory/temp", "xcoord", "ycoord", events_layer, "", "")

##Output events layer to feature class
print("FC to FC")
arcpy.FeatureClassToFeatureClass_conversion(events_layer, gdb_name, fc_name, "", "", "")

##Define projection
print("Defining Projection.")
arcpy.DefineProjection_management(output_fc, spRef)

print("Done.")


Related Solutions

Use Vi text editor or ATOM to create a bash script file. Use the file name...
Use Vi text editor or ATOM to create a bash script file. Use the file name ayaan.sh. The script when ran it will execute the following commands all at once as script. Test your script file make sure it works. Here is the list of actions the script will do: It will create the following directory structure data2/new2/mondaynews off your home directory. inside the mondaynews, create 4 files sports.txt, baseball.txt, file1.txt and file2.txt. Make sure file1.txt and file2.txt are hidden...
how to create a script file on puTTy script pp1.txt
how to create a script file on puTTy script pp1.txt
Demonstrate the use of CRUNCH tool to create a Wordlist file to generate a minimum and...
Demonstrate the use of CRUNCH tool to create a Wordlist file to generate a minimum and maximum word length (2-9) based on your MIT ID and the first seven numbers and two unique special characters, and store the result in file pass.txt. Give an exampleof two generated passwords with length of three characters, one number and one special character. After that, use the HYDRA attacking tool to attack ftp://192.168.1.3 server which has the username ‘tom’ and password length between 2...
Create a bash script file named assessment-script-a that: 1. Accepts any number of file names on...
Create a bash script file named assessment-script-a that: 1. Accepts any number of file names on the command line 2. For each file name provided, delete any line that contains the string: qwe.rty When the changes are completed, the script should display the total number of files scanned, and the total number of files changed. Example Command: assessment-script-a file.a file.b file.c file.d file.e    Example Output: 5 files scanned, 3 files changed 3. Your script should include a series of...
In PowerShell ISE create a script. Use the text file “its3410Users.txt” (found on Canvas) and import...
In PowerShell ISE create a script. Use the text file “its3410Users.txt” (found on Canvas) and import the users into your domain controller. The user file has a first name, last name, and department. Using this information, create users with the following specifications: Username will be first name.last name User Principal Name will be first name.last [email protected] The department signifies the OU that the user will be placed into If the department does not exist, create it Fill in the first...
Using Python Shell 2.7, create a file called Assignment6_1.py Create an array based on a basic...
Using Python Shell 2.7, create a file called Assignment6_1.py Create an array based on a basic array Create a for loop that will print the array index the array, print out the index append an element to the array, print out the array insert an element into the array, print out the array pop an element from the array, print out the array remove an element from the array, print out the array reverse the order of the array, print...
Create a MATLAB script file to determine the given function is continuous or discontinuous at given...
Create a MATLAB script file to determine the given function is continuous or discontinuous at given interval (points).
Record your daily intake for 4 weeks. Use the template below (also included as file) or...
Record your daily intake for 4 weeks. Use the template below (also included as file) or you may create your own. The log should be initiated at the start of the course and end at the conclusion of the course. You will notice a trend in your daily habits. This assignment will allow you to: Become more accountable for your eating habits Identify your motivation for eating Focus on your nutritional requirements Know your food triggers, such as for pinpointing...
Using Python create a script called create_notes_drs.py. In the file, define and call a function called...
Using Python create a script called create_notes_drs.py. In the file, define and call a function called main that does the following: Creates a directory called CyberSecurity-Notes in the current working directory Within the CyberSecurity-Notes directory, creates 24 sub-directories (sub-folders), called Week 1, Week 2, Week 3, and so on until up through Week 24 Within each week directory, create 3 sub-directories, called Day 1, Day 2, and Day 3 Bonus Challenge: Add a conditional statement to abort the script if...
Use CYGWIN TERMINAL to create this script. COPY AND PASTE the screenshot. Script 1: 1.   Perform...
Use CYGWIN TERMINAL to create this script. COPY AND PASTE the screenshot. Script 1: 1.   Perform a ls -al on the files within the user's home directory and save it to a file called ls.dat within your ~ directory 2.   Save the tree information for the /home directory in a file called tree.dat within your ~directory 3.   Create a new directory in your home directory called "backups" 4.   Move the files you just created to the new directory 5.   Rename...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT