0

I've updated the code with the suggestions in the code but still not working.

arcpy.env.workspace = r'F:\EGM722 - Customising GIS apps\Assignment\folklore.gdb'
arcpy.env.overwriteOutput = True
arcpy.Delete_management('folklore_shape.shp')
#arcpy.Delete_management(r'F:\EGM722 - Customising GIS apps\Assignment\folklore_shape.shp')
arcpy.MakeXYEventLayer_management('Folklore', 'x_coord', 'y_coord', 'folklore_Layer', "PROJCS['IRENET95_Irish_Transverse_Mercator',GEOGCS['GCS_IRENET95',DATUM['D_IRENET95',SPHEROID['GRS_1980',6378137.0,298.257222101]],PRIMEM['Greenwich',0.0],UNIT['Degree',0.0174532925199433]],PROJECTION['Transverse_Mercator'],PARAMETER['False_Easting',600000.0],PARAMETER['False_Northing',750000.0],PARAMETER['Central_Meridian',-8.0],PARAMETER['Scale_Factor',0.99982],PARAMETER['Latitude_Of_Origin',53.5],UNIT['Meter',1.0]];-5022200 -15179500 10000;-100000 10000;-100000 10000;0.001;0.001;0.001;IsHighPrecision", '#')
arcpy.FeatureClassToFeatureClass_conversion("folklore_Layer", "F:\EGM722 - Customising GIS apps\Assignment", "Folkore_shape.shp")

I've tried arcpy.Delete_management('folklore_shape.shp') and arcpy.Delete_management(r'F:\EGM722 - Customising GIS apps\Assignment\folklore_shape.shp')

Getting error;

Exception in Tkinter callback
Traceback (most recent call last):
  File "C:\Python27\ArcGIS10.5\lib\lib-tk\Tkinter.py", line 1542, in __call__
    return self.func(*args)
  File "F:\EGM722 - Customising GIS apps\Assignment\folklore - 22-04-18 - diff_folder.py", line 132, in new_record
    arcpy.FeatureClassToFeatureClass_conversion("folklore_Layer", "F:\EGM722 - Customising GIS apps\Assignment", "Folkore_shape.shp")
  File "C:\Program Files (x86)\ArcGIS\Desktop10.5\ArcPy\arcpy\conversion.py", line 1891, in FeatureClassToFeatureClass
    raise e
ExecuteError: ERROR 000258: Output F:\EGM722 - Customising GIS apps\Assignment\Folkore_shape.shp already exists
Failed to execute (FeatureClassToFeatureClass).

Creating the event layer works it is the delete part that isn't working.

  • Your code is creating a feature class in a geodatabase where as you are trying to delete a shapefile in the folder where the geodatabase is located. – jbosq Apr 24 '18 at 19:08
  • arcpy.env.overwriteOutput = True – Emil Brundage Apr 24 '18 at 19:31
  • Also don't forget your raw string: arcpy.FeatureClassToFeatureClass_conversion("folklore_Layer", r"F:\MyProject\Assignment", "folklore_shp") – Emil Brundage Apr 24 '18 at 19:32
  • Does it work if you set arcpy.env.workspace = r'C:\temp'? If not, does it work if you use a code snippet that does not involve Tkinter? – PolyGeo Apr 29 '18 at 21:29
2

You have a typo in this part of your code:

if arcpy.Exists(r'F:\MyProject\Assignment\folkore_shp.shp'):
   arcpy.Delete_management(r'F:\MyProject\Assignment\folkore_shp.shp')

folklore is misspelled.

Fix:

if arcpy.Exists(r'F:\MyProject\Assignment\folklore_shp.shp'):
   arcpy.Delete_management(r'F:\MyProject\Assignment\folklore_shp.shp')

Also, as commented:

arcpy.env.overwriteOutput = True

And don't forget your raw string for folder paths (or anything with a backslash):

arcpy.FeatureClassToFeatureClass_conversion("folklore_Layer", r"F:\MyProject\Assignment", "folklore_shp")

0

You say:

If I don't comment out arcpy.env.workspace.overwriteOutput = True I get:

arcpy.env.workspace.overwriteOutput = True AttributeError: 'unicode' object has no attribute 'overwriteOutput'

This is because the code should be:

arcpy.env.overwriteOutput = True

not:

arcpy.env.workspace.overwriteOutput = True
  • 1
    Think you meant: arcpy.env.overwriteOutput rather than workspace. – dslamb Apr 25 '18 at 12:45
  • Thanks @dslamb - I had edited out the wrong bit - corrected now. – PolyGeo Apr 25 '18 at 19:57
  • Hi Folks sorry for delay in getting back, I've looked at all comment but this still isn't working. – Dakan_GIS Apr 29 '18 at 14:27
  • I've updated code above – Dakan_GIS Apr 29 '18 at 14:29
  • This is working now. The code was working, I think it was to do with locks on the shape file. – Dakan_GIS Apr 30 '18 at 8:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.