[GRASS-user] Re: Trying python scripts.

Marcello Gorini gorini at gmail.com
Thu May 27 18:07:11 EDT 2010


Marcello Gorini wrote:
[...]
> >>> ... I am trying to run the first examples found in 
> >>> http://grass.osgeo.org/wiki/GRASS_and_Python.

--%<---
a script was here - look first post !
--->%--

> >>> It seems to run OK and “100%” is displayed in the GRASS prompt, but
> >>> when I tried to display the map, I found out that it wasn't created at
> >>> all.

Nikos Alexandris:
> >> If there are no errors and the script ran fine, maybe you just need to
> >> check the region settings?

> >>> Just for you to know, to run the script I simply create it (say
> >>> "myscript.py"), give permissions and run it in a GRASS session with
> the
> >>> necessary options:
> >>> > ./myscript.py output=outmap raster1=map1 raster2=map2

> >>> I am using Ubuntu 9.04 64bits and GRASS 6.4.ORC5.

> >> For example:
> >> # check region extent, etc.
> >> g.region -p
> >> 
> >> # set region extent and resolution to the map of your interest
> >> g.region rast=outmap -pa
> >> 
> >> # give color
> >> r.colors rast=outmap color=rainbow
> >> 
> >> # try to display
> >> d.mon x0 && d.rast outmap
> >> 
> >> # is it there?

Marcello Gorini: 
> >> No, it is not there. To make sure I set the region to the input map:
> >> 
> >> g.region rast=map1 -pa
> >> d.mon x0 && d.rast map1

> >> OK, it is there. Then I ran the script:
> >> ./myscript.py output=outmap raster1=map1 raster2=map2

> >> After processing, I tried:
> >> d.rast outmap

> >> But then:
> >> ERROR: Raster map <outmap> not found

> >> What could be wrong?

Nikos Alexandris:
>>Marcello, not sure why it does not work for you. I (copied over the script 
>>from the 1st post in this thread as test_mapcalc.py, added +x to make it 
>>executable) and it works fine for me:

>># test run
>>python test_mapcalc.py raster1=mod_b2 raster2=mod_b2_new 
>>output=testing_mapcalc_python_script

>># r.info on inputs and the output

>># mod_b2
>>r.info -r mod_b2

>>min=0
>>max=5504

>># mod_b2_new
>>r.info -r mod_b2_new

>>min=0
>>max=0.5504

>># output
>>r.info -r testing_mapcalc_python_script

>>min=0
>>max=5504.5504

> >> P.S.: By the way, is this the right way to quote answers?

>>Like (almost) always, it depends whom you are asking ;-). There are so
many
>>ways and opinions and habits and... (you can scan the archive or other
mailing
>>lists and you'll find that people even argue seriously about the "correct"
way
>>to reply).

>>Personally I got stuck with _clean_ in-line bottom posting because I find
it.
>>so useful when I read older threads and understand what has been discussed
and
>>get to the point right away.

>>I prefer to invest time and clean-out un-necessary stuff (taking though
>>sometimes the risk to reject parts that are important?) and give a logical
>>flow to the discussion (first the question, then the answer) in order to
make
>>it easier for any (next) reader.

>>Regards, Nikos 

Hello Nikos,


Thanks for the try. I tested it again with other rasters, but I got the same
error.
Could it possibly be something related to the 64bits architecture? Or could
GRASS be sending the outcome somewhere else?
Well, I guess that eventually I will go around this problem or even bump
into the solution, but the most important thing to say is that I appreciated
the effort and that it was a very good reception to this list. 
Thank you very much Nikos. And thank you also for the explanations with
respect to the right way to answer posts. I will do my best to make my posts
as clean and explanatory as possible.

Best regards,
Marcello.
_______________________________________________
grass-user mailing list
grass-user at lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-user



-- 
View this message in context: http://osgeo-org.1803224.n2.nabble.com/Trying-python-scripts-tp5109105p5110760.html
Sent from the Grass - Users mailing list archive at Nabble.com.


More information about the grass-user mailing list