1

I am trying to read in multiple (hundreds, thousand) LiDAR ascii files into GRASS 6.4.1. 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

572000-7144000_dem_1m.asc
572000-7145000_dem_1m.asc
572000-7146000_dem_1m.asc

etc.

How do I read in multiple files?

I have tried concatenating them with no luck.

1
  • 1
    If the proposal by @MarkusN below worked, convention is for you to please accept the answer. Commented Dec 21, 2018 at 9:04

1 Answer 1

6

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
done
# 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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.