zoukankan      html  css  js  c++  java
  • 基于Python的批量裁剪影像

    基于Python的批量裁剪影像

    之前用IDL批量裁剪影像的时候发现裁剪出来的是一个矩形,并不能严格按照图形的形状来完成。发现PYTHON在批处理方面的确好用,节约钱,帮代码直接给贴出来,也算为论坛做点贡献,不知道你们还有什么好的方法。分享一下。使用的时候可以参照这个帖子http://bbs.esrichina-bj.cn/esri/thread-82776-1-1.html
    import arcgisscripting
    import os
    #coding=gbk
    gp = arcgisscripting.create(9.3)
    gp.AddToolbox ("G:/Program Files/ArcGIS/ArcToolbox/Toolboxes/Spatial Analyst Tools.tbx")
    gp.CheckOutExtension("Spatial")
    ws = os.getcwd()
    print ws
    children = os.listdir(ws)
    files = []
    for child in children:
        ext = os.path.splitext(child)[1]
        if (ext == '.img'):
            files.append(child)
    gp.workspace = ws
    for file in files:
        InMask = "E:/NDVI/Export_Output.shp"
        s = os.path.basename(file)
        obj_name = s[8:15] + '.IMG'
        gp.ExtractByMask_sa(file, InMask, obj_name)
    print files
    print "ok"
    不知道怎么贴成代码的形式。
  • 相关阅读:
    Merge Two Sorted Lists
    4Sum
    Letter Combinations of a Phone Number
    3Sum Closest
    3Sum
    Longest Common Prefix
    Roman to Integer
    Integer to Roman
    Container With Most Water
    Regular Expression Matching
  • 原文地址:https://www.cnblogs.com/xianyin05/p/3100946.html
Copyright © 2011-2022 走看看