[arcpy] Merge layer data

【Merge_management】Merge layer operation

Merge_management is a utility function in ArcPy that is used to merge data from multiple layers or tables. It combines features or records from multiple input data sources into a single output data source.

Basic syntax of Merge_management:

arcpy.Merge_management(inputs, output)

Parameter Description:

  • inputs: The input data source to be merged, which can be multiple layers, tables, feature classes, etc. The input can be in the form of a list containing multiple data source paths.
  • output: The merged output data source path.

Example:

import arcpy

# 设置工作空间
arcpy.env.workspace = "路径/到/工作空间"

# 定义输入图层路径
layer1 = "路径/到/第一个图层"
layer2 = "路径/到/第二个图层"

# 定义输出合并后的图层路径
output_layer = "路径/到/输出合并图层.shp"

# 合并图层
arcpy.Merge_management([layer1, layer2], output_layer)
#这里应该可以合并多个图层,放在list中

print("图层合并完成!")

In the above code, please replace the following parts with your own paths:

  • "path/to/workspace": The path to the workspace to be set.
  • "Path/To/First Layer" and "Path/To/Second Layer": The paths of the two layers to be merged.
  • "Path/To/Output Merged Layer.shp": The path and name of the merged output layer.

Guess you like

Origin blog.csdn.net/weixin_43958438/article/details/132663220