8

How do I delete all of the fields from a feature class in a simple way?

I don't want to loop over the fields using the Delete Field tool because this method is very slow in ArcPy.

I am using a polygon feature class, and I tried arcpy.MultipartToSinglepart_management but the feature class result saved all the fields.

PolyGeo
65.5k29 gold badges115 silver badges350 bronze badges
asked Sep 28, 2012 at 8:22
0

2 Answers 2

7

I think you could do this with MakeFeatureLayer on your original feature class, using field_info to "hide" all the fields, followed by CopyFeatures to get the features with no fields in a new feature class.

I investigated to make sure that this would work - and it did. Here are some Python snippets of doing the steps manually to get the syntax right.

arcpy.MakeFeatureLayer_management("C:/avhome/arcGISdata/Exploration.gdb/Samples","Samples_Layer","#","#","OBJECTID OBJECTID HIDDEN NONE;SHAPE SHAPE HIDDEN NONE;Dip_Angle Dip_Angle HIDDEN NONE;Strike Strike HIDDEN NONE;Rock Rock HIDDEN NONE;Description Description HIDDEN NONE")
arcpy.CopyFeatures_management("Samples_Layer","C:/avhome/arcGISdata/Exploration.gdb/SamplesNoAtts","#","0","0","0")

The only attributes on output are OBJECTID and SHAPE.

I wish that the ArcInfo Workstation command PULLITEMS had translated into an ArcGIS Desktop tool perhaps named Pull Fields or Filter Fields.

answered Sep 28, 2012 at 11:20
0
3

You could work around it by creating a new feature class using the geometries of the old one but without the fields. The ArcGIS Resource Center has a section on working with geometry in Python. There' a section on reading and writing geometries that should cover what you need.

answered Sep 28, 2012 at 8:44

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.