import arcpy, math arcpy.env.overwriteOutput = True arcpy.env.workspace = r"C:\GIS\Temp\test.gdb" tempworkspace = arcpy.env.workspace in_poly_fc = r"C:\GIS\Temp\test.gdb\CirclesFeatureClass" clip_lines_fc = r"ClipLines" sum_lines_fc = r"SumClipLines" #converting an existing fc with circles to Geometry objects geometries = arcpy.CopyFeatures_management(in_poly_fc,arcpy.Geometry()) for feature in geometries: #obtaining a centroid of the circle centroid via Geometry class attribute centroid_Point = feature.trueCentroid centroid_xy = [] #obtaining XY coordinates of the centroid via Point class attribute centroid_xy.append(centroid_Point.X) centroid_xy.append(centroid_Point.Y) #obtaining the radius #have to add a small overhead value to make sure the radius end point will overshoot the polygon #otherwise may get undershooting lines which depends on the precision of the coordinates #and XY tolerance of the source data radius = math.sqrt(feature.area / math.pi) + 1 #supply the list of angles for bearing bearing_angles = [0,60,120,180,240,300,360] #creating bearing angles table and adding fields bearing_table = arcpy.CreateTable_management(tempworkspace,"BearingDataTable") arcpy.AddField_management(bearing_table,"Xcoord","Double") arcpy.AddField_management(bearing_table,"Ycoord","Double") arcpy.AddField_management(bearing_table,"Bearing","Double") arcpy.AddField_management(bearing_table,"Distance","Double") #inserting all required lines constructed from centroid with the radius and bearing angle with arcpy.da.InsertCursor(bearing_table,["Xcoord","Ycoord","Bearing","Distance"]) as ins_cursor: for bearing_angle in bearing_angles: ins_cursor.insertRow((centroid_xy[0],centroid_xy[1],bearing_angle,radius)) del ins_cursor #projected coordinate system used for output lines feature classes generated project_coordsys = """PROJCS['NAD_1927_StatePlane_Alabama_East_FIPS_0101',GEOGCS['GCS_North_American_1927', DATUM['D_North_American_1927',SPHEROID['Clarke_1866',6378206.4,294.9786982]],PRIMEM['Greenwich',0.0], UNIT['Degree',0.0174532925199433]],PROJECTION['Transverse_Mercator'],PARAMETER['False_Easting',500000.0], PARAMETER['False_Northing',0.0],PARAMETER['Central_Meridian',-85.83333333333333], PARAMETER['Scale_Factor',0.99996],PARAMETER['Latitude_Of_Origin',30.5], UNIT['Foot_US',0.3048006096012192]];-17948200 -43887100 3048,00609601219; -100000 10000;-100000 10000;3,28083333333333E-03;0,001;0,001;IsHighPrecision""" arcpy.BearingDistanceToLine_management(bearing_table,clip_lines_fc,"Xcoord","Ycoord", "Distance","Feet","Bearing",spatial_reference=project_coordsys) #adding each circle's 8 lines in iteration to the sum output line feature class arcpy.Append_management(clip_lines_fc,sum_lines_fc,"NO_TEST") #deleting temp feature classes to avoid locking issues at next iteration arcpy.Delete_management(bearing_table) arcpy.Delete_management(clip_lines_fc) #cutting each circle in the polygon feature class by using the lines obtained earlier arcpy.FeatureToPolygon_management([in_poly_fc,sum_lines_fc],"Quadrants","#","ATTRIBUTES","#")
Angemeldete Mitglieder können Beiträge verfassen, Updates folgen und mehr. Neu hier? Registriere ein kostenloses Konto.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.