<div dir="ltr">While += using multiple image arguments is not handled there is a Mean() function which will calculate the mean of all bands. However, you first need to reorganize the images so rather than X images of N bands each you will have N images of X bands each.<div><br></div><div>#################################<br></div><div># open up all of your files as a GeoImages object:</div><div>images = GeoImages([filenameslist])<br><div><br></div><div># create empty image</div><div><div>images_out = GeoImages()</div><div><br></div><div>for i in range(0, images.NumImages()):<br></div><div> for b in range(0, images[0].NumBands()):</div><div> images_out[b].AddBand(images[i][b])</div><div><br></div><div># create output image (create output image with same # of bands</div><div>mean_image = GeoImage('mean_image.tif', image_out[0])</div><div><br></div><div>for b in range(0, mean_image.NumBands()):</div><div> images_out[b].Mean(mean_image[b])</div><div>#################################</div><div><br></div><div>That's untested, but hopefully helps. I had started a convenience function to do some of this rearranging between bands and images, will take a look at that again.</div><div><br></div><div>As far as the other questions</div><div><br></div><div>- you can remove bands and prune an image</div><div><br></div><div># remove band number (number is 1-based)</div><div>img.RemoveBand(1)</div><div># remove bands except for red and NIR</div><div>img.PruneBands(['Red', 'NIR'])</div><div><br></div><div><br></div><div>In the code above when you create a GeoImage and then addbands...the bands are still stored on their original file, and GeoImage is just holding the file pointers to the right layer in each of those files. </div><div><br></div><div>You can use the GDAL MEM driver. The procedure for changing the format is weird - you have to set the gippy default format option:</div><div>gippy.Options.SetDefaultFormat('MEM')</div><div><br></div><div>Then create the image as normal. The plan is to change the global options to an options class that can be handed into the constructor of a new GeoImage, so you can easily change options per object.</div><div><br></div><div>Hope this helps!</div><div><br></div><div><br></div><div><br></div><div><br></div></div></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Jun 16, 2015 at 10:19 AM, Bobby Braswell <span dir="ltr"><<a href="mailto:rbraswell@appliedgeosolutions.com" target="_blank">rbraswell@appliedgeosolutions.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">I have a number of (N) image files with many bands. All have the same spatial properties. For each of those files I need to select one of the bands. Then I need to average all N of the extracted bands together.<br>
<br>
If I knew how many files I had (e.g. 2), then I could do something like<br>
<br>
imgC = 0.5*imgA[12] + 0.5*imgB[12]<br>
<br>
And process the result. But I think “+=“ is not handled by gippy, so I’m not sure the best way to do this in the case where I don’t know how many images I have.<br>
<br>
Related questions:<br>
<br>
Can I select (slice) bands from a geoimage and discard others?<br>
<br>
Can I create a geoimage to hold just the extracted bands that is not tied to a file on disk, or that is tied to memory or some temporary space?<br>
<br>
_______________________________________________<br>
GIPS mailing list<br>
<a href="mailto:GIPS@lists.osgeo.org">GIPS@lists.osgeo.org</a><br>
<a href="http://lists.osgeo.org/cgi-bin/mailman/listinfo/gips" rel="noreferrer" target="_blank">http://lists.osgeo.org/cgi-bin/mailman/listinfo/gips</a><br>
</blockquote></div><br></div>