overwriteOutput not working in 10.2.2

4874
6
Jump to solution
08-19-2014 03:25 PM
AmyKlug
Occasional Contributor III

Ever since upgrading to 10.2.2 my python code(s) tell me the file already exists and won't overwrite (using CopyFeatures or Copy). In ArcCatalog, I have my geoprocessing options set to overwrite and arcpy.env.overwriteOutput = True in my code.

Anyone know of a solution???

Thanks


EDIT: I am copying one feature class to another to a file geodatabase -> feature dataset. Both feature classes and feature datasets have the same projection. Worked fine in 10.1

EDIT2: It won't overwrite using modelbuilder either. Get "Already exists" error

Tags (2)
0 Kudos
1 Solution

Accepted Solutions
AmyKlug
Occasional Contributor III

After some testing I think with 10.2.2 the feature dataset and the feature class can't have the same name; If they do/you want them to, you have to first delete the feature class then copy in the updated version. 

View solution in original post

6 Replies
BruceHarold
Esri Regular Contributor

I can’t reproduce – a rerun of a tool works:

>>> arcpy.Copy_management(in_data="C:/Temp/DougGolfCourses.gdb/GolfCourses",out_data="C:/Temp/DougGolfCourses.gdb/GolfCourses_Copy",data_type="FeatureClass")

<Result 'C:
Temp
DougGolfCourses.gdb
GolfCourses_Copy'>

>>> arcpy.env.overwriteOutput

True

>>> arcpy.GetInstallInfo()['Version']

u'10.2.2'

>>>

0 Kudos
AmyKlug
Occasional Contributor III

I tried copying a feature class from GDB to GDB and FDS to GDB it worked fine. GDB or FDS to FDS would not overwrite. There seems to be an issue with overwriting a feature class in a feature dataset (FDS).

0 Kudos
XanderBakker
Esri Esteemed Contributor

When I try the code below which copies the source to dest1 and dest2 (featureclass in a feature dataset), it works without any problem in 10.2.2.

import arcpy

arcpy.env.overwriteOutput = True

source = r"C:\Forum\overwrite\source.gdb\myFC"

dest1 = r"C:\Forum\overwrite\dest1.gdb\myFC"

dest2 = r"C:\Forum\overwrite\dest2.gdb\featDS\myFC"

arcpy.Copy_management(in_data=source,out_data=dest1,data_type="FeatureClass")

arcpy.Copy_management(in_data=source,out_data=dest2,data_type="FeatureClass")

The only way I could reproduce this error was trying to write to the dest2 featureclass without using the feature dataset in the path. Like this:

dest2 = r"C:\Forum\overwrite\dest2.gdb\myFC"

Are you sure you are using the output feature dataset in referencing the output featureclass?

Kind regards, Xander

AmyKlug
Occasional Contributor III

After some testing I think with 10.2.2 the feature dataset and the feature class can't have the same name; If they do/you want them to, you have to first delete the feature class then copy in the updated version. 

curtvprice
MVP Esteemed Contributor

Good advice, Amy!

In my experience naming any two objects within in the geodatabase or folder the same can break tools (or your own model or script tool). Layer names and dataset names get duplicated in your memory namespace and bad karma grows...

Like starting names with a number or using spaces in your path, things may work okay at first, but break at the least opportune moment for you.  My advice: learn from the suffering from others and don't tempt fate.

This includes:

  • Feature classes within parallel feature datasets

fc1/features

fc2/features

  • Objects in a folder workspace (with different extensions)

mydata.shp

mydata.tif

mydata (folder)

mydata (Esri grid)

To avoid issues,  everything in a workspace should have a unique name.

GerryGabrisch
Occasional Contributor III

I had the same problem using 10.1 going from tables in a gdb to feature dataset feature classes.  Changing the output to something other than the name of the input table solved my two days of head scratching.  Thanks!

0 Kudos