Creating Wedge-Shaped Buffers

1499
2
06-05-2012 01:37 AM
ColinMacLeod
New Contributor
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
0 Kudos
2 Replies
StephenKruzik
New Contributor III
I work with E911 wireless data all the time that uses "sector wedges" for default coverage direction.  It's certainly not the same thing, but you might be able to tweek it a bit to get the desired results.  It takes a lot of other data that you could probably default with 'a' and '1', but the important thing is it takes an orientation, radius, and wedge width.

http://www.arcgis.com/home/item.html?id=9ac78cd092b640b3b69c6093e1be40bf

side note:  This is NOT my script.  The guy that wrote this is a million times smarter than me.
0 Kudos
ColinMacLeod
New Contributor
Hi Smkruzik,

Thanks for pointing me in the direction of that great little Add In.  It works perfectly for what I am needing to to (in this case it is identify the areas of sea that are surveyed from given land-based surey sites). There wasn't even too much fiddling around to get the exact outputs that I needed.  I can see it being used quite a lot by ecologists (my field of study), even though its designed for working with Wireless coverages, as this is the type of thing we need to do quite often.

Thanks again.

All the best,

Colin
0 Kudos