使用 arcpy 进行缓冲区分析

Buffer Analysis using arcpy

我正在寻找一段代码来帮助我将道路中心线要素转换为缓冲区。我有以下功能 类.

roads = "c:/base/data.gdb/roadcentreline"
roadsoutput = "c:/base/data.gdb/roadcentreline_Buffer"

现在,我想将其转换为缓冲区并将其存储在道路输出中。有什么方法可以实现吗?

我在互联网上找到的一种方法是,我们可以 运行 使用上面设置的变量进行缓冲,并将其余参数作为字符串传递。

以下是将任何多段线转换为缓冲区的建议代码。有关详细信息,请查看 Esri 文档。

import arcpy

roads = "c:/base/data.gdb/roadcentreline"
roadsoutput = "c:/base/data.gdb/roadcentreline_Buffer"
arcpy.Buffer_analysis(roads, output, "distance", "FULL", "ROUND", "NONE")

但是我还是很疑惑,有没有更好的办法呢?

UPD:“缓冲区”工具最适合一条道路或一组道路。但是对于网络,您最好使用 Network Analyst 工具箱中的一些特定工具

完成之前的回答:

您的工作流程应该是这样的:

  1. 在 arcMap 中打开“搜索”面板
  2. 键入“缓冲区”
  3. 探索答案,找到 suitable 工具并打开它。在您的情况下,它是“Analysys”工具箱中的“Buffer”
  4. 探索参数
  5. 打开“显示帮助”->“工具帮助”
  6. 向下滚动
  7. 在那里找到这个代码示例(还有一个非常有用的参数table):
import arcpy
arcpy.env.workspace = "C:/data"
arcpy.Buffer_analysis("roads", "C:/output/majorrdsBuffered", "100 Feet", "FULL", "ROUND", "LIST", "Distance")
# Name: Buffer.py
# Description: Find areas of suitable vegetation which exclude areas heavily impacted by major roads

# import system modules 
import arcpy
from arcpy import env

# Set environment settings
env.workspace = "C:/data/Habitat_Analysis.gdb"

# Select suitable vegetation patches from all vegetation
veg = "vegtype"
suitableVeg = "C:/output/Output.gdb/suitable_vegetation"
whereClause = "HABITAT = 1" 
arcpy.Select_analysis(veg, suitableVeg, whereClause)

# Buffer areas of impact around major roads
roads = "majorrds"
roadsBuffer = "C:/output/Output.gdb/buffer_output"
distanceField = "Distance"
sideType = "FULL"
endType = "ROUND"
dissolveType = "LIST"
dissolveField = "Distance"
arcpy.Buffer_analysis(roads, roadsBuffer, distanceField, sideType, endType, dissolveType, dissolveField)

# Erase areas of impact around major roads from the suitable vegetation patches
eraseOutput = "C:/output/Output.gdb/suitable_vegetation_minus_roads"
xyTol = "1 Meters"
arcpy.Erase_analysis(suitableVeg, roadsBuffer, eraseOutput, xyTol)