Try with g.findfile element=cell file=<your_raster_name> in a Perl pipe.
If the module returns a series of empty strings, your raster does not exist.
I used it in Python in a way like this:
if os.popen(g.findfile element=cell file=%s %
<raster_name>,r).readlines()[0][:-1].split(=)[1]:
<the raster exists>
else:
<the raster does not exist>
although you use Perl I suppose it will be similar (I hope).
Cheers,
Jose A.
De: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
En nombre de M S
Enviado el: martes, 14 de agosto de 2007 18:42
Para: GRASS user list
Asunto: [POSIBLESPAM]: [GRASS-user] test if raster/vector exists (in Perl)
I have a Perl program that loops through the r.lake module, and captures
output. In the program, there are a few instances where I would like to
test if a given raster already exists. In perl, its something like this to
test if a file exists ... if (-e "filename") { do stuff }.
is there a way to use this feature against a raster? Otherwise, I was going
to do something like r.info and pipe the output to a file. then search that
the file for some keyword indicating it exists or doesnt exist.
any other ideas or approaches?
thanks,
Mark
_______________________________________________
grassuser mailing list
[email protected]
http://grass.itc.it/mailman/listinfo/grassuser