| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1761 人关注过本帖
标题:ARCGIS中的PYTHON问题
只看楼主 加入收藏
校草
Rank: 1
等 级:新手上路
帖 子:50
专家分:7
注 册:2017-3-15
结帖率:75%
收藏
 问题点数:0 回复次数:0 
ARCGIS中的PYTHON问题
程序代码:
# Import system modules 

import sys, string, os   

dir = 'H:\\NDVI\\ndvi'  


 # Import arcpy module 

import arcpy 

files = os.listdir(dir) 

for f in files: 

    if os.path.splitext(f)[1] == '.tif': 

     # Script arguments... 

     Input_raster_file = dir + os.sep + f 

     # Local variables...  

    Output_Workspace = "H:\\NDVI\\ndvi\\ASCII" 

     # =============== file name process ====================== 

     basename = os.path.splitext(f)[0]; 

    Output_raster = Output_Workspace + os.sep + basename + ".txt"; 

    if os.path.exists(Output_raster) == False: 

        print Input_raster_file 

        # Process: Raster To Other Format (multiple)... 

        arcpy.RasterToASCII_conversion(Input_raster_file,Output_raster) 

        print Output_raster 


输入文件名是这样的 heihe_2001_NDVI_recon.001.tif
        heihe_2001_NDVI_recon.002.tif
        heihe_2001_NDVI_recon.003.tif
           ....

问题如下:1.if os.path.splitext(f)[1] == '.tif': 是什么意思
     2.basename = os.path.splitext(f)[0];   中的[0]是什么意思
     3.运行报错  File "<string>", line 17, in <module>
NameError: name 'Input_raster_file' is not defined  问题出在哪

求各位大神解答,在此先谢过


[此贴子已经被作者于2017-6-27 19:06编辑过]

搜索更多相关主题的帖子: PYTHON Import if path print 
2017-06-27 19:03
快速回复:ARCGIS中的PYTHON问题
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.017183 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved