[gdal-dev] Does gdal_calc.py not calculate arithmetic with in the same file?

Cleo Drakos cleo21drakos at gmail.com
Tue Jul 29 07:04:04 PDT 2014


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_band','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.


On Tue, Jul 29, 2014 at 10:37 PM, Etienne Tourigny <etourigny.dev at gmail.com>
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 <cleo21drakos at gmail.com>
> 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
>> gdal-dev at lists.osgeo.org
>> http://lists.osgeo.org/mailman/listinfo/gdal-dev
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20140729/93322117/attachment-0001.html>


More information about the gdal-dev mailing list