Take the 2-minute tour ×

I am trying to read in multiple (hundreds, thousand) LiDAR ascii files into Grass. They contain elevation data. I think I have managed one, and I can make a map of elevations, using File, Import Raster Map, Multiple formats using GDAL. The format is as follows:

ncols         1000
nrows         1000
xllcorner     562000.000
yllcorner     7124000.000
cellsize      1
nodata_value  -9999.0
108.93 108.92 108.97 108.99 109 109.01...

1000 lines, 1000 columns, representing 1 sq km with values at every 1 m. Files are called



My question is, how do Y read in multiple files? I have tried concatenating them, no luck.

Thank you for your help.. regards, Szilard

share|improve this question

1 Answer 1

You can simply import them in a loop like this:

for myfile in `ls 5*-7*_dem_1m.asc` ; do
  # remove .asc extension
  outname=`basename $myfile .asc`
  # import current file
  r.in.gdal input=$myfile output=$outname
# mosaik the tiles
r.patch input=`g.mlist rast pattern="5*-7*_dem_1m" sep=","` output=dem_1m
# colorize the result
r.colors dem_1m color=elevation

Note: if you had a more recent GRASS GIS version, use r.external instead of r.in.gdal to just register the files rather than physically importing them.

Eventually, remove the individual imported files with g.mremove and the above mentioned pattern. Done.

For a user interface solution (select by click), see Importing multiple raster (e.g., GeoTIFF) files

share|improve this answer

Your Answer


