<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>

    <meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
  </head>
  <body bgcolor="#ffffff" text="#000000">
    Hi,<br>
    <br>
    we encountered a problem with decimal precision when converting a
    SAGA grid to ESRI ASCII.<br>
    <br>
    I expect the problem arising from ASCII to double conversion by
    atof() and/or from the Geotransform (pixel as point to pixel as
    area).<br>
    <br>
    The SAGA header looks like<br>
    <br>
    POSITION_XMIN&nbsp;&nbsp; = 12181.8000000000
    <br>
    POSITION_YMIN&nbsp;&nbsp; = 219184.8800000000<br>
    CELLSIZE&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = 1.0000000000
    <br>
    <br>
    The final ESRI ASCII header looks like<br>
    <br>
    xllcorner&nbsp;&nbsp;&nbsp; 12181.299999999999
    <br>
    yllcorner&nbsp;&nbsp;&nbsp; 219184.380000000005
    <br>
    <br>
    instead of<br>
    xllcorner&nbsp;&nbsp;&nbsp; 12181.3<br>
    yllcorner&nbsp;&nbsp;&nbsp; 219184.38<br>
    <br>
    How is this problem handled in other drivers (using strtod(),
    stringstream, ...)?<br>
    <br>
    The relevant lines of code in sagadataset.cpp
    (<a class="moz-txt-link-freetext" href="http://trac.osgeo.org/gdal/browser/trunk/gdal/frmts/saga/sagadataset.cpp">http://trac.osgeo.org/gdal/browser/trunk/gdal/frmts/saga/sagadataset.cpp</a>)
    are:<br>
    <br>
    <a
href="http://trac.osgeo.org/gdal/browser/trunk/gdal/frmts/saga/sagadataset.cpp#L406">406</a>&nbsp;
    &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; dXmin <span class="o">=</span>&nbsp;atof<span class="p">(</span>papszTokens<span
      class="p">[</span><span class="mi">1</span><span class="p">]);<br>
    </span><a
href="http://trac.osgeo.org/gdal/browser/trunk/gdal/frmts/saga/sagadataset.cpp#L408">408</a>&nbsp;
    &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; dYmin <span class="o">=</span>&nbsp;atof<span class="p">(</span>papszTokens<span
      class="p">[</span><span class="mi">1</span><span class="p">]);<br>
    </span><a
href="http://trac.osgeo.org/gdal/browser/trunk/gdal/frmts/saga/sagadataset.cpp#L410">410</a>&nbsp;
    &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; dCellsize <span class="o">=</span>&nbsp;atof<span class="p">(</span>papszTokens<span
      class="p">[</span><span class="mi">1</span><span class="p">]);<br>
      <br>
    </span><a
href="http://trac.osgeo.org/gdal/browser/trunk/gdal/frmts/saga/sagadataset.cpp#L601">601</a>&nbsp;
    &nbsp; &nbsp; &nbsp; padfGeoTransform<span class="p">[</span><span class="mi">0</span><span
      class="p">]</span>&nbsp;<span class="o">=</span>&nbsp;poGRB<span class="o">-&gt;</span>m_Xmin
    <span class="o">-</span>&nbsp;poGRB<span class="o">-&gt;</span>m_Cellsize
    <span class="o">/</span>&nbsp;<span class="mi">2</span><span class="p">;</span><br>
    <a
href="http://trac.osgeo.org/gdal/browser/trunk/gdal/frmts/saga/sagadataset.cpp#L602">602</a>&nbsp;
    &nbsp; &nbsp; &nbsp; padfGeoTransform<span class="p">[</span><span class="mi">3</span><span
      class="p">]</span>&nbsp;<span class="o">=</span>&nbsp;poGRB<span class="o">-&gt;</span>m_Ymin
    <span class="o">+</span>&nbsp;<span class="p">(</span>nRasterYSize <span
      class="o">-</span>&nbsp;<span class="mi">1</span><span class="p">)</span>&nbsp;<span
      class="o">*</span>&nbsp;poGRB<span class="o">-&gt;</span>m_Cellsize <span
      class="o">+</span>&nbsp;poGRB<span class="o">-&gt;</span>m_Cellsize <span
      class="o">/</span>&nbsp;<span class="mi">2</span><span class="p">;</span><br>
    <span class="p"><br>
      <br>
    </span><br>
    Thanks,<br>
    Volker<br>
    <br>
  </body>
</html>