[GRASS-user] Importing ASCII file

Dear list,

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, 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 output of g.region -p:
g.region -p
projection: 3 (Latitude-Longitude)
zone: 0
datum: wgs84
ellipsoid: wgs84
north: 90N
south: 90S
west: 180W
east: 180E
nsres: 1
ewres: 1
rows: 180
cols: 360
cells: 64800

Looks like it should work, right? Does anybody have any ideas? I’ve be really grateful for any help :slight_smile:

Best,
Daniel

B.Sc. Daniel Lee
Geschäftsführung für Forschung und Entwicklung
ISIS - International Solar Information Solutions GbR
Vertreten durch: Daniel Lee, Nepomuk Reinhard und Nils Räder

Softwarecenter 3
35037 Marburg
Festnetz: +49 6421 379 6256
Mobil: +49 176 6127 7269
E-Mail: Lee@isi-solutions.org
Web: http://www.isi-solutions.org

On Wed, 27 Jun 2012, Daniel Lee wrote:

I'm having a lot of trouble importing some ASCII data into GRASS. It seems
like a perfect case for r.in.arc, but r.in.arc isn't working. Here's some
info:

Daniel,

   From the 6.5 manual r. index:

r.in.arc Converts an ESRI ARC/INFO ascii raster file (GRID) into a
     (binary) raster map layer.
r.in.ascii Converts ASCII raster file to binary raster map layer.

   Try r.in.ascii.

Rich

--
Richard B. Shepard, Ph.D. | Integrity - Credibility - Innovation
Applied Ecosystem Services, Inc. | Helping Ensure Our Clients' Futures
<http://www.appl-ecosys.com> Voice: 503-667-4517 Fax: 503-667-8863

Hi Rich,

Thanks for the tip. Unfortunately, r.in.ascii is made for files with another type of header. Nonetheless, I tried it and here’s the output:

r.in.ascii input=/home/lee/co2/daten/gcm_results/prec_1.asc output=test
“north” field missing from header
“south” field missing from header
“east” field missing from header
“west” field missing from header
“rows” field missing from header
“cols” field missing from header
Illegal row value
ERROR: Can’t get cell header

Those values aren’t in the header though and the requirements of r.in.arc match the header :frowning: QGIS manages to open it, but I don’t know how to script it and it’s quite a large number of datasets.

Any other ideas? Does anyone have experience with opening and exporting rasters in QGIS from a script? That would make things a bit easier, otherwise it takes a good 5 minutes or so to open each file.

Thanks!
Daniel

B.Sc. Daniel Lee
Geschäftsführung für Forschung und Entwicklung
ISIS - International Solar Information Solutions GbR
Vertreten durch: Daniel Lee, Nepomuk Reinhard und Nils Räder

Softwarecenter 3
35037 Marburg
Festnetz: +49 6421 379 6256
Mobil: +49 176 6127 7269
E-Mail: Lee@isi-solutions.org
Web: http://www.isi-solutions.org

2012/6/27 Rich Shepard <rshepard@appl-ecosys.com>

On Wed, 27 Jun 2012, Daniel Lee wrote:

I’m having a lot of trouble importing some ASCII data into GRASS. It seems

like a perfect case for r.in.arc, but r.in.arc isn’t working. Here’s some
info:

Daniel,

From the 6.5 manual r. index:

r.in.arc Converts an ESRI ARC/INFO ascii raster file (GRID) into a
(binary) raster map layer.
r.in.ascii Converts ASCII raster file to binary raster map layer.

Try r.in.ascii.

Rich


Richard B. Shepard, Ph.D. | Integrity - Credibility - Innovation
Applied Ecosystem Services, Inc. | Helping Ensure Our Clients’ Futures
<http://www.appl-ecosys.com> Voice: 503-667-4517 Fax: 503-667-8863


grass-user mailing list
grass-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-user

On Wed, 27 Jun 2012, Daniel Lee wrote:

Thanks for the tip. Unfortunately, r.in.ascii is made for files with
another type of header. Nonetheless, I tried it and here's the output:

