仅使用ArcGIS for Desktop在特定方向上创建缓冲区?[关闭]


9

我正在尝试为西南方向的多个多边形创建缓冲区。据我所知,使用缓冲工具是不可能的(我使用ArcGIS 10.3)。我可以手动完成,但是对于大约400多个多边形,这将花费太长时间。

有人知道更好的方法吗?

这或多或少是我的目标:

在此处输入图片说明


1
您的多边形是否都是矩形和正方形?
亚伦

不,不幸的是没有。它们具有不同的形状
用户

这是对您进行问题编辑的重要说明。
PolyGeo

Answers:


8

如果您可以使用arcpyPython进行一点操作,则可以使用一些脚本在特定方向上生成这些区域。我在几周前做了类似的事情,我将发布部分脚本以帮助您。

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

希望您能读得很好,我不得不翻译注释和变量。


谢谢您的脚本。我对Python一点都不了解,但是我已经复制了脚本并更改了工作区和对象名称以及距离。要素类已创建,但显然我犯了一个错误,因为每个“按属性选择图层”操作都出错
用户名

我已经对脚本进行了一些更改,您可以立即尝试。设置工作区和您的shapefile,我们将看到:)
david_p

非常非常感谢你!这正是我所期望的结果。最初它没有用,因为在脚本的最后一块中缺少一些括号,但除此之外,它是完美的。我认为我无法在注释中发布整个脚本,但我将在下面发布。再次感谢!
用户名

欢迎您:)很高兴能为您提供帮助!
david_p 2015年

5

这是解决问题的脚本。感谢和感谢david_p编写它。我只添加了一些缺少的括号。

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

选项A:

  1. 使用缓冲工具创建缓冲
  2. 选择“缓冲区”要素类中的所有要素
  3. 使用变形工具并指定一些重要的角落并进行变形

选项B:

  1. 使用缓冲工具创建缓冲
  2. 启用编辑并选择“缓冲区”要素类中的所有要素
  3. 使用“移动”工具,在窗口中填充X和Y偏移并保存输出

“移动”是指Shift工具吗?无论如何,我不确定这是否能给我所需的结果。我的要素类中的所有多边形都具有不同的形状,因此我无法以相同的方式移动所有缓冲区要素,因为这会导致距初始要素的距离不同。
用户名
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.