<div dir="ltr"><div><div>Good afternoon, </div><div><br></div><div>I work with Qgis 3.40. </div><br>I have a question almost similar to <a href="https://gis.stackexchange.com/questions/338888/calculating-the-average-of-multiple-bands-of-raster-with-high-number-of-bands-in">this post</a>. But i would like to caculate the median instead of the average/median. From one single raster with 90 bands, i would like generate a new raster file with the median value for each pixel. The median has to be calculated from all the 90 bands for each pixel.<br><br>Following still <a href="https://gis.stackexchange.com/questions/338888/calculating-the-average-of-multiple-bands-of-raster-with-high-number-of-bands-in">this post </a>succeed in calculating the average from the 90 bands thanks to this following python qgis script : <br><br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">    rasterlayer = QgsProject.instance().mapLayersByName('infra-red')[0] #Change infra-red to the name of your layer<br>    bandcount = rasterlayer.bandCount() #Count the bands<br>    <br>    tempexp = ['"{0}@{1}"'.format(<a href="http://rasterlayer.name">rasterlayer.name</a>(), bandnum) for bandnum in range(1,bandcount+1)] #['"infra-red@1"', '"infra-red@2"', '"infra-red@3"', '"infra-red@4"']<br>    tempexp = '+'.join(tempexp) #'"infra-red@1"+"infra-red@2"+"infra-red@3"+"infra-red@4"'<br>    exp = '('+tempexp+')/{0}'.format(bandcount) #'("infra-red@1"+"infra-red@2"+"infra-red@3"+"infra-red@4")/4'<br>    <br>    processing.runAndLoadResults("qgis:rastercalculator", <br>        {'EXPRESSION':exp,'LAYERS':[rasterlayer.source()],'CELLSIZE':None,'EXTENT':None,'CRS':None,'OUTPUT':'TEMPORARY_OUTPUT'})</blockquote><br>Is there a way to do the same thing but this time to calculate the median value ? <br><br></div><div>Thanks so much. </div><div>Regards.</div></div>