[GRASS-user] Importing ASCII file

Hamish hamish_b at yahoo.com
Wed Jun 27 15:20:23 PDT 2012


Daniel wrote:
> I'm having a lot of trouble importing some ASCII data into
> GRASS. The data is pretty large (each file is 3.7 GB and I've
> got a ton of them) and has the ending *.asc. It seems like a
> perfect case for r.in.arc,

indeed, r.in.arc is the right tool for the job.

> but r.in.arc isn't working. Here's some info:
>
> Command output:
> r.in.arc input=/home/lee/co2/daten/gcm_results/prec_1.asc
> output=prec_1
>
> Illegal latitude for North
> ERROR: Can't get cell header
>
> The cell header looks pretty tame. The contents:
> ncols         43200
> nrows         18000
> xllcorner     -180
> yllcorner     -60
> cellsize      0.0083333337679505
> NODATA_value  -9999

the problem is with broken cellsize value, resulting in a
latitude beyond the north pole.

>> 0.0083333337679505 * 18000 - 60
ans =      90.000007823109

which is > 90.

it seems that whatever software exported it (don't be afraid to
name names :) was holding or calculating the resolution with
single-precision floating point numbers but exporting it as if
it were a double-precision number. So the second half the number
is inexact jibberish.

Edit the cell size back to 0.008333333 (no small feat with a
3.7gb file, even for vi) and it'll work.


Importing with GDAL would give the same illegal-north latitude
result, although r.in.gdal now has a '-l' flag to reset the
northern boundary into something legal (after which you Must
repair it to the real value with r.region), although you could
get the same effect by editing the header to lie about the
cellsize or southern value to get it to fit into legal lat/lon,
then again use r.region to set the bounds exactly. (the
resolution as seen with r.info should end up exactly at 30 arc-
sec; bypass the built in failsafe checks at your own risk)
But the real solution is to get the software that created it
to not export broken files.


If works in QGIS because QGIS doesn't maintain an idea about
polar coordinate systems, it just sees everything in Cartesian
space and even a latitude of 500000 won't worry it. (which, fwiw,
is why raster-wrap at 180 longitude and geodesic lines work easily
in GRASS but not QGIS) [not to single out QGIS, most other
software don't do it either]


Hamish


More information about the grass-user mailing list