Professional Documents
Culture Documents
#Goal: To write a python script to create a point feature class from an (x, y) text file and assign the
appropriate spatial reference system to it.
import os
import shutil
import arcpy
inputFolder = r"C:\temp\d2RawData"
outputFolder = r"C:\temp\bariyaND2ProcData"
if os.path.exists (outputFolder):
shutil.rmtree(outputFolder)
if not os.path.exists(outputFolder):
os.makedirs(outputFolder)
arcpy.env.workspace = inputFolder
arcpy.env.overwriteOutput = True
list = arcpy.ListFiles("*.txt")
#set a for loop for textfile in list
#a new point layer is created using x and y data as defined in raw data
layer = "tempLayer"
spRef = arcpy.SpatialReference(26917)
arcpy.CopyFeatures_management(layer, shapeFile)
arcpy.env.workspace = outputFolder
shapeList = arcpy.ListFeatureClasses("*.shp")
newShape = "npFarm.shp"
arcpy.Merge_management(shapeList, newShape)
arcpy.MakeFeatureLayer_management("npFarm.shp", "newLayer")
count = int(output.getOutput(0))
print "There are " + str(count) + " farms in the vicinity of the extent"
arcpy.Delete_management("newLayer")