2

I need to convert entire geodatebase into shp files.One of the layers have 30 subtypes. I want and maintain the subtype data. Is there a way to Automatically populate the name of the subtype (Transfer subtype Descriptions)in to a new string field in order to not do it manually and not lussing the subtype data ?

4

I am not aware of any GP tool that would do that. However, I do this thing quite often by using a tiny procedure written in Python with ArcPy. I usually create a text field ("desc" in this case) in a feature class which has a subtype and then run UpdateCursor to write the description of the subtype code for each feature (the field used for subtype is "Typecode" in this case). After that, one can export a feature class to shapefile and this text field of course will be preserved as is.

This should work fine in 10.1 SP1 +.

import arcpy

fc = r"C:\Program Files (x86)\ArcGIS\ArcTutor\BuildingaGeodatabase\Montgomery.gdb\Water\Fittings"

# Create a dictionary of subtype codes and descriptions.
desc_lu = {key: value['Name'] for (key, value) in arcpy.da.ListSubtypes(fc).iteritems()}
with arcpy.da.UpdateCursor(fc, ["Typecode","desc"]) as cur:
    for row in cur:
        row[1] = (desc_lu[row[0]])
        cur.updateRow(row)

More information on using arcpy.da.ListSubtypes.

  • Thanks Alexey, How can write a loop that will update the domain description in a new text field ? Thanks allredy- Geog – Geog Apr 9 '14 at 18:52
  • 1
    @Geog, glad to help. Would you please start a separate question for that and describe the goal? It would be easier. – Alex Tereshenkov Apr 10 '14 at 6:06
  • I've allredy did it -gis.stackexchange.com/questions/92545/… – Geog Apr 10 '14 at 6:09
  • Great, I've answered it. – Alex Tereshenkov Apr 10 '14 at 7:53
  • wouldnt you use index [0]? tecnically row [0] is the header but that cant be edited by update cursor no? I havent tested this just curious – NULL.Dude Aug 1 '17 at 14:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.