Re: [GRASS-user] nviz script don't work

2011-05-18 Thread Maris Nartiss
Hello,
At first - can You use NVIZ without any scripting?
If Yes, then can You, please, send me script file off list? I can take
a look at it.

Some NVIZ parts are quite fragile and thus might be accidentally broken.

Maris.


2011/5/17, Bornemisza Imre b...@freemail.hu:
 Hi, dear GRASS-Users,

 do you have idea, why nviz my fly-script don#39;t plays?

 Environment:

 VMware Player 3.1.3 build-324285 (on WinXP)
 (because I haven#39;t access to install a real Linux)

 Ubuntu 10.04.2-desktop-i386 (because 11.04 was instable)

 the install command was on the just installed Ubuntu:
 sudo apt-get install gdal-bin grass grass-doc

 GRASS version: 6.4.0RC5

 script was made by d.nviz, the running commands:
 d.nviz -ice input=elevation.dem output=fly_01 dist=3000 ht=2000 frames=1000
 nviz command:nviz elevation=elevation.dem vect=roads color=landuse
 script=fly_01.nvscr

 nviz answers:
 
 Loading raster map elevation.dem@PERMANENT...
 100%
 Loading raster map landuse@PERMANENT...
 100%
 Vector map roads@PERMANENT loaded (757 features)
 Entering script mode ...
 DONE!
 
 , but nothing moves.

 (If the answer in the Archives,
 send me please the URL and the method to find it next time.)

 Thanks for your help:
 Imre Bornemisza - born_AT_freemail_DOT_hu
___
grass-user mailing list
grass-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-user


Re: [GRASS-user] Error while exporting

2011-05-18 Thread Glynn Clements

Markus Metz wrote:

  The NULL value of the reclass map is not recognized as NULL value, but
  instead treated as a valid number.
 
  This seems to be a bug in the GRASS library, specifically in
  G_get_null_value_row() and has probably been around since GRASS 6.3.
 
  AFAICT, it has been around as long as G_get_null_value_row() has
  existed. G_get_null_value_row() returns the raw data, without any
  reclass applied.
 
  As it stands, this function probably isn't of much use.
 
 Remove?

No, fix (as per r46323).

If you only care about whether a cell is null or non-null, reading and
decoding the actual data is needless overhead.

If you need to read the data anyhow, then use that rather than reading
the null data a second time (the raw data is cached, but conversion
and masking will be re-done).

r.out.gdal was the latter case, so it shouldn't have been using that
function. OGSF is also the latter case, and should be fixed. 

r.neighbors is the former case (it's used for the the selection=
parameter), so it should be using Rast_get_null_value_row(). There may
be other modules which should be doing this but are actually reading
the data.

-- 
Glynn Clements gl...@gclements.plus.com
___
grass-user mailing list
grass-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-user


Re: [GRASS-user] Creating a coordinate image?

2011-05-18 Thread Glynn Clements

Jonathan Greenberg wrote:

 Is there any way to take a GRASS raster and generate two outputs where
 each pixel is the center coordinate of that pixel (e.g. you will have
 one x- image and one y-image)?  I'm trying to produce a latitude map
 for solar calculations.

r.mapcalc 'xmap = x() ; ymap = y()'

-- 
Glynn Clements gl...@gclements.plus.com
___
grass-user mailing list
grass-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-user


Re: [GRASS-user] Re: Using temp files in Grass Script

2011-05-18 Thread Johannes Radinger

 Original-Nachricht 
 Datum: Tue, 17 May 2011 13:11:41 +0100
 Von: Glynn Clements gl...@gclements.plus.com
 An: Johannes Radinger jradin...@gmx.at
 CC: grass-user@lists.osgeo.org
 Betreff: Re: [GRASS-user] Re: Using temp files in Grass Script

 
 Johannes Radinger wrote:
 
  I found that thread about temporary maps...
  
  e.g in my case in my python script i use:
  
  #Convert river from vector to raster format
  grass.run_command(v.to.rast,
input = river_gen,
overwrite = True,
output = river_raster,
use = val,
value = res)

  #Thinning the rastarized river
  grass.run_command(r.thin,
input = river_raster,
overwrite = True,
output = river_raster_thin)
  
  and here is the map river_raster only temporary for the thinning
  process and the river_raster_thin is used for further calculations.
  At the moment I have a g.remove to remove the river raster after
  the thinning process but should I handle that with temporary files/maps
  and if yes how is that exactly done in my python script?
 
 1. In general, you should make an attempt at ensuring that temporary
 map names won't conflict with any existing map name. The usual
 approach is to include both .tmp and the PID in the map name, e.g.:
 
   import os
   ...
   global tmpmap
   tmp_map = 'river_raster.tmp.%d' % os.getpid()
 
 2. Deletion should ideally be handled using an exit handler, e.g.:
 
   import os
   import atexit
   import grass.script as grass
 
   tmp_map = None
 
   def cleanup():
   if tmp_map:
   grass.run_command('g.remove', rast = tmp_map, quiet = True)
 
   def main():
   global tmpmap
   tmp_map = 'river_raster.tmp.%d' % os.getpid()
   ...
 
   if __name__ == __main__:
   options, flags = grass.parser()
   atexit.register(cleanup)
   main()
 
 Using an exit handler ensures that the temporary map gets removed
 regardless of how the script terminates (e.g. if it terminates due to
 an exception).

Thank you for your nice examples how to do that with tmp files and the exit 
handler.

Just some questions:
1) is the PID also used on windows systems? so can it be integrated in a script 
which also windows users want to use? Is it correct that the PID is the same 
value for running the whole script one time?

