Created
April 14, 2015 02:11
-
-
Save beyoung/f4fafa5c9b4c04c1e337 to your computer and use it in GitHub Desktop.
arcpy-batch-image-clip
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
# @Author: youth | |
# @Date: 2015-04-11 09:20:01 | |
# @Last Modified time: 2015-04-11 10:14:58 | |
''' | |
该代码用于遥感影像的批量裁剪,其中运用到了多进程的处理模式 | |
''' | |
import os | |
import glob | |
import arcpy | |
from multiprocessing import Pool | |
PATH = r'E:\scratch\high\EO1H1370392002032110PZ' #指定要被裁剪的数据源的文件夹 | |
SAVE_PATH = r'E:\scratch\high\save'# 指定裁剪后保存的文件夹 | |
extent = '350256.784 3243290.486 357008.965 3247904.828' # 要裁剪的区域 | |
images = glob.glob(r'E:\scratch\high\EO1H1370392002032110PZ\*.TIF') #被裁剪数据的格式 *.TIF *.img等 | |
# 拆分为原子 单个任务 以用于多进程模式 | |
def do_task(task): | |
print 'processing %s'%(task[0]) | |
arcpy.Clip_management(task[0],extent,task[1]) | |
if __name__ == '__main__': | |
TASKS = [(image,os.path.join(SAVE_PATH,image[-35:])) for image in images] | |
pool = Pool(10) | |
pool.map(do_task,TASKS) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment