Geographic Information Systems Asked by Yuzhen on June 22, 2021
I was trying to merge stream lines from many HUC polygons into one. Currently these stream lines are stored in one geodatabase as separate feature classes with each feature class corresponding to one HUC polygon. It’s polyline feature and all lines have exactly the same attributes. All feature classes have the same schema.
I gave several tries by using arcpy.Merge_management() and arcpy_Append_management(), all ended up only merging several HUCs, but not all. (see the attached picture: try to merge stream lines from all green polygons, but only got stream lines from several upper polygons merged). I also tried to repair geometry first before merge, define extent before merge.., none of these seem to fix the issue.
Still new to python, anything I missed? I use ArcMap 10.7.1. Here is the code I tried:
fcList = arcpy.ListFeatureClasses("D:/test.gdb")
arcpy.Merge_management(fcList, "D:/output.gdb/merged")
emptyFC="merged"
schemaType="NO_TEST"
fieldMapping=""
subtype=""
template="example"
spatial_reference=arcpy.Describe(template).spatialReference
has_m="DISABLED"
has_z="DISABLED"
try:
arcpy.CreateFeatureclass_management(outWorkspace, emptyFC, "POLYLINE", template, has_m, has_z, spatial_reference)
listFC=arcpy.ListFeatureClasses("", "POLYLINE")
arcpy.Append_management(listFC, outWorkspace+os.sep+emptyFC, schemaType, fieldMapping, subtype)
except Exception as err:
print(err.args[0])
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP