9

I am trying to create a buffer for several polygons in a south-western orientation. As far as I know, this is not possible using the buffer tool (I use ArcGIS 10.3). I could do it manually but for some 400+ polygons it would take far too long. Does anybody know a better way? This is more or less what I am aiming for: enter image description here

  • Are your polygons all rectangles and squares? – Aaron Aug 4 '15 at 11:27
  • No, unfortunately not. They come in different shapes – Username Aug 4 '15 at 14:44
7

If you can work with arcpy in Python a little bit, then you could use some script to generate these zones in specific direction. I made some similar few weeks ago, I will post part of my script to help you.

import arcpy, math, gc
# Workspace, overwrite
arcpy.env.workspace = r"YOUR_WORKSPACE"
arcpy.env.overwriteOutput = True

# INPUTS
objects_input = "objects.shp" # must be polygons
objects = "objects_lyr.shp"
arcpy.MakeFeatureLayer_management(objects_input, objects)

# OUTPUTS, most temporal
result = "result.shp"
result_erase = "in_memory" + "\\" + "result_erase"
polygon = "in_memory" + "\\" + "polygon"
polygon_dissolve = "in_memory" + "\\" + "polygon_dissolve"

arcpy.CreateFeatureclass_management(arcpy.env.workspace, result, "POLYGON")

# Parameters
distance = 300 # distance for move in direction
direction = 90 # direction in degrees (90 is from north to south)
index = 0

# Set UpdateCursor
cur_objects = arcpy.da.UpdateCursor(objects, ("FID"))
for row_objects in cur_objects:
    try:
        fid = row_objects[0]
        sql = '"FID" = ' + str(index)
        index += 1

        # Initialize lists
        lines_list = []
        lines_created = []

        # Select current feature
        arcpy.SelectLayerByAttribute_management(objects, "NEW_SELECTION", sql)
        vertexes = "in_memory" + "\\" + "vertexes"

        # Convert object to vertexes
        arcpy.FeatureVerticesToPoints_management(objects, vertexes, "ALL")
        index_vertex = 0

        # Set SearchCursor for vertexes
        cur_vertexes = arcpy.da.SearchCursor(vertexes, ("SHAPE@XY"))
        for row_vertexes in cur_vertexes:
            vertex_coords_x = row_vertexes[0][0]
            vertex_coords_y = row_vertexes[0][1]

            # Define points coordinates
            point_move_x = vertex_coords_x - (distance) * math.cos(math.radians(direction))
            point_move_y = vertex_coords_y - (distance) * math.cos(math.radians(90 - direction))

            # Make list of points
            new_line = ([[vertex_coords_x, vertex_coords_y], [point_move_x, point_move_y]])
            lines_list.append(new_line)

            # From second cycle
            if index_vertex > 0:
                lines_vertexes = ([[vertex_coords_x, vertex_coords_y], start_line])
                lines_ends = ([[point_move_x, point_move_y], end_line])
                lines_list.append(lines_vertexes)
                lines_list.append(lines_ends)
            start_line = [vertex_coords_x, vertex_coords_y]
            end_line = [point_move_x, point_move_y]
            index_vertex = index_vertex + 1

        # Cycle that makes polylines from points
        for lines_step in lines_list:
            lines_created.append(arcpy.Polyline(arcpy.Array([arcpy.Point(*sour) for sour in lines_step])))

        arcpy.FeatureToPolygon_management(lines_created, polygon)
        arcpy.AggregatePolygons_cartography(polygon, polygon_dissolve, 1)

        # Final editing
        arcpy.Erase_analysis(polygon_dissolve, objects, result_erase)
        arcpy.Append_management(result_erase, result, "NO_TEST")
        arcpy.Delete_management("in_memory")
        arcpy.Delete_management(vertexes)
        start_line = []

        # Clear selection, memory and deleting temps
        arcpy.SelectLayerByAttribute_management(objects, "CLEAR_SELECTION")
        print "Object number: " + str(index - 1) + " -- done."
        gc.collect()


    # Catch errors
    except Exception as e:
        pass
        print "Error:"
        print e
        print "\n"
        index += 1

I hope you can read it well, I had to translate comments and variables.

  • Thank you for the script. I don't really know anything about Python but I've copied your script and changed the Workspace and Object names as well as the distance. The features classes are created, but apparently I've made a mistake because there's an error for each "select layer by attribute" operation – Username Aug 4 '15 at 14:25
  • I've made some changes in script, you could try it now. Set workspace and your shapefile and we will see :) – david_p Aug 5 '15 at 6:15
  • Thank you very very much! That gives me exactly the result I was hoping for. It didn't work at first because there were some parentheses missing in the last block of the script but besides that it's perfect. I don't think I can post the whole script in a comment but I will post it below. Thanks again! – Username Aug 5 '15 at 9:55
  • You are welcome :) I'm glad that I can help you! – david_p Aug 5 '15 at 10:49
