I have a model that converts shape files to a feature dataset in an existing database. I would like to either overwrite the existing feature classes in the db or delete them and perform the conversion. Which method is the most efficient and how do I do it?
v10.2
Solved! Go to Solution.
I was using 10.2, my issue was related to Arcpy .
My geoprocessing overwrite was already checked, too, but my solution was to check the security settings on my output folder structure; fixed the overwrite issues.
Hi there!
First off, let me just say that I feel your pain. This was (just) one of the limitations of ModelBuilder that eventually led me to embrace Python/arcpy as my solution of choice. If you're willing to go that route, you can export to a python script by editing the model and going to the Model menu > Export > to Python script. (Edit: seems like you're already aware of how to do this.)
From there, you have a couple of options. Option 1 is to set the overwriteOutput environment on your script by typing:
arcpy.env.overwriteOutput = True
at the beginning, but after importing the arcpy module.
If this fails to overwrite, you may employ a test for the existence of the feature class that you want to overwrite and if it does exist, delete it before running your conversion tool of choice. It would likely look something similar to:
# Iterate through your shapfiles with a for loop for shp in shapefiles_to_convert: # Get the input to the conversion tool in_shp = shp # Get the feature dataset where your tool will output output_featureDataset = r"path_to_feature_dataset" # Get the base name of your output feature class output_name = arcpy.Describe(shp).baseName # Test to see if the output feature class already exists if arcpy.Exists(output_featureDataset + "\\" + output_name): # Delete it if it does arcpy.Delete_management(output_featureDataset + "\\" + output_name) # Run the conversion tool arcpy.FeatureClassToFeatureClass_conversion(shp, output_featureDataset, output_name)
I hope you find a solution to your problem!
Warm Regards,
Micah Babinski
Looks like I am going to go that route. Thanks. The solution is posted here