資源簡介
arcgis批量配準(zhǔn),快速批量配準(zhǔn),工作上常用到

代碼片段和文件信息
#?-*-?coding:gb2312?-*-
#名稱:寫圖像名文本(writeimgname.py)
#時間:2010年8月25日
#作者:云浩
#內(nèi)容:把同一文件夾中的圖像文件名寫入投影參數(shù)文本文件
import?sys?os?string??glob
pydir?=?os.getcwd()?+?‘\\‘
dirPath?=?os.path.abspath(‘..‘)?+?‘\\‘
filelist?=?os.listdir(dirPath)
jpgfiles?=?glob.glob(dirPath?+?‘*.jpg‘)
tiffiles?=?glob.glob(dirPath?+?‘*.tif‘)
if?jpgfiles?==?[]?and?tiffiles?==?[]:
????print?dirPath?+?‘沒有JPG、TIF格式的影像文件,重選工作目錄。‘
????sys.exit()
f?=?True
while?f?==?True:
????txtname?=?raw_input(‘輸入新建坐標(biāo)參數(shù)文件名:‘)
????if?txtname.find(‘.txt‘)?==?-1:
???????txtname?=?txtname?+?‘.txt‘
????if?glob.glob(dirPath?+?txtname)?<>?[]:???#?判斷要創(chuàng)建的文件是否存在,如果存在則退出腳本
???????txtfile?=?dirPath?+?txtname
???????print?txtfile?+?‘已存在,請重輸文件名。‘
????else:f?=?False
newtxtfile?=?open(dirPath?+?txtname‘w‘)
for?fname?in?jpgfiles?+?tiffiles:
????kname?=?fname.split(dirPath)[1]
????sname?=?kname.split(‘.‘)[0]
????newtxtfile.write(sname+‘\n‘)
????print?sname
newtxtfile.close()
print?‘在‘?+?dirPath?+?‘工作目錄下共有‘?+?str(len(jpgfiles?+?tiffiles))?+?‘幅圖像的文件名已輸入‘?+?txtname?+?‘坐標(biāo)參數(shù)文件中‘
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件????????144??2004-02-06?17:41??地圖批量配準(zhǔn)\Xian?1980.prj
?????文件?????276992??2010-08-30?15:19??地圖批量配準(zhǔn)\中國國家基本地形圖查詢軟件.exe
?????文件???????1187??2010-08-30?17:32??地圖批量配準(zhǔn)\寫圖幅名.py
?????文件???????3477??2010-08-30?23:30??地圖批量配準(zhǔn)\地圖批量配準(zhǔn).py
?????目錄??????????0??2010-08-31?13:24??地圖批量配準(zhǔn)
-----------?---------??----------?-----??----
???????????????281800????????????????????5
評論
共有 條評論