When working with TIGER line shp data at county level scale the labeling of roads, rivers, railroads, etc. is cumbersome due to all of the tiny line segments. Merging the dozens of segments that comprise a particular road or river will result in much cleaner labeling. The only problem is the amount of tedious work this requires. Anyone know of a Python script that will automate this process? It needs to find all records with the same name and merge them into one record. I thought ET Geowizards had a tool for this but can't seem to locate it.
If the Dissolve tool suggested in my comment doesn't work this shouldn't be too big a hassle to script.
- Get a python list of all unique values in FULLNAME (potentially through use of SearchCursor)
- Loop through your FULLNAME to create a whereClause
- Use the whereClause in the Select Tool to create a temporary layer for each unique FULLNAME
- Merge all of the layers together (they'll already have the same schema)
If there is a computational bottleneck you might run into the same problem as with the Dissolve tool. You can always break your data into chunks to make it more managable.
# Location for temporary files output = r'...' tigerFile = r'...' finalProduct = r'...' # Limiting the cursor to only the field you need increases efficiency fullNameValues = arcpy.SearchCursor(tigerFile, '', '', 'FULLNAME') for name in fullNameValues: # Check if name is already in the list if name.FULLNAME in fullNameList: continue else: fullNameList.append(name.FULLNAME) del name, fullNameValues # Loop through list of unique values for i in range(0, len(fullNameList)): whereClause = '"FULLNAME" = ' + "'" + fullNameList[i] + "'" arcpy.Select_management(inFile, output + fullNameList[i], whereClause) # Merge all of the temporary files tempFileList =  #Set workspace for listFiles method arcpy.env.workspace = output for file in arcpy.ListFiles('*.shp'): tempFileList.append(output + "\\" + file) arcpy.Merge_management (tempFileList, finalProduct)