<!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 = 12181.8000000000
<br>
POSITION_YMIN = 219184.8800000000<br>
CELLSIZE = 1.0000000000
<br>
<br>
The final ESRI ASCII header looks like<br>
<br>
xllcorner 12181.299999999999
<br>
yllcorner 219184.380000000005
<br>
<br>
instead of<br>
xllcorner 12181.3<br>
yllcorner 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>
dXmin <span class="o">=</span> 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>
dYmin <span class="o">=</span> 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>
dCellsize <span class="o">=</span> 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>
padfGeoTransform<span class="p">[</span><span class="mi">0</span><span
class="p">]</span> <span class="o">=</span> poGRB<span class="o">-></span>m_Xmin
<span class="o">-</span> poGRB<span class="o">-></span>m_Cellsize
<span class="o">/</span> <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>
padfGeoTransform<span class="p">[</span><span class="mi">3</span><span
class="p">]</span> <span class="o">=</span> poGRB<span class="o">-></span>m_Ymin
<span class="o">+</span> <span class="p">(</span>nRasterYSize <span
class="o">-</span> <span class="mi">1</span><span class="p">)</span> <span
class="o">*</span> poGRB<span class="o">-></span>m_Cellsize <span
class="o">+</span> poGRB<span class="o">-></span>m_Cellsize <span
class="o">/</span> <span class="mi">2</span><span class="p">;</span><br>
<span class="p"><br>
<br>
</span><br>
Thanks,<br>
Volker<br>
<br>
</body>
</html>