[Qgis-user] Colour properties of raster layers

Maciej Sieczka tutey at o2.pl
Fri Mar 28 08:47:52 PDT 2008


Rosenkranz, Brigitte Christine pisze:

> I just started using Q-Gis and I have problems with using the color
> maps for my raster layers. I have a huge amount of ASCI grid raster
> files (elevation data from Danmark) and I try to open as much
> files/layers as possible at once. It seems like per default the
> chosen color map is greyscale. I would like to open my files in a
> customer defined colormap. I would also like to define the customer
> color map in a different way then it is default. Because I have a
> huge amount of files it is very unconvenient to open the properties
> for each layer.
> 
> Now my question is comming d:o) Is there any possibility to define
> these settings for all raster layers at once? So that I don't have to
> klick 9000 times for having the same colours in all my layers?

I assume you mean ArcInfo ASCII grids (AAIGrid in GDAL lingo) and they 
have a uniform extension (say *.asc).

If using GRASS GIS on a GNU/Linux box is an option for you, you might do 
the following:


0. Setup a location with coordinate system matching your grids.

1. Import all AAIGrid into GRASS (consider using flag -o in r.in.gdal, 
if your grids have a malformed prj or don't have it at all):

for i in *.asc; do r.in.gdal in=$i out=`basename $i`; done

2. Assign same colortable to all grids (refer to r.color manual for 
available colortables):

for i in `g.mlist type=rast patt=*`; do r.colors rast=$i 
color=any_you_like; done

3. Export grids. The colortables will be stored in xml files which QGIS 
(via GDAL) understands. Refer to r.out.gdal manual to choose a correct 
data type. As a bonus each AAIGrid will have a valid prj file (if you 
make step 0 right):

for i in `g.mlist type=rast patt=*`; g.region rast=$i -a; r.out.gdal 
in=$i out=$i.asc format=AAIGrid type=your_data_type; done

You might consider exporting to a different format.

Maciek



More information about the Qgis-user mailing list