加载中…
个人资料
  • 博客等级:
  • 博客积分:
  • 博客访问:
  • 关注人气:
  • 获赠金笔:0支
  • 赠出金笔:0支
  • 荣誉徽章:
正文 字体大小:

Shapefile文件批量添加属性表字段并赋值

(2018-03-21 03:41:44)
分类: RS
想把一堆独立的Shapefile文件合并在一起,但是用于区分各shapefile的属性表字段得是每个shapefile的名字,如何实现?

# -*- coding: utf-8 -*-
# Import arcpy module
import arcpy

arcpy.env.workspace = r'D:\SHP'
shps = arcpy.ListFeatureClasses()

for shp in shps:
  arcpy.AddField_management(shp, 'Name','text')
  arcpy.CalculateField_management(shp, 'Name', '"'+shp+'"')

# Merge shapfiles
arcpy.Merge_management(shps, 'result.shp')

# this works for Arcgis 10.0+ version

0

阅读 收藏 喜欢 打印举报/Report
  

新浪BLOG意见反馈留言板 欢迎批评指正

新浪简介 | About Sina | 广告服务 | 联系我们 | 招聘信息 | 网站律师 | SINA English | 产品答疑

新浪公司 版权所有