<html>
  <head>
    <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    On 07/29/2014 04:04 PM, Cleo Drakos wrote:<br>
    <blockquote
cite="mid:CAMorJ8EFQw-_84MbnaK5bBKp9jT4bh-55nbOMbaeiKzChiyosg@mail.gmail.com"
      type="cite">
      <div dir="ltr">Thanks for your response.
        <div>I tried the followings:</div>
        <div><br>
        </div>
        <div>
          <div>gcalc =
            'C:\\Users\\cleo\\Documents\\gdalpys\\gdal_calc.py'</div>
          <div>##I produced second file (b)as the copy of first(a)<br>
          </div>
          <div>a = 'D:\\a.tif'</div>
          <div>b = 'D:\\b.tif'</div>
          <div>outfile = 'D:\\result.tif'</div>
          <div>expr = '(A-B)/(A+B)'</div>
          <div>subprocess.call([sys.executable,gcalc,'-A',a,'--A_band','1','-B',b,'--B_band','0','--outfile',outfile,\</div>
          <div>   
            '--calc',expr,'--type','Float32','--format','ENVI'],shell=True)
             </div>
          <div>a,b,outfile = None, None,None</div>
        </div>
        <div><br>
        </div>
        <div>Unfortunately, resulted file is completely black.</div>
        <div><br>
        </div>
        <div>I hope someone can help me.</div>
      </div>
    </blockquote>
    <br>
    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.<br>
    <br>
    Best,<br>
    Vincent.<br>
    <br>
    <blockquote
cite="mid:CAMorJ8EFQw-_84MbnaK5bBKp9jT4bh-55nbOMbaeiKzChiyosg@mail.gmail.com"
      type="cite">
      <div dir="ltr">
        <div class="gmail_extra"><br>
          <br>
          <div class="gmail_quote">On Tue, Jul 29, 2014 at 10:37 PM,
            Etienne Tourigny <span dir="ltr"><<a
                moz-do-not-send="true"
                href="mailto:etourigny.dev@gmail.com" target="_blank">etourigny.dev@gmail.com</a>></span>
            wrote:<br>
            <blockquote class="gmail_quote" style="margin:0 0 0
              .8ex;border-left:1px #ccc solid;padding-left:1ex">
              <div dir="ltr">I am not sure, but you can do the following
                to make sure:
                <div><br>
                </div>
                <div>cp infile infile2</div>
                <div>
                  <span
                    style="font-family:arial,sans-serif;font-size:13px">gdal_calc.py
                    -A infile --A_band 1 -B infile2 --B_band 0 --outfile
                    outfile --calc "(A-B)/(A+B)" </span><br>
                </div>
                <div><span
                    style="font-family:arial,sans-serif;font-size:13px"><br>
                  </span></div>
                <div><span
                    style="font-family:arial,sans-serif;font-size:13px">Also,
                    perhaps the extra comma in your command might be to
                    blame "</span><font face="arial, sans-serif">-B
                    infile,"</font></div>
                <div><font face="arial, sans-serif"><br>
                  </font></div>
                <div><font face="arial, sans-serif">Etienne</font></div>
              </div>
              <div class="gmail_extra"><br>
                <br>
                <div class="gmail_quote">
                  <div>
                    <div class="h5">On Tue, Jul 29, 2014 at 3:46 AM,
                      Cleo Drakos <span dir="ltr"><<a
                          moz-do-not-send="true"
                          href="mailto:cleo21drakos@gmail.com"
                          target="_blank">cleo21drakos@gmail.com</a>></span>
                      wrote:<br>
                    </div>
                  </div>
                  <blockquote class="gmail_quote" style="margin:0 0 0
                    .8ex;border-left:1px #ccc solid;padding-left:1ex">
                    <div>
                      <div class="h5">
                        <div dir="ltr">Hi GDAL Developers,<br>
                          <br>
                          I have one GeoTIFF file with 2 bands. The data
                          type is Byte. I want to calculate
                          (Band2-Band1)/(Band2+Band1).<br>
                          <br>
                          But the following command provided a dark
                          image:<br>
                          <br>
                          gdal_calc.py -A infile --A_band 1 -B infile,
                          --B_band 0 --outfile outfile --calc
                          "(A-B)/(A+B)" <br>
                          <br>
                          Does gdal_calc.py not calculate arithmetic
                          with in the same file?<br>
                          <br>
                          Thanks for your time.<span><font
                              color="#888888"><br>
                              <br>
                              cleo<br>
                            </font></span></div>
                        <br>
                      </div>
                    </div>
                    _______________________________________________<br>
                    gdal-dev mailing list<br>
                    <a moz-do-not-send="true"
                      href="mailto:gdal-dev@lists.osgeo.org"
                      target="_blank">gdal-dev@lists.osgeo.org</a><br>
                    <a moz-do-not-send="true"
                      href="http://lists.osgeo.org/mailman/listinfo/gdal-dev"
                      target="_blank">http://lists.osgeo.org/mailman/listinfo/gdal-dev</a></blockquote>
                </div>
              </div>
            </blockquote>
          </div>
        </div>
      </div>
      <br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <br>
      <pre wrap="">_______________________________________________
gdal-dev mailing list
<a class="moz-txt-link-abbreviated" href="mailto:gdal-dev@lists.osgeo.org">gdal-dev@lists.osgeo.org</a>
<a class="moz-txt-link-freetext" href="http://lists.osgeo.org/mailman/listinfo/gdal-dev">http://lists.osgeo.org/mailman/listinfo/gdal-dev</a></pre>
    </blockquote>
    <br>
  </body>
</html>