Hi Zack Tucker ,
Good catch. The code simply will create a point every degree using the range from Minus30 to Plus30 in your case and if Minus30 is larger than Plus30 no points will be created. I added a small fix at lines 48-49 and it should work now:
import arcpy
def main():
import os
fc_in = r"C:\GeoNet\OrientedBuffers\data.gdb\points"
fc_out = r"C:\GeoNet\OrientedBuffers\data.gdb\sectors_v03"
fld_start = "Minus30"
fld_end = "Plus30"
fld_dist = "DistanceMeters"
fld_oid = "OIDpoints"
sr = arcpy.Describe(fc_in).spatialReference
arcpy.env.overwriteOutput = True
fc_ws, fc_name = os.path.split(fc_out)
arcpy.CreateFeatureclass_management(fc_ws, fc_name, "POLYGON", spatial_reference=sr)
arcpy.AddField_management(fc_out, fld_oid, "LONG")
flds_out = ("SHAPE@", fld_oid)
with arcpy.da.InsertCursor(fc_out, flds_out) as curs_out:
flds = ("SHAPE@", fld_start, fld_end, fld_dist, "OID@")
lst_polygons = []
with arcpy.da.SearchCursor(fc_in, flds) as curs:
for row in curs:
pnt_g = row[0]
start = row[1]
end = row[2]
length = row[3]
oid = row[4]
circle = pnt_g.buffer(length)
pnt = pnt_g.firstPoint
arrPnts = arcpy.Array()
arrPnts.add(pnt)
if end < start:
end += 360.0
for bearing in range(int(start), int(end) + 1):
arrPnts.add(createPointAtAngleWithBearing(pnt, bearing, length))
polygon = arcpy.Polygon(arrPnts, sr)
curs_out.insertRow((polygon, oid, ))
def createPointAtAngleWithBearing(pnt, angle, distance):
import math
angle = math.radians(angle)
dist_x, dist_y = (distance * math.cos(angle), distance * math.sin(angle))
return arcpy.Point(pnt.X + dist_x, pnt.Y + dist_y)
if __name__ == '__main__':
main()
Result (after changing some of the overlapping point locations):