imageutils.subset(inND4, contextvect, outND4, 'GTiff', rsgislib.TYPE_8INT) except: input("imageutils.subset not working") gdwarpcmd = "gdalwarp -cutline {c} -crop_to_cutline {i} {out}".format( c=contextvect, i=inND4.replace("TOSHIBA EXT", "TOSHIBA\ EXT"), out=outND4) print(gdwarpcmd) subprocess.call(gdwarpcmd, shell=True) if not (MGSmode): try: # if possible, work in rsgislib but fall back on gdalwarp if needed if not (os.path.isfile(DTMband)): imageutils.selectImageBands( inDTM, DTMband, 'GTiff', rsgislib.TYPE_32FLOAT, [2]) imageutils.subset(DTMband, contextvect, outDTM, 'GTiff', rsgislib.TYPE_32FLOAT) except: input( "imageutils.selectImageBands or imageutils.subset not working" ) gdwarpcmd = "gdalwarp -cutline {c} -crop_to_cutline {i} {out}".format( c=contextvect, i=DTMband.replace("TOSHIBA EXT", "TOSHIBA\ EXT"), out=outDTM) print(gdwarpcmd) subprocess.call(gdwarpcmd, shell=True) else: try:
def selectImageBands(inImage, outImage, bandList): gdalFormat = 'KEA' dataType = rsgislib.TYPE_32FLOAT imageutils.selectImageBands(inImage, outImage, gdalFormat, dataType, bandList)