31

I would like to create a square buffer from a point feature but I do not understand the code that goes into it.

Similar questions have been asked on the forums.esri website but that was over 10 years ago, and it did not work when I tried the code.

How do I create a square buffer from a point feature?

  • gis.stackexchange.com/questions/12479/… is essentially a duplicate (because it addresses a generalization of this question), but as there are already good answers here that are specific to square buffers, it seems best to leave both threads open and separate rather than merging them. But if you want yet more solutions, read the other thread too! – whuber Jul 12 '12 at 13:18
  • 2
    OK thanks whuber. I just found this website yesterday and I'm still getting familiar with it. I'll try to do that with my future posts/questions. I'm liking this site a lot better than the ArcGIS forums. – Kimball Jul 12 '12 at 14:37
  • I didn't mean that comment as criticism in any way, Kimball: it was there to prevent merging the two threads, that's all. Welcome to our community! (And please tell your friends about us, especially those on the ArcGIS forums. :-) – whuber Jul 12 '12 at 15:23
  • Right. I know you didn't mean it that way. I enjoy this community a lot and have already begun to tell others about this new forum. – Kimball Jul 12 '12 at 15:40
  • Thank you for your significant share. I am wondering how I can use a set of field data in point feature to create rectangle buffers using the script you provide without manually type their coordinates. Thanks – user77707 Jul 12 '16 at 7:12
47

Try these steps with ArcMap 10:

  1. Buffer your point feature (ArcToolbox > Analysis Tools > Proximity > Buffer). Make sure to select the correct distance in the Linear unit box.
  2. Input your newly created buffers into the Feature Envelope to Polygon tool (Data Management Tools > Features > Feature Envelope to Polygon). Make sure to select the "Create multpart features" box if you have multiple points.

For a Python solution:

Using SearchCursor and InsertCursor to create square buffers

enter image description here

  • 2
    +1 Replies that demonstrate the solution works are the best. – whuber Jul 12 '12 at 13:19
12

A possible solution would be to create your "normal" round buffers using the standard ESRI buffer tool with whatever radius you would like and then performing a Feature Envelope To Polygon on that resulting feature class of buffers. This creates a square envelope feature around the extent of each feature. Feature Envelope to Polygon is located within Data Management>Features. The model builder model would look similar to:

enter image description here

  • Excellent solution! Also, by creating the output of the buffer as an in_memory layer (in_memory\tmpBuffer) and you can avoid writing unneeded data to disk, and make the process much faster. – RyanDalton Jul 12 '12 at 14:15
9

Since the script linked at the end of Aaron's code can only be used for square buffers and doesn't make use of the newer arcpy.da module, I've written a script that can be used to create rectangle buffers. On a 10k random point dataset, it completed in 10 seconds:

enter image description here

import os, arcpy

point_FC = arcpy.GetParameterAsText(0)
w = float(arcpy.GetParameterAsText(1))
h = float(arcpy.GetParameterAsText(2))
output_FC = arcpy.GetParameterAsText(3)

def rect(coord, w, h):
        #Given XY coordinates and rectangle dimensions,
        #return a polygon object of a rectangle centered about the point
        x,y = coord
        w *= 0.5
        h *= 0.5
        xmin,xmax = x-w, x+w
        ymin,ymax = y-h, y+h
        poly = ((xmin, ymax), (xmax, ymax), (xmax, ymin), (xmin, ymin))
        return arcpy.Polygon(arcpy.Array(arcpy.Point(*p) for p in poly))

#Create output feature class.
spatref = arcpy.Describe(point_FC).spatialReference
folder, base = os.path.split(output_FC)
arcpy.CreateFeatureclass_management(folder, base, "POLYGON", spatial_reference=spatref)

#Get field object for every field in input except OID and Shape.
fields = [f for f in arcpy.ListFields(point_FC) if f.type not in ("OID", "Geometry")]

for field in fields:
         arcpy.AddField_management(output_FC, field.name, field.type, field.precision,
                                   field.scale, field.length, field.aliasName,
                                   field.isNullable, field.required, field.domain)

#Get field names to be inputted to cursors.
#Need SHAPE@XY token to read point coords and SHAPE@ token to write polygon coords.
fnames = [f.name for f in fields]
fields_in = fnames[::]
fields_out = fnames[::]
fields_in.append("SHAPE@XY")
fields_out.append("SHAPE@")

#Create buffers and write attributes to output FC, if any.
count = int(arcpy.GetCount_management(point_FC)[0])
arcpy.SetProgressor("step", "Buffering...", 0, count, 1)
with arcpy.da.SearchCursor(point_FC, fields_in) as Scursor,  arcpy.da.InsertCursor(output_FC, fields_out) as Icursor:
        for i,row_in in enumerate(Scursor):                
                #"Convert" point to rectangle
                arcpy.SetProgressorPosition(i)
                feature = list(row_in)
                feature[-1] = rect(feature[-1], w, h)                
                Icursor.insertRow(feature)
5

Assuming you're using ArcObjects (please use the tags to specify the language and API you're using), you could use IEnvelope.Expand to create a square buffer from a point's envelope, as in this example: Get All Features from Point Search in GeoFeatureLayer Snippet

ESRI.ArcGIS.Geometry.IEnvelope envelope = point.Envelope;
envelope.Expand(searchTolerance, searchTolerance, false);
0

This site describes how to convert csv to square or rectangle or circle buffers using geographiclib JavaScript and js2shapefile.

You can have a look if it solves your problem.

0

As an alternative to Aaron's answer, for those without an Advanced license, use the Minimum Bounding Geometry tool. Steps below (modified from Aaron):

  1. Buffer your point feature (ArcToolbox > Analysis Tools > Proximity > Buffer). Make sure to select the correct distance in the Linear unit box.
  2. Input your newly created buffers into the Minimum Bounding Geometry tool (Data Management Tools > Features > Minimum Bounding Geometry). Use 'RECTANGLE_BY_AREA' or 'RECTANGLE_BY_WIDTH', the other options are only available with an Advanced license.

EDIT: This option doesn't let you control the orientation of the resulting square buffers, without using the 'ENVELOPE' option (which requires an Advanced license). By ticking the 'Add geometry characteristics as attributes to output (optional)' option - the resulting offset will be recorded as 'MBG_Orientation' in the output feature class. This can then be used to rotate the features back to centre if desired - see Rotating polygons by value from attribute table using ArcPy? for a potential solution to that.

enter image description here

  • For my particular feature class it ends up rotating the squares in different directions using this workflow. Perhaps because I have overlapping buffer circles. Not sure. I had Esri use Aaron's method above on my same feature class and it did not rotate the buffered circles. – Andrew Jul 29 at 14:26
  • @Andrew, yep you're right, that is a limitation of the tool without an Advanced License. Using the ENVELOPE option would return the same result as Aaron's method above, but also needs an Advanced License. A potential workaround would be to tick the 'add geometry characteristics as attributes' option, find out the amount they are tilted (should be consistent), then rotate the resulting square buffers by that amount in an editing session. Haven't tried this yet. – Dùn Caan Jul 31 at 1:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.