Clip_Multiple_Rasters.py

Script - Luca Congedo, 2013-09-13 01:28 AM

Download (978 Bytes)

 
1
##Raster=group
2
##Input=multiple raster
3
# upper left point
4
##UX=number 
5
##UY=number 
6
# lower right point
7
##LX=number 
8
##LY=number
9
##No_data=boolean
10
##No_data_value=number 0
11
##Output_directory=folder
12

    
13
import os
14
import processing
15

    
16
lddLrs = Input.split(';')
17

    
18
if No_data == 0:
19
        for lyr in lddLrs:
20
                os.system("gdal_translate -projwin " + str(UX) + " " + str(UY) + " " + str(LX) + " " + str(LY) + " -of GTiff " + str(lyr) + " " + Output_directory + "/clip_" + str(os.path.basename(str(lyr))))
21
                #loading fails
22
                #processing.load(str(Output_directory + "/clip_" + str(os.path.basename(str(lyr)))))
23
else:
24
        for lyr in lddLrs:
25
                os.system("gdal_translate -a_nodata " + str(No_data_value) + " -projwin " + str(UX) + " " + str(UY) + " " + str(LX) + " " + str(LY) + " -of GTiff " + str(lyr) + " " + Output_directory + "/clip_" + str(os.path.basename(str(lyr))))
26
                #loading fails
27
                #processing.load(str(Output_directory + "/clip_" + str(os.path.basename(str(lyr)))))