[GRASS-user] Python scripts using rules

Greetings

I’m doing a processing that requires setting rules such as : IF band1> 1 output=5 if band<=1 ouput= 3 and if band2>5 output=7. How can I do this in a Python script in order to be “almost automatic”?

Thanks

Best regards
Luisa

Hi,

2010/6/22 Luisa Peña <luisapena1979@gmail.com>:

Greetings
I'm doing a processing that requires setting rules such as : IF band1> 1
output=5 if band<=1 ouput= 3 and if band2>5 output=7. How can I do this in a
Python script in order to be "almost automatic"?

if band1 > 1:
   output = 5
else:
   output = 3

if band2 > 5:
   output = 7

Martin

--
Martin Landa <landa.martin gmail.com> * http://gama.fsv.cvut.cz/~landa

Hi Martin
Maybe I was not clear enough. this is a procedding to be done over each pixel. Can I apply this sort of code to a pixel based analysis?

2010/6/22 Martin Landa <landa.martin@gmail.com>

Hi,

2010/6/22 Luisa Peña <luisapena1979@gmail.com>:

Greetings
I’m doing a processing that requires setting rules such as : IF band1> 1
output=5 if band<=1 ouput= 3 and if band2>5 output=7. How can I do this in a
Python script in order to be “almost automatic”?

if band1 > 1:
output = 5
else:
output = 3

if band2 > 5:
output = 7

Martin


Martin Landa <landa.martin gmail.com> * http://gama.fsv.cvut.cz/~landa

Hi,

2010/6/22 Luisa Peña <luisapena1979@gmail.com>:

Maybe I was not clear enough. this is a procedding to be done over each
pixel. Can I apply this sort of code to a pixel based analysis?

mapcalc() from grass.script.raster [1] or try ctypes interface from trunk.

Martin

[1] http://download.osgeo.org/grass/grass7_progman/namespacepython_1_1raster.html#a0f8268995af8d19e6b86e1f67295aaaf

--
Martin Landa <landa.martin gmail.com> * http://gama.fsv.cvut.cz/~landa

Hi Martin
Thanks
You mean like using an expression, for mapcalc, based on ifs right? Is this interface available for GRASS6.4? If so, is there an example of usage?

And about the ctypes interface? What is it? can it work on GRASS6.4.0 RC6?

Thanks
Luisa

2010/6/22 Martin Landa <landa.martin@gmail.com>

Hi,

2010/6/22 Luisa Peña <luisapena1979@gmail.com>:

Maybe I was not clear enough. this is a procedding to be done over each
pixel. Can I apply this sort of code to a pixel based analysis?

mapcalc() from grass.script.raster [1] or try ctypes interface from trunk.

Martin

[1] http://download.osgeo.org/grass/grass7_progman/namespacepython_1_1raster.html#a0f8268995af8d19e6b86e1f67295aaaf

Martin Landa <landa.martin gmail.com> * http://gama.fsv.cvut.cz/~landa

Hi Martin
Thanks
You mean like using an expression, for mapcalc, based on ifs right? Is this interface available for GRASS6.4? If so, is there an example of usage?

And about the ctypes interface? What is it? can it work on GRASS6.4.0 RC6?

Thanks
Luisa

2010/6/22 Martin Landa <landa.martin@gmail.com>

Hi,

2010/6/22 Luisa Peña <luisapena1979@gmail.com>:

Maybe I was not clear enough. this is a procedding to be done over each
pixel. Can I apply this sort of code to a pixel based analysis?

mapcalc() from grass.script.raster [1] or try ctypes interface from trunk.

Martin

[1] http://download.osgeo.org/grass/grass7_progman/namespacepython_1_1raster.html#a0f8268995af8d19e6b86e1f67295aaaf

Martin Landa <landa.martin gmail.com> * http://gama.fsv.cvut.cz/~landa