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
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
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.
Hello Asrujit,
I am having the same problem as Daniel, and I do not have an option of moving over to a python solution. It seems that there shold be a model builder solution. Maybe this is a bug? Or something in my settings? I've closed windows explorer, arcCatalog, and arcMap, then re-opened arcMap and validated my model and it still shows up as a white circle (not abnle to run) with the same error message.
Is there another way to triple check that ther eis no schema lock?
Any other ideas?
Thanks,
John
Looks like I am going to go that route. Thanks. The solution is posted here
I get the warning error 000258 name already used when I attempt to run the model again to check that it works
Like this:
Oh, I see. If you use FeatureClass to Geodatabase (multiple) it doesn't overwrite.
I would use Feaure Class to Feature Class tool and iterators to convert all the shapefiles.
The DB is not locked
just in case...The data in that Feature Dataset should not have Locks on them, when you are replacing them.
Thanks but I have that option checked already. No luck
Liza that is not a batch function unfortunately.
Enable the 'Overwrite the outputs of geoprocessing operations" option on Geoprocessing Options and then try.
When I convert shapefile to feature class in the geodatabase, I use Feaure Class to Feature Class tool and it does overwrite by default. Did you try and it didn't overwrite?
Lisa
Signed in members can post, follow updates, and more. New here? Register a free account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.