[POSIBLESPAM]: [GRASS-user] test if raster/vector exists (in Perl)
Hamish
hamish_nospam at yahoo.com
Tue Aug 14 20:46:50 EDT 2007
Mark wrote:
> 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 }.
José Antonio Ruiz Arias wrote:
> 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.
You can also test g.findfile's return code, it returns 0 if the file was
found, 1 if not.
Hamish
More information about the grass-user
mailing list