Arcpy 更新三维数据高程
import arcpy infc = arcpy.GetParameterAsText(0) outfc= arcpy.GetParameterAsText(1) h=arcpy.GetParameter(2) arcpy.analysis.Select(infc, outfc, '') cursor=arcpy.da.UpdateCursor(outfc, ["OID@", "SHAPE@"]) for row in cursor: partnum = 0 row1_new= arcpy.Array() for part in row[1]: part_new=arcpy.Array() for pnt in part: if pnt: point_new =arcpy.Point(pnt.X,pnt.Y,pnt.Z+h) part_new.append(point_new) print("{}, {}".format(pnt.X, pnt.Y)) else: print("Interior Ring:") row1_new.append(part_new) rowl_new_polyline = arcpy.Polyline(row1_new,has_z= True) row[1] =rowl_new_polyline cursor.updateRow(row) partnum += 1 del cursor
import arcpy infc = arcpy.GetParameterAsText(0) outfc= arcpy.GetParameterAsText(1) h=arcpy.GetParameter(2) arcpy.AddMessage("=={}, {},{}".format(infc, outfc,h)) arcpy.analysis.Select(infc, outfc, '1=2') cursor = arcpy.da.InsertCursor(outfc, ["SHAPE@"]) with arcpy.da.SearchCursor(infc, ["OID@", "SHAPE@"]) as qcursor: for row in qcursor: partnum = 0 row1_line= arcpy.Array() for part in row[1]: linearr=arcpy.Array() for pnt in part: if pnt: arcpy.AddMessage("{}, {},{}".format(pnt.X, pnt.Y,pnt.Z)) point_new =arcpy.Point(pnt.X,pnt.Y,pnt.Z+h) linearr.append(point_new) n=linearr.count p1=linearr[n-1] arcpy.AddMessage("kkk={}, {},{}".format(p1.X, p1.Y,p1.Z)) else: print("Interior Ring:") arcpy.AddMessage("Interior Ring:") row1_line.append(linearr) new_polyine = arcpy.Polyline(row1_line,has_z= True) cursor.insertRow([new_polyine]) partnum += 1