Skip to content

Instantly share code, notes, and snippets.

@morehavoc
Created December 12, 2014 16:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save morehavoc/3e86f535bf204b040ee2 to your computer and use it in GitHub Desktop.
Save morehavoc/3e86f535bf204b040ee2 to your computer and use it in GitHub Desktop.
Remove those pesky Shape_Length__ and Shape_Area__fields
print "Importing arcpy"
import arcpy
from os.path import join
workspace = r"path to .sde connection here"
fields_to_remove = ["Shape_STLength__", "Shape_STArea__"]
arcpy.env.workspace = workspace
print "Listing Feature Classes"
layers= arcpy.ListFeatureClasses()
for layer in layers:
print "Processing {}".format(layer)
layer_path = join(workspace, layer)
fields = [f.name for f in arcpy.ListFields(layer_path)]
for field in fields_to_remove:
if field in fields:
print " Removing {}".format(field)
try:
arcpy.DeleteField_management(layer_path, field)
except Exception as e:
print e
pass
print "Complete"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment