pack up your GRASS raster layer

What if you  want to get a number of raster maps from a mapset to bring with you? Or you want to back up a number of layers, but not the whole mapset? Of course you can export it as e.g., an ascii or geotiff, but that won’t save the colour table, attributes, etc. So what then? Well, check out the r.pack package. It provides a script that compresses a raster layer, including colour table etc.  You can restore the raster map from the export file to the same or another computer using the accompanying add-on r.unpack.

For example, I have a large number of temporary raster layers in my mapset ConsStat. I don’t need them any more, but I want to keep a backup. So I just package them using r.pack. The following will take care of that, with the last line deleting the layers from my mapset.

MAP=`g.mlist type=rast pattern=tmp* mapset=ConsStat`
for maps in $MAP ; do
    r.pack input=$maps
done
g.mremove -f rast=tmp*

GRASS GIS has an amazing number of functions. But if what you need is not there, like an easy way to export and restore GRASS maps, you might want to check out the GRASS AddOns wiki page. It list a large number of add ons, offering all kind of different functions. Note that part of these add ons can be found and installed using the g.extensions function (menu | settings | install extensions from from add-ons).

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s