1

I want to make a 32-days composite from 8-days LST data by taking its average value, but I am facing a problem in checking QC-day, the other thing is, due to data gaps (missing DN values) we cannot take its average simply (DN1+DN2+DN3)/3 etc because due to data gaps some value are missing.My problem is when I add all the four images and then divide them by 4 it doesn't give the average values because of missing values. for exp. (2+8+6+0)/4, fourth pixel is missing, how can i exclude the missing values and specify the average of existing values? if someone knows any code/proper method, please share and help me

  • You only specified python: Are you loading the 8-day LST composites into numpy arrays and use those for processing? – Kersten Jul 8 '15 at 14:18
  • Thanks for your reply, method doesn't matter, I just need to process the data. Any method (procedure/code/tool) is okay. if you have in numpy arrays, please share – Shahid Naeem Jul 9 '15 at 9:25
1

You specified python, So I am assuming you are familiar how to use GDAL to load the images into numpy arrays. This assumes that you stacked 4 8-day composites into a 3D numpy array, where each layer along the z-axis represents one image (just like if you would stack them as a multilayer image).

import numpy as np

# load your data into a 3D numpy array of the shape(layer, Y, X)
composite8_stack  # this is your image stack, as produced by gdal.ReadAsArray()

no_data = -32768  # insert the NoData value of you images here

composite8_stack[composite8_stack == no_data] = np.NaN  #replace NoData values

# calculate the mean along the z-axis while ignoring NoData values
composite32 = np.nanmean(composite8_stack, axis=0)

The numpy function nanmean along axis=0 (the z-axis, layers) does exactly what you want - calculating the mean only from valid observations. Using this it should be easy to loop through your list of images, read 4 8-day composites at a time and produce the 32-day composite from them.

0

Reclassify 0 as NoData. If you are using arcpy you need spatial analyst extension.

  • Thanks for your reply but its a 16-years data (768 images) sp it is not possible to do it manually, if you have any code/script using any language, please share....... – Shahid Naeem Jul 9 '15 at 9:21
0

In ARCPY use Cell Statistics, you just need ignore NoData http://desktop.arcgis.com/en/arcmap/10.3/tools/spatial-analyst-toolbox/cell-statistics.htm

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.