工作中需要做大量圖層的拼接,為了在拼接完成後還能知道原始資料檔案是什麼,所以寫了個python指令碼對每個圖層的source欄位進行賦值。
附上python**:
1#-*- coding: utf-8 -*-2#
nightroad
3import
sys4
import
arcpy
56 path = "
c:/users/nightroad/desktop/shp
"7 arcpy.env.workspace =path
8 ff =arcpy.listfeatureclasses()
9for fc in
ff:10
print(fc.replace("
.shp
", ""
))11 arcpy.calculatefield_management(fc,"
source
",'"
'+fc.replace("
.shp
", "")+'
"',"
python_9.3")
12print('
success:
'+fc)
arcpy批量合併shp
import arcpy shuju r c users documents arcgis default.gdb arcpy.env.workspace shuju fcs arcpy.listfeatureclasses lspt for fc in fcs arcpy.merge manage...
arcpy批量更新shp某一字段的值
提取檔名更新到dlbh欄位 encoding utf 8 import csv import arcpy import os shuju r d short2.gdb wenjianjia r d desktop csv.gdb fish r d desktop yw fishnet.shp res...
批量為shp檔案加字段並賦值檔名
import sys,string,os,arcgisscripting create the geoprocessor object gp arcgisscripting.create load required toolboxes.gp.addtoolbox c program files x8...