alex_bn_lee

导航

< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

统计

[937] Combine different shapefiles and remove duplicate features

In arcpy, you can combine different shapefiles and remove duplicate features using the arcpy.management.Merge tool and the arcpy.management.DeleteIdentical tool. Here's an example:

import arcpy
# Set the workspace environment
arcpy.env.workspace = r'C:\Path\To\Your\Workspace.gdb'
# List of shapefiles to combine
shapefiles_to_combine = ['Shapefile1', 'Shapefile2', 'Shapefile3']
# Output shapefile with combined features
output_shapefile = 'CombinedShapefile'
# Merge the shapefiles into a new shapefile
arcpy.management.Merge(shapefiles_to_combine, output_shapefile)
# Remove duplicate features based on geometry
arcpy.management.DeleteIdentical(output_shapefile, "SHAPE")
print(f'Shapefiles combined and duplicate features removed in {output_shapefile}.')

Replace 'C:\Path\To\Your\Workspace.gdb' with the actual path to your geodatabase, 'Shapefile1', 'Shapefile2', 'Shapefile3' with the names of the shapefiles you want to combine, and 'CombinedShapefile' with the desired name for the new shapefile.

In this example, the Merge tool is used to combine the specified shapefiles into a new shapefile, and then the DeleteIdentical tool is used to remove duplicate features based on geometry. Adjust the list of shapefiles and the output shapefile name based on your specific requirements. Note that the DeleteIdentical tool removes features that have identical geometries; if you want to remove duplicates based on attributes, you can specify the attribute fields in the second parameter of the tool.

posted on   McDelfino  阅读(12)  评论(0编辑  收藏  举报

相关博文:
阅读排行:
· DeepSeek 开源周回顾「GitHub 热点速览」
· 记一次.NET内存居高不下排查解决与启示
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· .NET10 - 预览版1新功能体验(一)
历史上的今天:
2019-11-15 【451】python 同一行打印进度条
点击右上角即可分享
微信分享提示