Creating Wedge-Shaped Buffers

Discussion created by cdmacleod on Jun 5, 2012
Latest reply on Jun 5, 2012 by cdmacleod
Hi All,

I am looking to create wedge-shaped buffers around a series of points in a point data layer.  Basically these wedges need to be sections of a circle with a user-defined (possibly from fields in the attribute table of the point data layer?) start bearing, end bearing and radius, where the original point is situated at the tip of the wedge.  This is to represent a surveyed section of sea from a static survey point.

Looking for a solution to this I found the following link from an old ArcGIS forum: This provided the code pasted below for doing this. 

However, I'm having trouble using this code and can't quite work out how best to load this into ArcGIS and what bits I need to customise/change for my specific computer/settings.  I think this is also written for ArcGIS 9.3, while I am using ArcGIS 10.0. If it is relevant, the computer I am trying to use this on is running 64 bit Windows 7.

Any suggestions of how to use this code, or of any other/better ways to create wedge-shaped buffers would be greatly appreciated.

All the best,


Code from old ArcGIS forum:

import win32com.client
import math, os, os.path
from win32com.client import Dispatch
GP = win32com.client.Dispatch("esriGeoprocessing.GpDispatch.1")
GP.workspace = "C:\\temp\\"

#The function that makes the wedge-shaped buffer
def MakeWedge(point, radius):
    cArray = GP.CreateObject("Array")
    p0_x = point[0]
    p0_y = point[1]
    p1_x = p0_x + radius
    p1_y = p0_y
    center = GP.CreateObject("Point")
    del center

    #Specify the starting and ending radians - starts at East and goes counterclockwise   
    for i in range(0, 91):
        cPoint = GP.CreateObject("Point")
        p2_x = p0_x + math.cos(math.radians(i))*radius
        p2_y = p1_y + math.sin(math.radians(i))*radius = i
        cPoint.x = p2_x
        cPoint.y = p2_y
        del cPoint   
    return cArray

    outfc = "wedges_80km.shp"
    for i in range(0, GP.MessageCount-1):
        print str(i+1)+':\t'+GP.GetMessages(i)+'\n'
    rows = GP.SearchCursor("anop_spm.shp")
    #Reset the cursor to the top.
    row = rows.Next()
    #Loop through each record in the shapefile
    while row:
        long = row.GetValue("LONGITUDE")
        lat = row.GetValue("LATITUDE")
        radius = 80000
        cur  = GP.InsertCursor(outfc)     
        feat = cur.NewRow()
        #call the function MakeWedge
        feat.shape = MakeWedge((long, lat), radius)
        #go to next record in shapefile
        row = rows.Next()
    for i in range(0, GP.MessageCount-1):
        print str(i+1)+':\t'+GP.GetMessages(i)+'\n'

del GP