import arcpy g = arcpy.Geometry() geoList = arcpy.Dissolve_management(r'C:\Data\ArcGIS\TemplateData.gdb\USA\states', g) arcpy.CopyFeatures_management(geoList, r'C:\Data\ArcGIS\TemplateData.gdb\USA\statesDiss")
line_geom = arcpy.Geometry() lines = arcpy.Dissolve_management(newline, line_geom) upstream.append(lines[0])
[<Polyline object at 0x107918d0[0x104daaa0]>, <Polyline object at 0xbebd770[0x104ce278]>, <Polyline object at 0xbdf6cf0[0xba9c980]>, <Polyline object at 0xbe0e750[0x104dad58]>, <Polyline object at 0x573d770[0x104ce338]>]
for i in range (0, len(upstream)): ln = upstream arcpy.CopyFeatures_management(ln, "line" +str(i))
upstream =[] # for each sampling site a polyline shall be added to this list (one stream contains several branches that are dissolved to one polyline with the dissolve tool in the end) # do for each sampling site: for streamsegment_list in sampling_list: lineList = [] # for each branch a polyline shall be added to this list # do for each branch of the actual stream: for segmentlist in streamsegment_list: # streamsegment_list contains the points for all branches of one stream, segmentlist gives one branch pointList = arcpy.Array() # the points for one branch of the stream-polyline shall be added to this list # do for each point of the actual branch: for segment in segmentlist: # segmentlist gives one branch of the stream, segment is an object that contains the x/y coordinates PS_pt = arcpy.Point(segment.firstx, segment.firsty) #firstx and firsty contain the coordinates for the points pointList.add(PS_pt) # add the point to the list ln = arcpy.Polyline(pointList) # make a polyline out of the pointlist (one branch) lineList.append(ln) # append this polyline to the linelist ln = None line_geom = arcpy.Geometry() lines = arcpy.Dissolve_management(lineList, line_geom) # dissolve the branches of one stream to one polyline upstream.append(lines[0]) # append this polyline to the upstream-list # make a new geodatabase feature class for the streams: arcpy.CopyFeatures_management(upstream, "streams")
# make a new geodatabase feature class for the streams: for i in range (0, len(upstream)): ln = upstream arcpy.CopyFeatures_management(ln, "line" +str(i)) arcpy.CopyFeatures_management(upstream, "streams")
for g in upstream: print "Min X: {0}, Min Y: {1}, Max X: {2}, Max Y: {3}".format(g.extent.XMIN, g.extent.YMIN, g.extent.XMax, g.extent.YMax)