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 ?
1 Answer
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 Commented Apr 9, 2014 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. Commented Apr 10, 2014 at 6:06
-
I've allredy did it -gis.stackexchange.com/questions/92545/… Commented Apr 10, 2014 at 6:09
-
-
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 Commented Aug 1, 2017 at 14:36