OverWriteOutput not actually overwriting

485
2
11-21-2013 10:42 AM
RichardHughes3
New Contributor III
Hi,

So I am running a Simplify Line tool in the Python Window and my geoprocessing environment setting in ArcMap is set to overwrite outputs True.  I am able to overwrite outputs and do it a lot when cranking out data. 

I am re-running the Simplify Line and want to overwrite an existing feature class in a file geodatabase.  The python windows runs

arcpy.SimplifyLine_cartography(r"Landbase Layer\Infrastructure\Roads selection",r"C:\ESRI WORK FOLDER\Landbase\4- California\Siskiyou Landbase\Landbase Geodatabase\Siskiyou_Landbase.gdb\Infrastructure\LocalRoads_Simplified_50ft","POINT_REMOVE",50,"RESOLVE_ERRORS","KEEP_COLLAPSED_POINTS","CHECK")

Pretty straightforward.  When I add the results to the mapdocument, the changes I made are not contained in the attribute table as if it were never overwritten. 

Next I delete the feature classes from the database and rerun the same script.  My results then do show the change. 

Where does the problem exist?  and how can I remedy this?  If I were to run a larger script and had this issue happen, it would be a really drag. 

Thanks,

Richard
Tags (2)
0 Kudos
2 Replies
markdenil
Regular Contributor II
One is best advised to deliberatly delete an existing feature class rather than expecting the Overwrite environment setting to ensure that it is removed prior to an attempted write. The environment setting basically just alows overwriting, it does not force it.

A three line subroutine:

def whaka(mole):
    if arcpy.Exists(mole):
        arcpy.Delete_management(mole)

saves a whole lot of heartache.
0 Kudos
MichaelVolz
Esteemed Contributor
One caveat to the DeleteManagement method would be if the feature class is being used as a datasource for ArcGIS Server which would put locks on the feature class.

If that is the case I would use a DeleteRows and Append to accomplish the same goal.
0 Kudos