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

Python Create a Python script file called hw3.py. Ex. 1. Write a program that inputs numbers...
Python Create a Python script file called hw3.py. Ex. 1. Write a program that inputs numbers from the user until they enter a 0 and computes the product of all these numbers and outputs it. Hint: use the example from the slides where we compute the sum of a list of numbers, but initialize the variable holding the product to 1 instead of 0. print("Enter n") n = int(input()) min = n while n != 0: if n < min:...
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...
Use fork() Create a program that reads characters from an input file. Use fork to create...
Use fork() Create a program that reads characters from an input file. Use fork to create parent and child processes. The parent process reads the input file. The input file only has letters, numbers. The parent process calculates and prints the frequency of the symbols in the message, creates the child processes, then prints the information once the child processes complete their execution. The child processes receives the information from the parent, generates the code of the assigned symbol by...
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...
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).
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT