I have imported North American wildfire incident data a comma delimited text file containing one line for each fire incident. Each fire incident has a latitude, longitude coordinate pair separated by commas along with a confidence value.
My first task was to create a shapefile, and make the data usable to import into the attribute table of the shapefile I created called Incidents.
My new task is to repeat this process in a new shapefile within my MDB. The shapefile is called NewFires by user input. My issue is that when I run the code a second time, I get the error:
Traceback (most recent call last): File "C:\Program Files (x86)\Wing IDE 101 4.1\src\debug\tserver_sandbox.py", line 29, in
File "C:\Program Files (x86)\ArcGIS\Desktop10.3\arcpy\arcpy\management.py", line 1807, in CreateFeatureclass raise e arcgisscripting.ExecuteError: ERROR 000354: The name contains invalid characters Failed to execute (CreateFeatureclass).
My second shapefile starts with 'if 'Confidence' in fire:'
import arcpy work = raw_input("Enter the full path of WildlandFires.mdb: ") # C:\Scripts\Lab 7 Data\WildlandFires.mdb arcpy.env.workspace = work # Set the workspace to the geodatabase arcpy.env.overwriteOutput = True iFile = raw_input("Enter the full path of wildfire text file: ")# input text file C:\Scripts\Lab 7 Data\NorthAmericaWildfires_2007275.txt output = raw_input("Enter the name of the output feature class: ") f = open(iFile, 'r')# input text file C:\Scripts\Lab 7 Data\NorthAmericaWildfires_2007275.txt in "read" mode lstFires = f.readlines() # Read the lines of fire data from the input file f.close() # close the file fields = ["SHAPE@", "CONFIDENCE"] # represents the field names for each row in the feature class # Process: Create Feature Class arcpy.CreateFeatureclass_management(work, "Incidents.shp", "POINT", "C:\\Scripts\\Lab 7 Data\\WildlandFires.mdb\\FireIncidents") cursor = arcpy.da.InsertCursor("Incidents.shp", fields) # add the new points that you will create to the "FireIncidents" feature class cntr = 0 # counter variable for fire in lstFires: if 'Latitude' in fire: # Skip the header continue pnt = arcpy.Point() # Create a new Point object lstValues = fire.split(',') # create a list of values "lstValues" based on the type of delimiter str_int = lstValues [-3:] str_int = list(map(float, str_int)) #turns string to integers latitude = str_int # Latitude longitude = str_int # Longitude confid = str_int # Confidence Value pnt.X = longitude # Assign the X and Y properties of the Point object pnt.Y = latitude if 'Confidence' in fire: # Skip the header continue output = arcpy.Point() # Create a new Point Object arcpy.CreateFeatureclass_management(work, "NewFires", "POINT", "'C:\\Scripts\\Lab 7 Data\\Incidents.shp'") arcpy.AddField_management(NewFires_shp, "CONFIVALUE", "FLOAT") field = ["SHAPE@", "CONFIDENCE"] # represents the field names for each row in the feature class row = [pnt, confid] # Create a new row for the feature class cursor.insertRow(row) # Insert the new row to the feature class cntr = cntr + 1 # update the counter print "Record # " + str(cntr) + " written to feature class" del cursor # release the cursor lock on the feature class