cdmacleod

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: http://forums.esri.com/Thread.asp?c=93&f=983&t=238219. 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,

Colin 

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.SetProduct("ArcInfo")
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")
    center.id=361
    center.x=p0_x
    center.y=p0_y
    cArray.add(center)
    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
        cPoint.id = i
        cPoint.x = p2_x
        cPoint.y = p2_y
        cArray.add(cPoint)
        del cPoint   
    return cArray

try:
    outfc = "wedges_80km.shp"
    GP.CreateFeatureclass(os.path.dirname(outfc),
                          os.path.basename(outfc),
                          "POLYGON")
except:
    for i in range(0, GP.MessageCount-1):
        print str(i+1)+':\t'+GP.GetMessages(i)+'\n'
   
try:
    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)
        cur.InsertRow(feat)
        #go to next record in shapefile
        row = rows.Next()
except:
    for i in range(0, GP.MessageCount-1):
        print str(i+1)+':\t'+GP.GetMessages(i)+'\n'

del GP

Outcomes