Daniel,

   Then I've no idea how to advise you to proceed.

   I'm sure others have the solution for you.

Good luck,

Rich

--
Richard B. Shepard, Ph.D. | Integrity - Credibility - Innovation
Applied Ecosystem Services, Inc. | Helping Ensure Our Clients' Futures
<http://www.appl-ecosys.com> Voice: 503-667-4517 Fax: 503-667-8863

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 27/06/12 18:36, Daniel Lee wrote:

Hi Rich,

Thanks for the tip. Unfortunately, r.in.ascii is made for files with another type of header.
Nonetheless, I tried it and here's the output:

r.in.ascii input=/home/lee/co2/daten/gcm_results/prec_1.asc output=test "north" field missing
from header "south" field missing from header "east" field missing from header "west" field
missing from header "rows" field missing from header "cols" field missing from header Illegal
row value ERROR: Can't get cell header

Those values aren't in the header though and the requirements of r.in.arc match the header :frowning:
QGIS manages to open it, but I don't know how to script it and it's quite a large number of
datasets.

Any other ideas? Does anyone have experience with opening and exporting rasters in QGIS from a
script? That would make things a bit easier, otherwise it takes a good 5 minutes or so to open
each file.

What about gdal? Check with gdalinfo which format it is, and then use r.in.gdal to import it - I
guess qgis is using gdal to import the files.

Cheers,

Rainer

Thanks! Daniel

--

B.Sc. Daniel Lee Geschäftsführung für Forschung und Entwicklung ISIS - International Solar
Information Solutions GbR Vertreten durch: Daniel Lee, Nepomuk Reinhard und Nils Räder

Softwarecenter 3 35037 Marburg Festnetz: +49 6421 379 6256 Mobil: +49 176 6127 7269 E-Mail:
Lee@isi-solutions.org <mailto:Lee@isi-solutions.org> Web: http://www.isi-solutions.org
<http://www.isi-solutions.org/&gt;

2012/6/27 Rich Shepard <rshepard@appl-ecosys.com <mailto:rshepard@appl-ecosys.com>>

On Wed, 27 Jun 2012, Daniel Lee wrote:

I'm having a lot of trouble importing some ASCII data into GRASS. It seems

like a perfect case for r.in.arc, but r.in.arc isn't working. Here's some info:

Daniel,

From the 6.5 manual r. index:

r.in.arc Converts an ESRI ARC/INFO ascii raster file (GRID) into a (binary) raster map
layer. r.in.ascii Converts ASCII raster file to binary raster map layer.

Try r.in.ascii.

Rich

-- Richard B. Shepard, Ph.D. | Integrity - Credibility - Innovation Applied
Ecosystem Services, Inc. | Helping Ensure Our Clients' Futures
<http://www.appl-ecosys.com> Voice: 503-667-4517 <tel:503-667-4517> Fax: 503-667-8863
<tel:503-667-8863>

_________________________________________________ grass-user mailing list
grass-user@lists.osgeo.org <mailto:grass-user@lists.osgeo.org>
http://lists.osgeo.org/__mailman/listinfo/grass-user
<http://lists.osgeo.org/mailman/listinfo/grass-user&gt;

_______________________________________________ grass-user mailing list
grass-user@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/grass-user

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk/rSNgACgkQoYgNqgF2egphcACfRtCQ8LHhTjC2hBjXcZzRwOUy
uQAAn3NCvz7yexJm0RHz+NwUreQfamWW
=wQPa
-----END PGP SIGNATURE-----

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 27/06/12 18:36, Daniel Lee wrote:

Hi Rich,

Thanks for the tip. Unfortunately, r.in.ascii is made for files with another type of header.
Nonetheless, I tried it and here's the output:

r.in.ascii input=/home/lee/co2/daten/gcm_results/prec_1.asc output=test "north" field missing
from header "south" field missing from header "east" field missing from header "west" field
missing from header "rows" field missing from header "cols" field missing from header Illegal
row value ERROR: Can't get cell header

