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

Jukka Rahkonen jukka.rahkonen at mmmtike.fi
Tue Jul 29 09:53:08 PDT 2014


Cleo Drakos <cleo21drakos <at> gmail.com> writes:

> 
> 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.
Have you checked from the histogram that the result is totally black? I
could imagine that bands 1 (A) and 2 (B) can have values close to each 
other which makes that A-B is close to zero. That divided by A+B makes
the values even closer to zero and if such Float32 type image is opened 
in an image viewer without LUT stretch that could well appear as 
totally black. Forget all this if you have checked the histograms.

-Jukka Rahkonen-




More information about the gdal-dev mailing list