[GRASS-user] Python Script- Check if a raster exists

Hi

I’m doing a python script and, in a process, I need to check if a raster map exists. My idea is, if this map exists I don’t need to create otherwise, I need to create it (v.to.rast). Is there a way to check if a map exists in the current mapset?
Thanks
Helena

Try e.g “g.findfile element=vector file=testmap”

Christian

From: Helena Herrera
Sent: Monday, September 27, 2010 12:25 PM
To: grass-user@lists.osgeo.org
Subject: [GRASS-user] Python Script- Check if a raster exists

Hi

I’m doing a python script and, in a process, I need to check if a raster map exists. My idea is, if this map exists I don’t need to create otherwise, I need to create it (v.to.rast). Is there a way to check if a map exists in the current mapset?
Thanks
Helena



grass-user mailing list
grass-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-user

Uhm. I have tried that one with
g.findfile element=raster file=L (I have a raster map named L in my mapset) and I get:

name=
mapset=
fullname=
file=
Which would mean that it doesn’t exist.

is there any other way to do this for GRASS-pythons scripts?

On Mon, Sep 27, 2010 at 11:39 AM, Christian Schwartze <christian.schwartze@uni-jena.de> wrote:

Try e.g “g.findfile element=vector file=testmap”

Christian

From: Helena Herrera
Sent: Monday, September 27, 2010 12:25 PM
To: grass-user@lists.osgeo.org
Subject: [GRASS-user] Python Script- Check if a raster exists

Hi

I’m doing a python script and, in a process, I need to check if a raster map exists. My idea is, if this map exists I don’t need to create otherwise, I need to create it (v.to.rast). Is there a way to check if a map exists in the current mapset?
Thanks
Helena



grass-user mailing list
grass-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-user

See the notes and output sections of the g.findfile manpage. There you can find additional information how to use the comand in scripts.
http://grass.fbk.eu/gdp/html_grass64/g.findfile.html

Christian.

From: Helena Herrera
Sent: Monday, September 27, 2010 12:47 PM
To: Christian Schwartze ; grass-user@lists.osgeo.org
Subject: Re: [GRASS-user] Python Script- Check if a raster exists

Uhm. I have tried that one withg.findfile element=raster file=L (I have a raster map named L in my mapset) and I get:

name=
mapset=
fullname=
file=
Which would mean that it doesn’t exist.

is there any other way to do this for GRASS-pythons scripts?

On Mon, Sep 27, 2010 at 11:39 AM, Christian Schwartze <christian.schwartze@uni-jena.de> wrote:

Try e.g “g.findfile element=vector file=testmap”

Christian

From: Helena Herrera
Sent: Monday, September 27, 2010 12:25 PM
To: grass-user@lists.osgeo.org
Subject: [GRASS-user] Python Script- Check if a raster exists

Hi

I’m doing a python script and, in a process, I need to check if a raster map exists. My idea is, if this map exists I don’t need to create otherwise, I need to create it (v.to.rast). Is there a way to check if a map exists in the current mapset?
Thanks
Helena



grass-user mailing list
grass-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-user