I just checked - I have files with the extension .asc which start as follow:

ncols 790
nrows 210
xllcorner 574000
yllcorner 6242000
cellsize 100.000000
NODATA_value -9999
- -9999 -9999 -9999 -9999 ...

and I read them in via r.in.arc and it works ...

As I said, try the gdal, maybe more robust?

Rainer

Those values aren't in the header though and the requirements of r.in.arc match the header :frowning:
QGIS manages to open it, but I don't know how to script it and it's quite a large number of
datasets.

Any other ideas? Does anyone have experience with opening and exporting rasters in QGIS from a
script? That would make things a bit easier, otherwise it takes a good 5 minutes or so to open
each file.

Thanks! Daniel

--

B.Sc. Daniel Lee Geschäftsführung für Forschung und Entwicklung ISIS - International Solar
Information Solutions GbR Vertreten durch: Daniel Lee, Nepomuk Reinhard und Nils Räder

Softwarecenter 3 35037 Marburg Festnetz: +49 6421 379 6256 Mobil: +49 176 6127 7269 E-Mail:
Lee@isi-solutions.org <mailto:Lee@isi-solutions.org> Web: http://www.isi-solutions.org
<http://www.isi-solutions.org/&gt;

2012/6/27 Rich Shepard <rshepard@appl-ecosys.com <mailto:rshepard@appl-ecosys.com>>

On Wed, 27 Jun 2012, Daniel Lee wrote:

I'm having a lot of trouble importing some ASCII data into GRASS. It seems

like a perfect case for r.in.arc, but r.in.arc isn't working. Here's some info:

Daniel,

From the 6.5 manual r. index:

r.in.arc Converts an ESRI ARC/INFO ascii raster file (GRID) into a (binary) raster map
layer. r.in.ascii Converts ASCII raster file to binary raster map layer.

Try r.in.ascii.

Rich

-- Richard B. Shepard, Ph.D. | Integrity - Credibility - Innovation Applied
Ecosystem Services, Inc. | Helping Ensure Our Clients' Futures
<http://www.appl-ecosys.com> Voice: 503-667-4517 <tel:503-667-4517> Fax: 503-667-8863
<tel:503-667-8863>

_________________________________________________ grass-user mailing list
grass-user@lists.osgeo.org <mailto:grass-user@lists.osgeo.org>
http://lists.osgeo.org/__mailman/listinfo/grass-user
<http://lists.osgeo.org/mailman/listinfo/grass-user&gt;

_______________________________________________ grass-user mailing list
grass-user@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/grass-user

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk/rSg4ACgkQoYgNqgF2egqDVwCcDcPjxlgBCeKosEBqMthvh8J4
/00An02EcYMFwxw+z6IvS+p48xros2Yy
=GHGx
-----END PGP SIGNATURE-----

Rainer,

Good idea. Here’s the output of gdalinfo:

gdalinfo prec_1.asc
Driver: AAIGrid/Arc/Info ASCII Grid
Files: prec_1.asc
Size is 43200, 18000
Coordinate System is `’
Origin = (-180.000000000000000,90.000000000000000)
Pixel Size = (0.008333333333333,-0.008333333333333)
Corner Coordinates:
Upper Left (-180.0000000, 90.0000000)
Lower Left (-180.0000000, -60.0000000)
Upper Right ( 180.0000000, 90.0000000)
Lower Right ( 180.0000000, -60.0000000)
Center ( 0.0000000, 15.0000000)
Band 1 Block=43200x1 Type=Int32, ColorInterp=Undefined
NoData Value=-9999

So it looks like Arc/Info ASCII grid is correct.

Hamish,

you’re right, editing the cell size even with vi would be painful. I wouldn’t be afraid to name names about the software, but the fact of the matter is that I don’t know what software it is. I downloaded the data from http://www.ccafs-climate.org/data/

In any case, using the -l flag did the trick! Thanks a ton, that makes my day :slight_smile: Case closed!

Best,
Daniel