3

This is the script that solves the problem. Credit and many thanks go to david_p who wrote it. I just added a few missing parentheses.

import arcpy, math, gc

# Workspace, overwrite 
arcpy.env.workspace = r"YOUR_WORKSPACE" 
arcpy.env.overwriteOutput = True

# INPUTS 
objects_input = "objects.shp" # must be polygons 
objects = "objects_lyr.shp" 
arcpy.MakeFeatureLayer_management(objects_input, objects)

# OUTPUTS, most temporal 
result = "result.shp" 
result_erase = "in_memory" + "\\" + "result_erase" 
polygon = "in_memory" + "\\" + "polygon" 
polygon_dissolve = "in_memory" + "\\" + "polygon_dissolve"

arcpy.CreateFeatureclass_management(arcpy.env.workspace, result, "POLYGON")

# Parameters 
distance = 300 # distance for move in direction 
direction = 90 # direction in degrees (90 is from north to south) 
index = 0

# Set UpdateCursor
cur_objects = arcpy.da.UpdateCursor(objects, ("FID"))
for row_objects in cur_objects:
    try:
        fid = row_objects[0]
        sql = '"FID" = ' + str(index)
        index += 1

        # Initialize lists
        lines_list = []
        lines_created = []

        # Select current feature
        arcpy.SelectLayerByAttribute_management(objects, "NEW_SELECTION", sql)
        vertexes = "in_memory" + "\\" + "vertexes"

        # Convert object to vertexes
        arcpy.FeatureVerticesToPoints_management(objects, vertexes, "ALL")
        index_vertex = 0

        # Set SearchCursor for vertexes
        cur_vertexes = arcpy.da.SearchCursor(vertexes, ("SHAPE@XY"))
        for row_vertexes in cur_vertexes:
            vertex_coords_x = row_vertexes[0][0]
            vertex_coords_y = row_vertexes[0][1]

            # Define points coordinates
            point_move_x = vertex_coords_x - (distance) * math.cos(math.radians(direction))
            point_move_y = vertex_coords_y - (distance) * math.cos(math.radians(90 - direction))

            # Make list of points
            new_line = ([[vertex_coords_x, vertex_coords_y], [point_move_x, point_move_y]])
            lines_list.append(new_line)

            # From second cycle
            if index_vertex > 0:
                lines_vertexes = ([[vertex_coords_x, vertex_coords_y], start_line])
                lines_ends = ([[point_move_x, point_move_y], end_line])
                lines_list.append(lines_vertexes)
                lines_list.append(lines_ends)
            start_line = [vertex_coords_x, vertex_coords_y]
            end_line = [point_move_x, point_move_y]
            index_vertex = index_vertex + 1

        # Cycle that makes polylines from points
        for lines_step in lines_list:
            lines_created.append(arcpy.Polyline(arcpy.Array([arcpy.Point(*sour) for sour in lines_step])))

        arcpy.FeatureToPolygon_management(lines_created, polygon)
        arcpy.AggregatePolygons_cartography(polygon, polygon_dissolve, 1)

        # Final editing
        arcpy.Erase_analysis(polygon_dissolve, objects, result_erase)
        arcpy.Append_management(result_erase, result, "NO_TEST")
        arcpy.Delete_management("in_memory")
        arcpy.Delete_management(vertexes)
        start_line = []

        # Clear selection, memory and deleting temps
        arcpy.SelectLayerByAttribute_management(objects, "CLEAR_SELECTION")
        print ("Object number: " + str(index - 1) + " -- done.")
        gc.collect()


    # Catch errors
    except Exception as e:
        pass
        print ("Error:")
        print (e)
        print ("\n")
        index += 1
0

Option A:

  1. Create the buffer using the buffer tool
  2. Select all the features in Buffer feature class
  3. Use warping tool and designate some important corners and perform warping

Option B:

  1. Create the buffer using the buffer tool
  2. Enable Editing and Select all the features in Buffer feature class
  3. Use 'Move' tool, fill the X and Y offests in the window and save the output
  • By "Move" do you mean the Shift tool? Anyway I'm not sure if this will give me the result I need. All the polygons in my feature class come in different shapes so I can't move all the buffer features the same way as this would result in different distances from the initial features. – Username Aug 4 '15 at 14:35

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.