Hello everybody,
I’m actually computing a large amount of LAI / FAPAR for Sentinel-2 data. Due to the amount of region I have I am using snappy to automatize all my work.
My problem is that the computation of those two vegetation information is really long. For each location I have a shapefile associated and I noticed that I can’t subset my image before processing the LAI : it says "RuntimeError: org.esa.snap.core.gpf.OperatorException: Missing band at 560.0 nm"
.
I saw that for the creation of the biophysical factors, all the metadata was needed so I added it in my subset function that looks like this :
def subset(product,wkt):
parameters = HashMap()
parameters.put('bandNames',product.getBandNames()[0])
parameters.put('geoRegion',wkt)
parameters.put('copyMetadata',True)
return GPF.createProduct('Subset',parameters,product)
And here my functions for computing the factors :
def biophysicalProcessor(product, LAI = True, FAPAR = False, FCOVER = False, CAB = False, CW = False):
parameters = HashMap()
parameters.put('computeLAI', LAI)
parameters.put('computeFapar', FAPAR)
parameters.put('computeFcover', FCOVER)
parameters.put('computeCab', CAB)
parameters.put('computeCw', CW)
return GPF.createProduct('BiophysicalOp',parameters,product)
def resample(product, targetRes):
parameters = HashMap()
parameters.put('targetResolution', targetRes)
return GPF.createProduct('Resample',parameters,product)
def BIOFactors(file, dst, res=10, wkt = None, LAI = True, FAPAR = False, FCOVER = False, CAB = False, CW = False) :
X = read(file)
X = resample(X, res)
if wkt != None :
WKT = WKTReader().read(wkt)
X = subset(X, WKT)
X = biophysicalProcessor(X, LAI = LAI,
FAPAR = FAPAR,
FCOVER = FCOVER,
CAB = CAB,
CW = CW)
if not os.path.isfile(dst) :
save_file(X,dst,'GeoTIFF')
return dst
Maybe my subset function is not good to fit with the biophysicalProcessor function …
But I tried on snap and there was no problem in subseting first before computing the LAI.
So if you have any idea to permit to subset before computing it will help me to save a lot of time !
Thanks in advance for your answers.