That's because numpy.median expects one array and keyword arguments, not three arrays. It's unclear to me what gdal_calc.py does under the hood (I admit I did not read it) but the correct way to get the median of the three bands would be: --calc median([A,B,C], 0) The strange part is that--calc median([A,B,C])works as well and generates a different output. When axis is not specified median should return a single value. At this point I suggest you take three 2D arrays, calculate their median as a 2D array, convert the three arrays to rasters, run gdal_calc.py and compare results. -marius
Date: Tue, 25 Nov 2014 17:56:46 +0900 From: [email protected] To: [email protected] CC: [email protected] Subject: Re: [gdal-dev] gdal_calc.py: produce median raster Dear Dr Chris Yesson Thanks for your quick response. I got the following error: ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()` Perhaps the expression for calc seems to be revised... On Tue, Nov 25, 2014 at 4:59 PM, Chris Yesson <[email protected]> wrote: Dear Simen, You can refer to each band explicitly using the --A_band option.Try something like this gdal_calc.py -A infile --A_band 1 -B infile --B_band 2 -C infile --C_band 3 --outfile outfile --calc median(A,B,C) - ChrisDr Chris Yesson Institute of Zoology, Zoological Society of LondonTel: 020 7449 6267 email: [email protected] web: http://www.zsl.org/chrisyesson/ Note: I work Mon-Thurs and do not check email on Fri On 25 November 2014 at 07:44, Simen Langseth <[email protected]> wrote: Dear Respected Authors: I would be grateful if you could share any hints on it. On Tue, Nov 25, 2014 at 4:33 PM, Simen Langseth <[email protected]> wrote: Dear Marius Jigmond: Thanks for your attempt. Unfortunately, it is producing 3 band outfile, rather than 1 band median image. I could not figure out what this code computed, all the resulted 3 bands images are also different. I hope someone can help me. On Tue, Nov 25, 2014 at 12:09 PM, Marius Jigmond <[email protected]> wrote: Does the following work: gdal_calc.py -A infile --allBands=A --outfile=outfile --calc="median(A)" Date: Mon, 24 Nov 2014 19:14:06 +0900 From: [email protected] To: [email protected] Subject: [gdal-dev] gdal_calc.py: produce median raster I have one GeoTiff file with 3 bands. I want to produce a raster file computing pixel wise median value for the three raster bands. How can I do that? I tried as follows: gdal_calc.py -A infile --allBands --outfile outfile --calc median(A) But could not get any out file. _______________________________________________ gdal-dev mailing list [email protected] http://lists.osgeo.org/mailman/listinfo/gdal-dev This message has been scanned for viruses by MailControl, a service from BlackSpider Technologies. Click here to report this email as spam. The Zoological Society of London is incorporated by Royal Charter Principal Office England. Company Number RC000749 Registered address: Regent's Park, London, England NW1 4RY Registered Charity in England and Wales no. 208728 _________________________________________________________________________ This e-mail has been sent in confidence to the named addressee(s). If you are not the intended recipient, you must not disclose or distribute it in any form, and you are asked to contact the sender immediately. Views or opinions expressed in this communication may not be those of The Zoological Society of London and, therefore, The Zoological Society of London does not accept legal responsibility for the contents of this message. The recipient(s) must be aware that e-mail is not a secure communication medium and that the contents of this mail may have been altered by a third party in transit. If you have any issues regarding this mail please contact: [email protected]. ___________________________________________________________________________ This message has been scanned for viruses by MailControl, a service from BlackSpider Technologies. _______________________________________________ gdal-dev mailing list [email protected] http://lists.osgeo.org/mailman/listinfo/gdal-dev
_______________________________________________ gdal-dev mailing list [email protected] http://lists.osgeo.org/mailman/listinfo/gdal-dev
