DOI-USGS / gems-tools-pro

GeMS Tools for ArcGIS Pro
Creative Commons Zero v1.0 Universal
47 stars 15 forks source link

Make Polygons fails to create `errors_{}unlabeledPolys` #22

Open BenjiDa opened 2 years ago

BenjiDa commented 2 years ago

Running the Make Polygon tool appears to fail when trying to create errors_unlabeledPolys, the code seems not to write blankPolys before trying to delete it, but maybe I'm mistaken...

#make blankPolys
addMsgAndPrint('    Making {}'.format(blankPolys))
if arcpy.Exists(badLabels):
    arcpy.CopyFeatures_management(mup, r"in_memory\blankPolys")
    arcpy.DeleteFeatures_management(blankPolys)
    arcpy.Append_management(r"in_memory\blankPolys", blankPolys)
    arcpy.Delete_management(r"in_memory\blankPolys")
else:
    arcpy.CopyFeatures_management(centerPoints2, blankPolys)

error message:

Start Time: Thursday, May 19, 2022 2:06:53 PM
This version of the tool is up to date
GeMS_MakePolys3_AGP2.py, version of 15 January 2020
Making layer view of CAF without concealed lines
Making xxxTempPolys
Making xxxCenterPoints
Deleting centerPoints2 MapUnit = ''
Saving MapUnitPolys
Making oldPolys
Making new MapUnitPolys
Making changedPolys
deleting features with MapUnit = OldMapUnit
0 rows in changedPolys
Finding label errors
Sorting through label points
Making C:\Users\bmelosh\Documents\ArcGIS\Projects\Healdsburg_map\Healdsburg_map_gems.gdb\GeologicMap\errors_multilabelPolys
Making C:\Users\bmelosh\Documents\ArcGIS\Projects\Healdsburg_map\Healdsburg_map_gems.gdb\GeologicMap\errors_unlabeledPolys
Traceback (most recent call last):
  File "C:\Users\bmelosh\Tools\gems-tools-pro-master\Scripts\GeMS_MakePolys3_AGP2.py", line 319, in <module>
    arcpy.DeleteFeatures_management(blankPolys)
  File "C:\ArcGIS\Pro\Resources\ArcPy\arcpy\management.py", line 4241, in DeleteFeatures
    raise e
  File "C:\ArcGIS\Pro\Resources\ArcPy\arcpy\management.py", line 4238, in DeleteFeatures
    retval = convertArcObjectToPythonObject(gp.DeleteFeatures_management(*gp_fixargs((in_features,), True)))
  File "C:\ArcGIS\Pro\Resources\ArcPy\arcpy\geoprocessing\_base.py", line 512, in <lambda>
    return lambda *args: val(*gp_fixargs(args, True))
arcgisscripting.ExecuteError: Failed to execute. Parameters are not valid.
[ERROR 000732:](javascript:void(0);) Input Features: Dataset C:\Users\bmelosh\Documents\ArcGIS\Projects\Healdsburg_map\Healdsburg_map_gems.gdb\GeologicMap\errors_unlabeledPolys does not exist or is not supported
Failed to execute (DeleteFeatures).
Failed script Make Polygons...
Failed to execute (MakePolys).
Failed at Thursday, May 19, 2022 2:10:39 PM (Elapsed Time: 3 minutes 45 seconds)
ethoms-usgs commented 2 years ago

It worked for me after I changed if arcpy.Exists(badLabels): to if arcpy.Exists(blankPolys): , but I will try to clean some other parts up a bit before posting a new version.

If you get other errors, try deleting all of the errors_ and edit_ feature classes..

Also, while the new MapUnits might get properly written to the geodatabase, the MapUnits layer in the map won't display the new features until you pan and zoom. And/or go the layer properties > Cache and click Clear Cache.

BenjiDa commented 2 years ago

Okay, thanks, I tried that but the MapUnits are not being written to the geodatabase so I figured that wasn't the solution. Running the code piece by piece I notice that the MapUnits are written to a file called xxxCenterPoints2 but somehow they are not written to the final MapUnitPolys feature class. I will continue to trying to fiddle with this. If it worked for you maybe it is something in my data structure that is off.