-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmake_vrt.py
More file actions
40 lines (28 loc) · 891 Bytes
/
make_vrt.py
File metadata and controls
40 lines (28 loc) · 891 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Thu Oct 11 11:02:55 2018
@author: braatenj
"""
import subprocess
def make_vrt(inputFiles, vrtFile):
inputListFile = vrtFile.replace('.vrt', '_filelist.txt')
inputList = open(inputListFile, 'w')
for inputFile in inputFiles:
inputList.write(inputFile+'\n')
inputList.close()
# create vrt
cmd = 'gdalbuildvrt -separate -input_file_list '+inputListFile+' '+vrtFile
print(cmd)
subprocess.call(cmd, shell=True)
#############################
raster = '/vol/v2/archive/biomass_deflate/{year}/biomassfiaald_20180708_0859_{year}_mean_deflate.tif'
startYear = 1984
endYear = 2017
outFile = '/vol/v2/archive/biomass_time_series_deflate.vrt'
#############################
files = []
for year in range(startYear, endYear+1):
files.append(raster.format(year=str(year)))
files.sort()
make_vrt(files, outFile)