[GRASS-user] Conversion of multiple rasters to PNG files
Hamish
hamish_b at yahoo.com
Tue Apr 12 03:30:19 EDT 2011
Mortsde wrote:
> I'm relatively new to GRASS/unix style commands and was
> wondering if anyone
> had a quick PERL script that could convert LOTS of raster maps to PNG
> files without the repetition of going through one by one. I'm not much
> of a programmer otherwise I'd write some kind of loop and have a go.
> The general form of my rasters is already in a "Name_$Date" style
> format so I think this
> should be pretty easy? I'm attempting to make video files that illustrate
> soil saturation with time. I have about 10 years (daily) of soil moisture
> that I'm looking to animate so it's a digestible amount of information.
some shell script loop scripts here:
http://grass.osgeo.org/wiki/Movies
but none of those really strike me as beginner-friendly. (mea culpa)
the general idea is:
# set up region
g.region rast=
# use g.mlist to list all relevant maps
g.mlist rast pattern=
# eg throw those map names into a loop
my @maps = system(g.mlist rast pat=soils.*);
my @maps = `g.mlist rast pat=soils.*`;
for my $m (@maps) {
print $m;
`d.erase`;
`d.rast $m`;
...
`d.out.file $png_name`
...
}
probably it is good to first run through a loop of all the maps with
'r.info -r' and get the overall range, then create color rules covering
that entire range and in a loop apply it to all maps with r.colors.
that way the color scale stats the same.
Hamish
More information about the grass-user
mailing list