You are on page 1of 1

# Created by Shannon Graup # February 12, 2014 # GISC9307 D2 Create point feature class # Make a layer file from

XY text file, then convert from a layer into shapefile and merge shapefiles together import arcpy import os from arcpy import env env.overwriteOutput = True # Set environment env.workspace = "C:/GraupSGISC9307D2/d2CreatePointFeatureclass/d2RawData" #env.workspace = "H:/9307Python/Assignment2/GraupSGISC9307D2/d2CreatePointFeatureclass/d2RawData" for file in arcpy.ListFiles(): if file.endswith(".txt"): try: # Set the variables for input file, x and y coordinates and output files layername = os.path.splitext(file) output = layername[0] x_coordinates = "EastingM" y_coordinates = "NorthingM" # Set the spatial reference spatial_Ref = "Coordinate Systems/Projected Coordinate Systems/Utm/Nad 1983/NAD 1983 UTM Zone 17N.prj" # Make the XY event layer for both shapefiles using earlier defined variables arcpy.MakeXYEventLayer_management(file, x_coordinates, y_coordinates, output, spatial_Ref) # Set variables for conversion to shapefile #OutputLocation = "H:/9307Python/Assignment2/GraupSGISC9307D2/d2CreatePointFeatureclass" OutputLocation = "C:/GraupSGISC9307D2/d2CreatePointFeatureclass" # Convert feature layer into a shapefile and specify output location arcpy.FeatureClassToShapefile_conversion(output, OutputLocation) # Print completion message stating where output file has been saved print "Your XY shapefile has been created in " + "(" + OutputLocation + ")" except: # Print error message if one occured print arcpy.GetMessages()

You might also like