[GRASS-user] Checking if a raster is in current MAPSET

Greetings

I have a Py script where I do some processing. But, I want to limit it to the files that are available in my current mapset. How can I do this? I mean, I just to evaluate if the input is in the current/active MAPSET?

Thanks

Best regards
Monica

Monica Buescu wrote:

I have a Py script where I do some processing. But, I want to limit it to
the files that are available in my current mapset. How can I do this? I
mean, I just to evaluate if the input is in the current/active MAPSET?

grass.script.find_file() is a wrapper for g.findfile. Either check the
returned mapset or use the mapset= argument. You can use
grass.script.gisenv() to determine the current mapset.

--
Glynn Clements <glynn@gclements.plus.com>

Hello Glynn

Hum it sounds interesting. How can I parameterize it? I mean, what is the order of the parameters?

About the current mapset I’m already using it thanks :slight_smile:

PS- Where can I find a list of avaliable functions in grass.python?
Monica

On Fri, Oct 15, 2010 at 2:59 PM, Glynn Clements <glynn@gclements.plus.com> wrote:

Monica Buescu wrote:

I have a Py script where I do some processing. But, I want to limit it to
the files that are available in my current mapset. How can I do this? I
mean, I just to evaluate if the input is in the current/active MAPSET?

grass.script.find_file() is a wrapper for g.findfile. Either check the
returned mapset or use the mapset= argument. You can use
grass.script.gisenv() to determine the current mapset.


Glynn Clements <glynn@gclements.plus.com>

Monica Buescu wrote:

Hum it sounds interesting. How can I parameterize it? I mean, what is the
order of the parameters?

    > help(grass.find_file)
    Help on function find_file in module grass.script.core:
    
    find_file(name, element='cell', mapset=None)
        !Returns the output from running g.findfile as a
        dictionary. Example:
        
        \code
        >>> result = grass.find_file('fields', element = 'vector')
        >>> print result['fullname']
        fields@PERMANENT
        >>> print result['file']
        /opt/grass-data/spearfish60/PERMANENT/vector/fields
        \endcode
        
        @param name file name
        @param element element type (default 'cell')
        @param mapset mapset name (default all mapsets in search path)
        
        @return parsed output of g.findfile

About the current mapset I'm already using it thanks :slight_smile:

PS- Where can I find a list of avaliable functions in grass.python?
Monica

    > import grass.script
    > help(grass.script)
    > help(grass.script.core)
    ...

Although reading the .py files in a text editor may be simpler.

--
Glynn Clements <glynn@gclements.plus.com>