[POSIBLESPAM]: [GRASS-user] test if raster/vector exists (in Perl)

José Antonio Ruiz Arias jararias at ujaen.es
Tue Aug 14 15:34:19 EDT 2007

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’ %

            <the raster exists>


            <the raster does not exist>


although you use Perl I suppose it will be similar (I hope).




Jose A.



De: grassuser-bounces at grass.itc.it [mailto:grassuser-bounces at grass.itc.it]
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?


-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/grass-user/attachments/20070814/eeadde40/attachment.html

More information about the grass-user mailing list