Jump to content
Sign in to follow this  
bdsmolla

ArcPy Support

Recommended Posts

I think, this will be good idea to share python codes to learn and get support from the members. Under this post we can do that.

Can anyone help to delete subtype field from a feature class (FC)? Like one FC may have a subtype field with 5 (five) predefined subtypes. How to read and list those five subtype values and remove from the subtype list dynamically and finally delete the field. Just now thought about this. Will work on this to get solution.

Please share your views and post how you learnt Python for customizing ArcGIS Desktop and Server.

Share this post


Link to post
Share on other sites

In 10.0 the solution is very difficult.

First you will be require to identify which field is defined as subtype.

To find that field you can use:

--------------------
urFC = r'C:\Temp\DemoData.gdb\VegA'
fcDescr = arcpy.Describe(urFC)
stFld = fcDescr.subtypeFieldName
print stFld
-------------------

If you run above code in Python Window of ArcGIS Desktop and if the VegA feature class of DemoData.gdb having subtype field will return the field name.

You can not directly delete subtype field, before that you are require to delete its codes and values from the list.

For that, you need to know how many subtype values defined into the Feature Class.

In 10.0, I didn't find any function to list the codes and values, in 10.1 under arcpy.da (data access module there is a function which can be used) for details, visit the link:

http://resources.arcgis.com/en/help/main/10.1/index.html#//018w00000021000000

Finally,

make the list of codes which may like:

----------------------
stList = ["1", "2", "3", "4", "5"]
arcpy.RemoveSubtype_management(urFC, stList)
arcpy.DeleteField_management(urFC, stFld)
----------------------

If you find any problem, let me know

Edited by bdsmolla

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.