Le mercredi 30 juillet 2014 05:54:48, Cleo Drakos a écrit : > Dear all: > > The problem I was facing has been solved. I detected that the problem was > with the band number '0'. Solution is: the band number starts from '1'. > > But, the gdal documentation says that the default band number is '0'. > http://www.gdal.org/gdal_calc.html > > The documentation should be corrected, I think.
Fixed. Thanks > > The default band number is '1'. > > Thanks. > > cleo > > > On Wed, Jul 30, 2014 at 11:15 AM, Jeremy Palmer <[email protected]> > > wrote: > > Hi Cleo, > > > > Just been dealing with this type of issue. > > > > > > > > It’s likely that the byte datatype is overflowing. > > > > > > > > Try something like: > > > > > > > > --calc "(A.astype(int)-B.astype(int))/(A.astype(int)+B.astype(int))" > > > > > > > > Actually you might only need to cast one of the bands from byte to int, > > so the syntax could be: > > > > > > > > --calc "(A.astype(int)-B A.astype(int)+B)" > > > > > > > > Cheers > > Jeremy > > > > > > > > *From:* [email protected] [mailto: > > [email protected]] *On Behalf Of *Cleo Drakos > > *Sent:* Wednesday, 30 July 2014 2:06 p.m. > > *To:* Vincent Schut > > *Cc:* gdal-dev > > *Subject:* Re: [gdal-dev] Does gdal_calc.py not calculate arithmetic with > > in the same file? > > > > > > > > Even if I converted the input file into Float 32 at first, the resulted > > image is still totally black. > > > > cleo > > > > On Tue, Jul 29, 2014 at 11:20 PM, Vincent Schut <[email protected]> > > wrote: > > > > On 07/29/2014 04:04 PM, Cleo Drakos wrote: > > Thanks for your response. > > > > I tried the followings: > > > > > > > > gcalc = 'C:\\Users\\cleo\\Documents\\gdalpys\\gdal_calc.py' > > > > ##I produced second file (b)as the copy of first(a) > > > > a = 'D:\\a.tif' > > > > b = 'D:\\b.tif' > > > > outfile = 'D:\\result.tif' > > > > expr = '(A-B)/(A+B)' > > > > > > subprocess.call([sys.executable,gcalc,'-A',a,'--A_band','1','-B',b,'--B_b > > and','0','--outfile',outfile,\ > > > > '--calc',expr,'--type','Float32','--format','ENVI'],shell=True) > > > > a,b,outfile = None, None,None > > > > > > > > Unfortunately, resulted file is completely black. > > > > > > > > I hope someone can help me. > > > > > > > > I don't use gdal_calc myself, but I suppose the problem is the byte > > datatype. I would try to convert the input data to float32 first (use > > gdal_translate -ot Float32) and try again. > > > > Best, > > Vincent. > > > > > > > > > > > > > > On Tue, Jul 29, 2014 at 10:37 PM, Etienne Tourigny < > > [email protected]> wrote: > > > > I am not sure, but you can do the following to make sure: > > > > > > > > cp infile infile2 > > > > gdal_calc.py -A infile --A_band 1 -B infile2 --B_band 0 --outfile outfile > > --calc "(A-B)/(A+B)" > > > > > > > > Also, perhaps the extra comma in your command might be to blame "-B > > infile," > > > > > > > > Etienne > > > > > > > > On Tue, Jul 29, 2014 at 3:46 AM, Cleo Drakos <[email protected]> > > > > wrote: > > Hi GDAL Developers, > > > > I have one GeoTIFF file with 2 bands. The data type is Byte. I want to > > calculate (Band2-Band1)/(Band2+Band1). > > > > But the following command provided a dark image: > > > > gdal_calc.py -A infile --A_band 1 -B infile, --B_band 0 --outfile outfile > > --calc "(A-B)/(A+B)" > > > > Does gdal_calc.py not calculate arithmetic with in the same file? > > > > Thanks for your time. > > > > cleo > > > > > > > > _______________________________________________ > > 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 > > > > > > > > > > _______________________________________________ > > gdal-dev mailing list > > [email protected] > > http://lists.osgeo.org/mailman/listinfo/gdal-dev > > > > > > > > ------------------------------ > > This message contains information, which may be in confidence and may be > > subject to legal privilege. If you are not the intended recipient, you > > must not peruse, use, disseminate, distribute or copy this message. If > > you have received this message in error, please notify us immediately > > (Phone 0800 665 463 or [email protected]) and destroy the original > > message. LINZ accepts no responsibility for changes to this email, or > > for any > > attachments, after its transmission from LINZ. Thank You. -- Geospatial professional services http://even.rouault.free.fr/services.html _______________________________________________ gdal-dev mailing list [email protected] http://lists.osgeo.org/mailman/listinfo/gdal-dev
