I've created an XY Event Layer, and now I want to copy that to a shape file. It works fine on the first iteration, but crashes on the second iteration. What seems odd, when looking in my geodatabase, the first shapefile is not named correctly; it is just called "shp", but I'm trying to name it "Data_20130626.shp". Is there a problem in my naming syntax for ShapeName?Thanks for any help you can provide!Jon Mulder# Set the workspace.
env.workspace = "G:\Documents\GIS\HydstraData"
arcpy.env.overwriteOutput = True
## Set the Spatial Reference.
Spatial_Reference = "PROJCS['NAD_1983_California_Teale_Albers',GEOGCS['GCS_North_American_1983',DATUM['D_North_American_1983',SPHEROID['GRS_1980',6378137.0,298.257222101]],PRIMEM['Greenwich',0.0],UNIT['Degree',0.0174532925199433]],PROJECTION['Albers'],PARAMETER['False_Easting',0.0],PARAMETER['False_Northing',-4000000.0],PARAMETER['Central_Meridian',-120.0],PARAMETER['Standard_Parallel_1',34.0],PARAMETER['Standard_Parallel_2',40.5],PARAMETER['Latitude_Of_Origin',0.0],UNIT['Meter',1.0]]"
OutFolderPath = env.workspace
OutName = "tempgdb.gdb"
##Check if geodatabase exists.
if arcpy.Exists(OutName):
##Delete geodatabase.
arcpy.Delete_management(OutName)
##Create geodatabase.
arcpy.CreateFileGDB_management(OutFolderPath,OutName)
DateStart = date(2013,6,25)
DateEnd = date(2013,6,26)
for dt in rrule(DAILY, dtstart=DateStart, until=DateEnd):
CurrentDate = dt.strftime("%Y%m%d")
print CurrentDate
##Create Point Shapefile from spreadsheet.
InSpreadsheet = "G:\Documents\GIS\HydstraData\HydstraMeasurementsDeep\HydstraMeasurements_" + CurrentDate + ".XLS"
X_Coords = "LONGITUDE"
Y_Coords = "LATITUDE"
Z_Coords = "MeanData"
TableName = os.path.join(OutFolderPath,OutName,"Data_" + CurrentDate)
print TableName
LayerName = os.path.join(OutFolderPath,OutName,"Data_" + CurrentDate + ".lyr")
print LayerName
ShapeName = os.path.join(OutFolderPath,OutName,"Data_" + CurrentDate + ".shp")
print ShapeName
arcpy.ExcelToTable_conversion(InSpreadsheet,TableName)
arcpy.MakeXYEventLayer_management(TableName,X_Coords,Y_Coords,LayerName,"",Z_Coords)
arcpy.CopyFeatures_management(LayerName,ShapeName)
print "Completed."
===Outout in Python Shell================================20130625G:\Documents\GIS\HydstraData\tempgdb.gdb\Data_20130625G:\Documents\GIS\HydstraData\tempgdb.gdb\Data_20130625.lyrG:\Documents\GIS\HydstraData\tempgdb.gdb\Data_20130625.shp20130626G:\Documents\GIS\HydstraData\tempgdb.gdb\Data_20130626G:\Documents\GIS\HydstraData\tempgdb.gdb\Data_20130626.lyrG:\Documents\GIS\HydstraData\tempgdb.gdb\Data_20130626.shpTraceback (most recent call last): File "G:\Documents\GIS\HydstraData\CreateATinFromPoints_Mulder_20131212.py", line 55, in <module> arcpy.CopyFeatures_management(LayerName,ShapeName) File "C:\Program Files (x86)\ArcGIS\Desktop10.2\arcpy\arcpy\management.py", line 2281, in CopyFeatures raise eExecuteError: ERROR 000210: Cannot create output G:\Documents\GIS\HydstraData\tempgdb.gdb\Data_20130626.shpFailed to execute (CopyFeatures).