I have a feature with polylines and want to get the midpoint of every line. Following pything script I found here works great:
import arcpy, math, datetime, numpy
print ("starting")
start = datetime.datetime.now() # for calculating time of process
#setting the containers
midpoint = #put your file to be populated in here, make sure it already exists
polyline = #put your polyline file in here
#housekeeping
arcpy.DeleteFeatures_management(midpoint)
arcpy.env.overwriteOutput = True
#generating the mid point
with arcpy.da.SearchCursor(polyline, "SHAPE@") as in_cursor, \
arcpy.da.InsertCursor(midpoint, "SHAPE@") as out_cursor:
for row in in_cursor:
midpoint = row[0].positionAlongLine(0.50,True).firstPoint
out_cursor.insertRow([midpoint])
#tidy up
del rows, row, updateRows_midpoint, outRow, out_cursor, midpoint, polyline
print "Done in ",datetime.datetime.now() - start, " seconds"
But, all the rest of the attributes are lost. Only the Geometry is written into the new feature. I'm aware why, but I don't know how to do it.
How do I get them into the midpoint-feature?
Can it be done in the for-loop?