import arcpy #Next 4 lines must be edited to correspond to your data and directories. fc = r"Database Connections\GDB_HMS.sde\GDB_HMS.HMSADMIN.rdsmall_arc" #original dataset path shortName = "rdsmall_arc" #a simplified dataset name (without "." characters found in our SDE dataset names) fipsField = "FIPS" #name of the field that is used to subdivide dataset outputFolder = r"V:\Projects\Shared\kalley\Documentation\rdsmall" #folder path where shape files should go fipsList = sorted(set([code[0] for code in arcpy.da.SearchCursor(fc, fipsField)])) #creates a sorted list of unique fips codes in dataset for fipsCode in fipsList: outputName = "{0}_{1}".format(shortName, str(fipsCode)) #new filename will look like shortName_fipsCode.shp query = "{0} = {1}".format(fipsField, str(fipsCode)) #assumes fipsCode is an integer arcpy.FeatureClassToFeatureClass_conversion(fc, outputFolder, outputName, query) arcpy.AddMessage("Created {0}\n".format(outputName))
Hi Kerry,
Thanks for the quick response. Not being a Python script writer, I'll need some more code, please. First, the fips code field in both the sde and related table is a string field. I now have a "state" field (string) in the look-up table so I'll need those extra 4 lines of code you mentioned. For the connection to SDE, here is what the Instance field reads under Layer Properties, "sde:oracle$sde:oracle11g:LANDP.xcelenergy.com". Looks different than yours.
Any assistance would be appreciated!
Jim
Hi Jim,
The paths do help. It isn't clear to me, however, exactly what information is in your lookup table or how you want to use it. For example, does the lookup table identify which fips codes belong to which state? If so, how? Is every fips code listed in one field, with another field providing the name of the state the code belongs to? Will each shape file correspond to a single or multiple fips codes? I would need to understand these kinds of relationships between relevant fields, and to know the names of the fields, in order to incorporate the lookup table into the script.
Kerry
Kerry,
The information in the lookup table identifys all 87 unique fips codes for Minnesota but the feature class of parcel data includes other states so that's why there is a state field in the lookup table as well, all with MN as the attribute. So yes, every fips listed in one field and another field with state abbrev (MN), see attached table. Each exported shapefile should correspond to a single fips code. Also, the path to the SDE layer is as follows: Database Connections\LAND_P.sde
The feature class is called: PARCELS.PARCELS
Hope this all helps!
Jim