[GRASS-dev] Help - run r.profile through python

Hi all,

I need some help since I'm new using GRASS functions through python.

I'm trying to use the function r.profile.

My code:

from grass.script import raster as grass

os.chdir('F:\GEOSTORM\Python scripts')

grass.run_command("r.profile",-g,input= teste1,output = teste, [12244.256
-295112.597,12128.012 -295293.77])

However I'm having the following error mesage:

"non-keyword arg after keyword arg grass.run_command"

Does someone can help me to write the correct code to call the r.profile
function from GRASS.

Best regards,

Pedro

--
View this message in context: http://osgeo-org.1803224.n2.nabble.com/Help-run-r-profile-through-python-tp5707457p5707457.html
Sent from the Grass - Dev mailing list archive at Nabble.com.

On Fri, Nov 5, 2010 at 1:35 AM, melolp <melolp@gmail.com> wrote:

Hi all,

I need some help since I'm new using GRASS functions through python.

I'm trying to use the function r.profile.

My code:

from grass.script import raster as grass

os.chdir('F:\GEOSTORM\Python scripts')

grass.run_command("r.profile",-g,input= teste1,output = teste, [12244.256
-295112.597,12128.012 -295293.77])

However I'm having the following error mesage:

"non-keyword arg after keyword arg grass.run_command"

I think that you need something like this (untested):

    grass.run_command("r.profile", flags = "g" , input = teste1, output = teste,
                     profile = "12244.256,-295112.597,12128.012,-295293.77")

Markus

melolp wrote:

grass.run_command("r.profile",-g,input= teste1,output = teste, [12244.256 -295112.597,12128.012 -295293.77])

However I'm having the following error mesage:

"non-keyword arg after keyword arg grass.run_command"

All arguments except the first are keyword arguments, i.e. "arg = val".

  grass.run_command(
    "r.profile",
Okay
    -g,

This should be: flags = 'g'. "-g" would be the negative of a Python
variable namd "g".

    input= teste1,
    output = teste,
Okay
    [12244.256 -295112.597,12128.012 -295293.77])

This should be:
    profile = [12244.256,-295112.597,12128.012,-295293.77]
or:
    profile = [(12244.256,-295112.597),(12128.012,-295293.77)]

i.e. you need to provide the keyword, and the argument must be a valid
Python expression. run_command() etc accept lists and tuples.

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