脚本的目的是将影像重采样到与参考影像同一大小,配合上篇博文使用更佳。
# -*- coding: utf-8 -*-
"""
Created on Sun Jul 21 11:22:59 2019
@author: Minty
"""
from osgeo import gdal, gdalconst
#import os
import sys
args = sys.argv
if len(args)!=4:
print("Invalid parameters.")
print("Please input:")
print("Input path of raster to be resampled")
print("Input path of reference raster")
print("Output path of resampled raster")
sys.exit(1)
print ('参数个数为:', len(args), '个参数。')
print ('参数列表:', str(args))
inputfile = args[1]
referencefile = args[2]
outputfile = args[3]
inputras = gdal.Open(inputfile,gdal.GA_ReadOnly)
inputProj = inputras.GetProjection()
inputTrans = inputras.GetGeoTransform()
reference = gdal.Open(referencefile,gdal.GA_ReadOnl