这里对一个文件中的多个矢量点,生成了50km缓冲区
代码实例:
# encoding: utf-8
import arcpy
import os
arcpy.env.workspace = r"E:\03-2001_2020World\02-PlantYearSHP"
output_workspace = r"E:\03-2001_2020World\03-PlantYearSHPbuffer"
# 列出所有的点Shapefile
shp_files = arcpy.ListFeatureClasses(feature_type='Point')
# 遍历所有点Shapefile文件
for shp_file in shp_files:
# 构建输出缓冲区Shapefile的名称
buffer_shp = os.path.join(output_workspace, os.path.splitext(shp_file)[0] + "_Buffer50")
# 缓冲区距离(例如5公里)
buffer_distance = "50 Kilometers"
# 执行缓冲区分析
arcpy.Buffer_analysis(shp_file, buffer_shp, buffer_distance)
print("Created buffer")
print("All buffers have been created.")