2) what exactly does the global tmpmap?

3)I've got a lot of tmp-files which will be created during the process, so is 
there and option to tell the g.remove that all maps containing .tmp.%d' % 
os.getpid() in the end should be removed instead of typing all the tmp map 
files into the list of g.remove.

4) so the whole thing works that in the end all the tmp maps are deleted after 
the processing of the script and after an exception etc.


/johannes


 
 -- 
 Glynn Clements gl...@gclements.plus.com

-- 
NEU: FreePhone - kostenlos mobil telefonieren und surfen!   
Jetzt informieren: http://www.gmx.net/de/go/freephone
___
grass-user mailing list
grass-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-user


[GRASS-user] using not so common characters in Python Script

2011-05-18 Thread António Rocha
Greetings  

I would like to include some sentences with characters like á ã àó in my 
grass.message strings. It seems it's not possible Because I get this


   grass.fatal(_('á'))
I get:
 File C:/local/scripts/x.teste, line 41
SyntaxError: Non-ASCII character '\xe1' in file
C:/local/scripts/x.teste on line 41, but no encoding
declared; see http://www.python.org/peps/pep-0263.html for
details

Is it possible?
Thanks
Antonio Rocha




__ Information from ESET NOD32 Antivirus, version of virus signature 
database 6132 (20110518) __

The message was checked by ESET NOD32 Antivirus.

http://www.eset.com


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


Re: [GRASS-user] using not so common characters in Python Script

2011-05-18 Thread Ricardo Filipe Soares Garcia da
Hi António

I usually start all my python scripts with the following two lines:

#!/usr/bin/env python
# -*- coding: utf-8 -*-

The first line is nice for linux users. The second line ensures that I
can write non-ASCII characters in my code.
In your case, just add this second line to your script and make sure
it is either the first or second line of the script.
I recommend adding both lines to the top of the file, as a good practice.

If you'd like to know more just check out the link that the grass
error is giving you.

Cheers

2011/5/18 António Rocha antonio.ro...@deimos.com.pt:
 Greetings
 I would like to include some sentences with characters like á ã àó in my
 grass.message strings. It seems it's not possible Because I get this

   grass.fatal(_('á'))
 I get:
  File C:/local/scripts/x.teste, line 41
 SyntaxError: Non-ASCII character '\xe1' in file
 C:/local/scripts/x.teste on line 41, but no encoding
 declared; see http://www.python.org/peps/pep-0263.html for
 details

 Is it possible?
 Thanks
 Antonio Rocha




 __ Information from ESET NOD32 Antivirus, version of virus signature
 database 6132 (20110518) __

 The message was checked by ESET NOD32 Antivirus.

 http://www.eset.com


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




-- 
___ ___ __
Ricardo Garcia Silva
___
grass-user mailing list
grass-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-user


[GRASS-user] Using d.vect in python script

2011-05-18 Thread Daniel Victoria
Hi all,

It's my first grass python script using all the bells and whistles
(g.parser gui construction and the grass.run_command) so I might be
asking something silly.

Can I use d.vect and d.rast commands in python script so that the map
is displayed in the GUI? I'm running the grass script inside the
command console window.

For instance, if I type:

d.vect munic

in the command console, the munic vector is displayed in the GUI but,
if I put grass.run_command(d.vect, map=munic) in a python script and
run this from the command console, nothing happens.

Thanks for the help
Daniel
___
grass-user mailing list
grass-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-user


[GRASS-user] Convert Floating Point Raster to Integer Raster

2011-05-18 Thread Michael Morin
Techies,

In ArcInfo I used to write .aml code to covert Floating Point Grids to Integer 
Grids.  Doing this produced a .vat table in the new Integer grid thereby giving 
me elevation data which i could then used to develop painted DEMS.  

Question...?  Would r.mapcalc or r.reclass be the tools I would use?..could 
someone share some example code how I would make this conversion?

I will sum.

Bonjour.

Michael D. Morin
mmo...@cassblue.com





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


Re: [GRASS-user] Convert Floating Point Raster to Integer Raster

2011-05-18 Thread maning sambale
r.mapcalc integer_map = round(fp_maps)

On Thu, May 19, 2011 at 7:04 AM, Michael Morin mmo...@cassblue.com wrote:
 Techies,

 In ArcInfo I used to write .aml code to covert Floating Point Grids to 
 Integer Grids.  Doing this produced a .vat table in the new Integer grid 
 thereby giving me elevation data which i could then used to develop painted 
 DEMS.

 Question...?  Would r.mapcalc or r.reclass be the tools I would 
 use?..could someone share some example code how I would make this 
 conversion?

 I will sum.

 Bonjour.

 Michael D. Morin
 mmo...@cassblue.com





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




-- 
cheers,
maning
--
Freedom is still the most radical idea of all -N.Branden
wiki: http://esambale.wikispaces.com/
blog: http://epsg4253.wordpress.com/
--
___
grass-user mailing list
grass-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-user