[gdal-dev] Unknown ASCII raster format

Javier Jimenez Shaw j1 at jimenezshaw.com
Mon Jul 22 09:17:36 PDT 2024


Hi

I have seen some raster files with this format

-4.983333 14.983333 -79.983333 -66.016667 0.03333333333333333
0.03333333333333333
-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
...
The first line (six numbers) is the bounding box (4) and the grid steps
(2), all in degrees.
Then all the pixel values (as in AAIGrid format).

If I try to run gdalinfo, I get

ERROR 1: Maximum number of characters allowed reached.
ERROR 1: Couldn't determine X spacing
gdalinfo failed - unable to open 'file.txt'.

However, if I change the first line with this command to convert it into a
https://gdal.org/drivers/raster/aaigrid.html , is works

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>

Producing something like this:

NCOLS 420
NROWS 600
XLLCENTER -79.983333
YLLCENTER -4.983333
CELLSIZE 0.03333333333333333
-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
...

See that I am assuming that the coordinates in the first line are at the
pixel center.

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)

Thanks
.___ ._ ..._ .. . ._.  .___ .. __ . _. . __..  ... .... ._ .__
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20240722/825ccc19/attachment.htm>


More information about the gdal-dev mailing list