[GRASSLIST:3798] another scripting question

I'm looking for a little more scripting advice as I put together a couple of tools to handle an image rectifying job. I think I have most of what I need, but I'm stuck on what I perceive as one of the first steps.

Both scripts need to run through all files in a particular mapset.

Therefor my first question is how to step through each map within the current mapset, so that the same procedure can be applied to every one of them? Most of the examples I've found use the map name as an argument specified on the command line.

Any tips?

Thanks,

Kirk

Kirk R. Wythers wrote:

I'm looking for a little more scripting advice as I put together a
couple of tools to handle an image rectifying job. I think I have most
of what I need, but I'm stuck on what I perceive as one of the first
steps.

Both scripts need to run through all files in a particular mapset.

Therefor my first question is how to step through each map within the
current mapset, so that the same procedure can be applied to every one
of them? Most of the examples I've found use the map name as an
argument specified on the command line.

Any tips?

1. List the "cell" directory.

eval `g.gisenv`
ls "$GISDBASE/$LOCATION_NAME/$MAPSET/cell" | while read map ; do
  ... $map
done

2. Parse the output of "g.list rast".

Option 1 is likely to be the easiest; the output of g.list isn't
exactly easy to parse.

--
Glynn Clements <glynn.clements@virgin.net>

> I'm looking for a little more scripting advice as I put together a
> couple of tools to handle an image rectifying job. I think I have
> most of what I need, but I'm stuck on what I perceive as one of the
> first steps.
>
> Both scripts need to run through all files in a particular mapset.
>
> Therefor my first question is how to step through each map within
> the current mapset, so that the same procedure can be applied to
> every one of them? Most of the examples I've found use the map name
> as an argument specified on the command line.
>
> Any tips?

1. List the "cell" directory.

eval `g.gisenv`
ls "$GISDBASE/$LOCATION_NAME/$MAPSET/cell" | while read map ; do
  ... $map
done

May I suggest g.mlist. It works very well these days (it was still a bit
broken in 5.0.3). Besides using wildcards for picking map names, it lets
you use regular expressions too if you want.

for MAP in `g.mlist rast` ; do
    echo "[$MAP]"
done

Hamish

On Thu, Jul 01, 2004 at 11:40:57PM +0100, Glynn Clements wrote:

Kirk R. Wythers wrote:

> I'm looking for a little more scripting advice as I put together a
> couple of tools to handle an image rectifying job. I think I have most
> of what I need, but I'm stuck on what I perceive as one of the first
> steps.
>
> Both scripts need to run through all files in a particular mapset.
>
> Therefor my first question is how to step through each map within the
> current mapset, so that the same procedure can be applied to every one
> of them? Most of the examples I've found use the map name as an
> argument specified on the command line.
>
> Any tips?

1. List the "cell" directory.

eval `g.gisenv`
ls "$GISDBASE/$LOCATION_NAME/$MAPSET/cell" | while read map ; do
  ... $map
done

2. Parse the output of "g.list rast".

Option 1 is likely to be the easiest; the output of g.list isn't
exactly easy to parse.

3. option

Use g.mlist, which is easy to parse.

Markus