Shapefile文件批量添加属性表字段并赋值
(2018-03-21 03:41:44)分类: RS |
想把一堆独立的Shapefile文件合并在一起,但是用于区分各shapefile的属性表字段得是每个shapefile的名字,如何实现?
arcpy.AddField_management(shp,
'Name','text')
arcpy.CalculateField_management(shp,
'Name', '"'+shp+'"')
# -*- coding: utf-8 -*-
# Import arcpy module
import arcpy
arcpy.env.workspace = r'D:\SHP'
shps = arcpy.ListFeatureClasses()
for shp in shps:
# Merge shapfiles
arcpy.Merge_management(shps, 'result.shp')
# this works for Arcgis 10.0+ version