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

ArcGIS 10 批量转换栅格数据

(2013-08-05 22:00:53)
分类: ARCGIS

引自:http://blog.csdn.net/mygisforum/article/details/8262450

 

在做三维场景的时候,经常会涉及多种不同DEM数据格式之间的转换,如ASCII、GRID、IMG、TIFF等等,遇到大数据量时,我们就需要批量转换功能了。

下面使用python脚本来实现批量转换,把f:\\test文件夹下的*.grd栅格文件转换为*.TIFF文件并存于其下的TIFF子文件夹中:

  1. Import system modules   
  2. import sys, string, os  
  3.   
  4. dir 'F:\\test'  
  5.   
  6. Import arcpy module   
  7. import arcpy  
  8.   
  9. files os.listdir(dir)  
  10. for in files:  
  11.     if os.path.splitext(f)[1== '.grd' 
  12.         Script arguments...   
  13.         Input_raster_file dir os.sep  
  14.   
  15.         Local variables...   
  16.         Output_data_type "FLOAT"  
  17.         Raster_Format "TIFF"  
  18.         Output_Workspace "f:\\test\\TIFF"  
  19.   
  20.         =============== file name process ======================   
  21.         basename os.path.splitext(f)[0];  
  22.         Output_raster Output_Workspace os.sep basename ".tif" 
  23.   
  24.         if os.path.exists(Output_raster) == False 
  25.             print Input_raster_file  
  26.             Process: Raster To Other Format (multiple)...   
  27.             arcpy.RasterToOtherFormat_conversion(Input_raster_file,   
  28.                         Output_Workspace, Raster_Format)  
  29.   
  30.             print Output_raster  
# Import system modules
import sys, string, os

dir = 'F:\\test'

# Import arcpy module
import arcpy

files = os.listdir(dir)
for f in files:
    if os.path.splitext(f)[1] == '.grd':
        # Script arguments...
        Input_raster_file = dir + os.sep + f

        # Local variables...
        Output_data_type = "FLOAT"
        Raster_Format = "TIFF"
        Output_Workspace = "f:\\test\\TIFF"

        # =============== file name process ======================
        basename = os.path.splitext(f)[0];
        Output_raster = Output_Workspace + os.sep + basename + ".tif";

        if os.path.exists(Output_raster) == False:
            print Input_raster_file
            # Process: Raster To Other Format (multiple)...
            arcpy.RasterToOtherFormat_conversion(Input_raster_file, 
                        Output_Workspace, Raster_Format)

            print Output_raster


 

0

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

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

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

新浪公司 版权所有