<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<p>Javier,</p>
<p>yes I've came across similarly looking grid files occasionally.
I'm not quite sure which ancestor format is behind. This is a bit
similar to the IGN France ASCII grid .mnt format documented at
<a class="moz-txt-link-freetext" href="https://geodesie.ign.fr/contenu/fichiers/documentation/grilles/notices/Grilles-MNT-TXT_Formats.pdf">https://geodesie.ign.fr/contenu/fichiers/documentation/grilles/notices/Grilles-MNT-TXT_Formats.pdf</a>,
except it has extra fields in the header to document the number of
values per node, etc. Or actually, the closest would be the .gra
format that was used at a time for older IGNF grids (like
<a class="moz-txt-link-freetext" href="https://geodesie.ign.fr/contenu/fichiers/documentation/grilles/outremer/RAR07_bl.gra">https://geodesie.ign.fr/contenu/fichiers/documentation/grilles/outremer/RAR07_bl.gra</a>),
which is identical to your sample, except that the values of the
header in .gra are split on 3 lines... and the order of longitudes
and latitudes are switched... Both were handled by the
IGNFHeightASCIIGrid driver that was retired in
<a class="moz-txt-link-freetext" href="https://github.com/OSGeo/gdal/commit/87721936b700b7e6a1ce52fba33d24c995c12472">https://github.com/OSGeo/gdal/commit/87721936b700b7e6a1ce52fba33d24c995c12472</a>
and moved to OSGeo/gdal-extra-drivers in
<a class="moz-txt-link-freetext" href="https://github.com/OSGeo/gdal-extra-drivers/commit/3db74a53b6ee6a0eb6645a0e4ecab31af7215600">https://github.com/OSGeo/gdal-extra-drivers/commit/3db74a53b6ee6a0eb6645a0e4ecab31af7215600</a>
. Reason being that IGNF releases one grid every few years, so I'm
fine spending 1 minute to build an out of tree driver when
needed. Given the lack of any metadata key, it is quite difficult
to write a reliable automatic driver because of all the potential
variants on the header field order.</p>
<p>Even<br>
</p>
<p><br>
</p>
<div class="moz-cite-prefix">Le 22/07/2024 à 18:17, Javier Jimenez
Shaw via gdal-dev a écrit :<br>
</div>
<blockquote type="cite"
cite="mid:CADRrdKtdHWRJ3eAdj7xGt8sr+dfzC9dU_fLunWskX7N8MSMQFg@mail.gmail.com">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<div dir="ltr">
<div>Hi</div>
<div><br>
</div>
<div>I have seen some raster files with this format<br>
</div>
<br>
<div><span style="font-family:monospace">-4.983333 14.983333
-79.983333 -66.016667 0.03333333333333333
0.03333333333333333<br>
-5.258 -5.301 -5.345 -5.393 -5.444 -5.499 -5.555 -5.615
-5.682 -5.752 -5.823 -5.886 -5.938 -5.986 -6.036 -6.093
-6.157 -6.226 -6.296 -6.358 -6.413 -6.462 -6.516 -6.574
-6.636 -6.700 -6.761 -6.819 -6.868 -6.901 -6.933 -6.962
-7.004 -7.069 -7.156 -7.263 -7.374 -7.479 -7.581 -7.669
-7.748 -7.814 -7.873 -7.923 -7.973 -8.027 -8.084 -8.143
-8.208 -8.278 -8.355 -8.447 -8.552 -8.670 -8.790 -8.911</span><br>
</div>
<div>... <br>
</div>
<div>The first line (six numbers) is the bounding box (4) and
the grid steps (2), all in degrees.</div>
<div>Then all the pixel values (as in AAIGrid format).</div>
<div><br>
</div>
<div>If I try to run gdalinfo, I get<br>
</div>
<div>
<div><br>
</div>
<div><span style="font-family:monospace">ERROR 1: Maximum
number of characters allowed reached.<br>
ERROR 1: Couldn't determine X spacing<br>
gdalinfo failed - unable to open 'file.txt'.</span></div>
<div><br>
</div>
<div>However, if I change the first line with this command to
convert it into a <a
href="https://gdal.org/drivers/raster/aaigrid.html"
moz-do-not-send="true" class="moz-txt-link-freetext">https://gdal.org/drivers/raster/aaigrid.html</a>
, is works</div>
<div><br>
</div>
<div><span style="font-family:monospace">awk 'NR==1 {print
"NCOLS "($4-$3)/$6+1 "\nNROWS "($2-$1)/$5+1 "\nXLLCENTER
"$3 "\nYLLCENTER "$1 "\nCELLSIZE "$6} NR>1 {print $0}'
<source_file></span><br>
</div>
</div>
<div>
<div>
<div><br>
</div>
<div>Producing something like this:<br>
</div>
</div>
</div>
<div><br>
</div>
<div><span style="font-family:monospace">NCOLS 420<br>
NROWS 600<br>
XLLCENTER -79.983333<br>
YLLCENTER -4.983333<br>
CELLSIZE 0.03333333333333333<br>
-5.258 -5.301 -5.345 -5.393 -5.444 -5.499 -5.555 -5.615
-5.682 -5.752 -5.823 -5.886 -5.938 -5.986 -6.036 -6.093
-6.157 -6.226 -6.296 -6.358 -6.413 -6.462 -6.516 -6.574
-6.636 -6.700 -6.761 -6.819 -6.868 -6.901 -6.933 -6.962
-7.004 -7.069 -7.156 -7.263 -7.374 -7.479 -7.581 -7.669
-7.748 -7.814 -7.873 -7.923 -7.973 -8.027 -8.084 -8.143
-8.208 -8.278 -8.355 -8.447 -8.552 -8.670 -8.790 -8.91</span></div>
<div><span style="font-family:monospace">...</span></div>
<div><br>
</div>
<div>See that I am assuming that the coordinates in the first
line are at the pixel center.</div>
<div><br>
</div>
<div>Do you know what is that initial format? Is it a
"variation" of "AAIGrid -- Arc/Info ASCII Grid"? Something
else? Is it worth it to add it to GDAL? (maybe the awk script
is enough)<br>
</div>
<div><br>
</div>
<div>Thanks<br>
</div>
<div>
<div dir="ltr" class="gmail_signature"
data-smartmail="gmail_signature">
<div dir="ltr">
<div>.___ ._ ..._ .. . ._. .___ .. __ . _. . __.. ...
.... ._ .__</div>
</div>
</div>
</div>
</div>
<br>
<fieldset class="moz-mime-attachment-header"></fieldset>
<pre class="moz-quote-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="https://lists.osgeo.org/mailman/listinfo/gdal-dev">https://lists.osgeo.org/mailman/listinfo/gdal-dev</a>
</pre>
</blockquote>
<pre class="moz-signature" cols="72">--
<a class="moz-txt-link-freetext" href="http://www.spatialys.com">http://www.spatialys.com</a>
My software is free, but my time generally not.</pre>
</body>
</html>