Re: [GRASS-user] Retrieve list of values in Python

2011-03-29 Thread Christian Schwartze
In order to get a list, here is just one approach:
vals = os.popen(“r.stats –Nn your_map”).readlines()

Christian.

From: Jenny Turner 
Sent: Tuesday, March 29, 2011 11:55 PM
To: GRASS user list 
Subject: [GRASS-user] Retrieve list of values in Python

Greetings 

I would like to know how can I retrieve the list of available values in a 
Raster map in a Python Script?
Thanks
Best regards,
Jenny Turner



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


Re: [GRASS-user] Using output from r.statistics

2011-03-02 Thread Christian Schwartze

Antonio,
since the calculated statistics are stored as labels in the output map, you 
have to use the @ operator in the mapcalc formula in order to access the 
labels instead of the clump categories, in your case.


Regards,
Christian.


-Ursprüngliche Nachricht- 
From: António Rocha

Sent: Wednesday, March 02, 2011 11:10 AM
To: GRASS user list
Subject: [GRASS-user] Using output from r.statistics

Greetings

I have used r.statistics to calculate the sum of a cover map based on a
base map. When I use the Query tool I get these:
598666.544966|9159452.159237||3996|7108
The first two corresponds to Geographic Location the third Base map
clump ID and the last one it corresponds to the value of the sum
(r.statistics).

When I try to use this output, in mapcalc, it does not use the values
obtained in r.statistics but the clump value Which does not make much
sense. How can I use the r.average valeus of this raster?

Thanks
Antonio Rocha



__ Information from ESET NOD32 Antivirus, version of virus signature 
database 5918 (20110301) __


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 


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


Re: [GRASS-user] calculating average value over a base map

2011-03-01 Thread Christian Schwartze
Monica,
I did similar things on slope values...have a look to the following code 
snippet:

r.mapcalc slope_mult=int(slope*1000.0)
r.stats -nN input=slope_mult | awk '{print $1=$1 $1/1000}' | r.reclass --o 
input=slope_mult output=slope_labeled
r.statistics --o -c base=base_map cover=slope_labeled method=average 
output=slope_avg
r.mapcalc slope_avg_cval=int(@slope_avg*1000)/1000.0

Perhaps it may help you...
Regards,
Christian.

From: Monica Buescu 
Sent: Tuesday, March 01, 2011 11:40 AM
To: Dmitrij Kolesov ; GRASS user list 
Subject: Re: [GRASS-user] calculating average value over a base map


Hi Dmistrij 
I think it was worked. I just need to figure out something with r.statistics.

Thanks
Monica



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


Re: [GRASS-user] calculating average value over a base map

2011-02-28 Thread Christian Schwartze
Monica,

try to use r.statistics with the average function/method. Pass you maps through 
the cover= and base= parameters...

Christian.

From: Monica Buescu 
Sent: Monday, February 28, 2011 4:27 PM
To: GRASS user list 
Subject: [GRASS-user] calculating average value over a base map

Greetings 

I have a map with values and a base map created with r.clump. How can I 
calculate the average of values that falls inside each cluster defined by 
r.clump?
Thanks

Best regards,
Monica



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


Re: [GRASS-user] calculating average value over a base map

2011-02-28 Thread Christian Schwartze
If you want to deal with raster value types other than CELL, you can use the –c 
flag in r.statistics in order to process the labels. Therfore, you have to copy 
your cat values to the category labels first...

Regards,
Christian.
From: Monica Buescu 
Sent: Monday, February 28, 2011 5:16 PM
To: Christian Schwartze 
Cc: GRASS user list 
Subject: Re: [GRASS-user] calculating average value over a base map

Greetings Christian 

Unfortunely it only works with CELL values. For instance, r.median uses more 
than just CELL.
Is there any other alternative? Beucase for mode and median there is specific 
functions.

Thamls

Best regards,
Monica

On Mon, Feb 28, 2011 at 3:55 PM, Christian Schwartze 
christian.schwar...@uni-jena.de wrote:

  Monica,

  try to use r.statistics with the average function/method. Pass you maps 
through the cover= and base= parameters...

  Christian.

  From: Monica Buescu 
  Sent: Monday, February 28, 2011 4:27 PM
  To: GRASS user list 
  Subject: [GRASS-user] calculating average value over a base map

  Greetings 

  I have a map with values and a base map created with r.clump. How can I 
calculate the average of values that falls inside each cluster defined by 
r.clump?
  Thanks

  Best regards,
  Monica

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

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


Re: [GRASS-user] Find rasters by using a wildcard

2011-02-17 Thread Christian Schwartze
Depending on what you want to do in detail, grass.run_command(“g.mlist”, ...) 
may help ...

Christian.

From: Pedro Roma 
Sent: Thursday, February 17, 2011 10:30 AM
To: GRASS user list 
Subject: [GRASS-user] Find rasters by using a wildcard

Greetings 

Currently, I'm using this expression to find a raster file (in a Python script):
grass.find_file(raster_map, element = 'cell', mapset=mapset)

My problem is that now I need to find files that are not called raster_maps but 
that incldues a specific string E.g. raster. So I would like to list all files 
with that string on its name in a defined MAPSET
How can I do that in a GRASS python script?
Thanks
Pedro




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


Re: [GRASS-user] Changing raster boundaries

2010-10-15 Thread Christian Schwartze
Thanks to all of you, the approach of Micha using g.region and r.mapcalc did 
the job...!


Regards,
Christian.

--
From: Nikos Alexandris nikos.alexand...@felis.uni-freiburg.de
Sent: Friday, October 15, 2010 10:50 AM
To: grass-user@lists.osgeo.org
Cc: Micha Silver mi...@arava.co.il; Christian Schwartze 
christian.schwar...@uni-jena.de

Subject: Re: [GRASS-user] Changing raster boundaries


Christian:


 how to change the boundaries of a raster map (simply expand the
 border) without any automatic modification of map resolution as it
 will happen when using r.region map=.. n= ..s=.. w= e=.. ?
 Thanks for some hint.


Micha:

 How about changing the current region with g.region, then use 
 r.mapcalc

 to create a copy of the original at the new extents?


On 10/15/2010 12:20 AM, Nikos Alexandris wrote:


 A reminder that r.region might be useful as well in this case.


Micha:


Yes, but the OP asked not to use r.region since it changes also the
resolution. It recalculates the res so as to keep the same number of
rows and columns.


Correct. My bad.

Thought the r.region map=mymap n=n+100 e=e+100 w=w+100 s=s+100 will get 
the

job done and avoid (carefully) using g.region + r.mapcalc.

Regards, Nikos 


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


[GRASS-user] Changing raster boundaries

2010-10-02 Thread Christian Schwartze
Hi GRASS users,

how to change the boundaries of a raster map (simply expand the border) without 
any automatic modification of map resolution as it will happen when using 
r.region map=.. n= ..s=.. w= e=.. ?
Thanks for some hint.

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


Re: [GRASS-user] Python Script- Check if a raster exists

2010-09-27 Thread Christian Schwartze
Try e.g g.findfile element=vector file=testmap

Christian


From: Helena Herrera 
Sent: Monday, September 27, 2010 12:25 PM
To: grass-user@lists.osgeo.org 
Subject: [GRASS-user] Python Script- Check if a raster exists


Hi 


I'm doing a python script and, in a process, I need to check if a raster map 
exists. My idea is, if this map exists I don't need to create otherwise, I need 
to create it (v.to.rast). Is there a way to check if a map exists in the 
current mapset?
Thanks
Helena





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


Re: [GRASS-user] Python Script- Check if a raster exists

2010-09-27 Thread Christian Schwartze
See the notes and output sections of the g.findfile manpage. There you can find 
additional information how to use the comand in scripts.
http://grass.fbk.eu/gdp/html_grass64/g.findfile.html

Christian.


From: Helena Herrera 
Sent: Monday, September 27, 2010 12:47 PM
To: Christian Schwartze ; grass-user@lists.osgeo.org 
Subject: Re: [GRASS-user] Python Script- Check if a raster exists


Uhm. I have tried that one with  
g.findfile element=raster file=L (I have a raster map named L in my mapset) and 
I get:
name=
mapset=
fullname=
file=
Which would mean that it doesn't exist.


is there any other way to do this for GRASS-pythons scripts?


On Mon, Sep 27, 2010 at 11:39 AM, Christian Schwartze 
christian.schwar...@uni-jena.de wrote:

  Try e.g g.findfile element=vector file=testmap

  Christian


  From: Helena Herrera 
  Sent: Monday, September 27, 2010 12:25 PM
  To: grass-user@lists.osgeo.org 
  Subject: [GRASS-user] Python Script- Check if a raster exists


  Hi 


  I'm doing a python script and, in a process, I need to check if a raster map 
exists. My idea is, if this map exists I don't need to create otherwise, I need 
to create it (v.to.rast). Is there a way to check if a map exists in the 
current mapset?
  Thanks
  Helena


--


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



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


Re: [GRASS-user] Python Script for changing raster values

2010-09-07 Thread Christian Schwartze
Following code could be one approach:

os.system(cat %s | r.recode input=map_a output=map_recl % path_to_rules)

where path_to_rules is a previously created (temp) file containg the 
reclassifiying rules as for example:

1:1:1.1:1.1
2:2:7.5:7.5
3:3:0.4:0.4

Christian.




From: Luisa Peña 
Sent: Tuesday, September 07, 2010 12:37 PM
To: GRASS user list 
Subject: [GRASS-user] Python Script for changing raster values


Greetings 


I have a classification raster (with values that ranges from 1-20) and I need 
to reclassify them. I mean, to change (as an example):
1-  255
2-  100
3 - 150


and I need to implement this on a Python script. What do you suggest to do? I 
mean, that is the most robust and easy way to implement this?
Thanks
Luisa





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


Re: [GRASS-user] get coords from a raster

2010-06-03 Thread Christian Schwartze
Margherita,
now I got your point...I had a very similar problem a short time ago, but 
finally I was able to solve it. If your are interested in, take a look to the 
following notes - I know, a bit complicated but it works 

- set your desired path as a mask for limiting following calculations using 
r.mask
- r.describe -dr your_dem to fetch min and max of elevation along your path 
(use tool awk or any other string processing function like split() in Python)  
- r.to.vect to convert the mask into a vector line, and then v.to.db -p 
your_vector_path option=length column=s to print out the path length 
(therefor, parse the string again to fetch the column that contains the length)
- now you can calculate the slope based on altitude difference and distance...

Perhaps it is adaptable to yours...

Christian.



From: Margherita Di Leo 
Sent: Wednesday, June 02, 2010 6:50 PM
To: Christian Schwartze 
Cc: grass-user@lists.osgeo.org 
Subject: Re: [GRASS-user] get coords from a raster


Christian,

thank you for answering. My problem is that I don't want to use the slope map 
to get slope, bu i want to calculate it as the 
ratio between the difference of the elevation and the distance between two 
given points (pixels). To do that, I need to get the coordinates of the points 
as a input file for r.profile.

Margherita



2010/6/2 Christian Schwartze christian.schwar...@uni-jena.de

  Why are you not using r.statistics, since it takes one base map (your path as 
a raster) and another map containing data you want to analyze (your slope). 
With the average option/method you will get the desired result, if I 
understand you correctly...

  Christian.


  From: Margherita Di Leo 
  Sent: Wednesday, June 02, 2010 6:17 PM
  To: grass-user@lists.osgeo.org 
  Subject: [GRASS-user] get coords from a raster


  Hi List,

  I'm trying to make a script to calculate the slope along a path. I want to 
calculate the slope as the average of cell per cell slope. For my purpose I 
found r.profile to produce the input file for my script, but I have to give it 
the coordinates of the points. As I have a raster and not a vector, I was 
wondering if is there a non interactive way like a d.where or something like 
that, that i can use for my purpose. I mean, i have a raster in which there is 
the path i'm interested in, and the other cells are null.

  Thank you in advance

  Margherita



--


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

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


Re: [GRASS-user] Using a polygon as a Mask

2010-05-27 Thread Christian Schwartze
There is no way to use a vector geometry in mapcalculator (or mapcalc) 
directly, hence, you have to convert it to raster before.


Christian.

--
From: António Rocha antonio.ro...@deimos.com.pt
Sent: Thursday, May 27, 2010 2:08 PM
To: GRASS user list grass-user@lists.osgeo.org
Subject: [GRASS-user] Using a polygon as a Mask


Greetings

I have polygon that I want to use to define an for which I want to 
calculate some indicators (almost as a mask). Is it possible to use it 
directly in mapcalculator or do I have to convert it to RASTER and only 
then I can use it in mapcalculator as a mask?


Thanks

Best regards,
Antonio


__ Information from ESET NOD32 Antivirus, version of virus 
signature database 5149 (20100527) __


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 


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


Re: [GRASS-user] Extracting grey features from an image

2010-05-27 Thread Christian Schwartze
Use r.mask as already done to identify your grey values only, then apply 
r.mapcalc new_raster=if(MASK,orig_raster,null()).


Christian.

--
From: baobazz baob...@hotmail.fr
Sent: Thursday, May 27, 2010 11:59 AM
To: grass-user@lists.osgeo.org
Subject: [GRASS-user] Extracting grey features from an image



Hello

I've got a black and white image with some grey features on it

I'd like to create a new image containing only these features so I can
vectorize them

i think that I have to use
r.mask
r.mapcalc
or
r.reclass

r.describe raster
returns me
0-121 123 125-127 132-255

I created a mask of my image
r.mask input=image maskcats=0 thru 121 -i
-i to invert the maskcats range

Only the grey features appear.

So, my grey features seem to have the 0-121 range category of values.

Considering that, how can I manage to create a raster map based only on
these values.

I used r.reclass like this:
r.reclass input=raster output=rasterRec

0 thru 121=1 black
*=NULL

But I didn't get any good result...

Any help would be greatly appreciated!



--
View this message in context: 
http://osgeo-org.1803224.n2.nabble.com/Extracting-grey-features-from-an-image-tp5107822p5107822.html

Sent from the Grass - Users mailing list archive at Nabble.com.
___
grass-user mailing list
grass-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-user 


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


[GRASS-user] temporary maps/space during r.fill.dir execution

2010-04-14 Thread Christian Schwartze
Hi grass users,

does anybody know how to avoid the temporary use of disk space during execution 
of r.fill.dir? For large input files it seems that large temporary files are 
written as well since I got messages like no disk space left (running in a 
minimized environment where not so much disk space is available).

Thanks a lot for any hints...

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


Re: [GRASS-user] temporary maps/space during r.fill.dir execution

2010-04-14 Thread Christian Schwartze

g.region -p says:

   projection: 0 (x,y)
   zone: 0
   north: 6257261.73938969
   south: 6124108.23119424
   west: 650218.74629604
   east: 775529.77427479
   nsres: 84.32774427
   ewres: 69.6946763
   rows: 1579
   cols: 1798
   cells: 2839042

Hence, working on nearly 3 mill. cells...

Regards,
Christian.
--
From: Markus Neteler nete...@osgeo.org
Sent: Wednesday, April 14, 2010 10:07 PM
To: Christian Schwartze christian.schwar...@uni-jena.de
Cc: GRASS user list grass-user@lists.osgeo.org
Subject: Re: [GRASS-user] temporary maps/space during r.fill.dir execution


On Wed, Apr 14, 2010 at 11:01 AM, Christian Schwartze
christian.schwar...@uni-jena.de wrote:

Hi grass users,

does anybody know how to avoid the temporary use of disk space during
execution of r.fill.dir? For large input files it seems that large 
temporary

files are written as well since I got messages like no disk space left
(running in a minimized environment where not so much disk space is
available).


The command is actually memory demanding. What's the output of
g.region -p
? On how many cells do you work on?

Markus 


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


Re: [GRASS-user] Uploading bounding box of vectors to database?

2010-01-05 Thread Christian Schwartze
Just a quick idea, when an underlying postgres/postgis database is 
available:


   - use v.out.ogr to import vector data to your postgis database, to 
testtable

   - now db.connect and db.login
   - when connected, something like echo 'UPDATE testtable SET 
wkb_geometry=envelope(wkb_geometry)' | db.execute should work

   - but not yet in the attribute table... (?)

...maybe too difficult.

Christian.






--
From: Christian Kaiser christian.kai...@unil.ch
Sent: Tuesday, January 05, 2010 6:28 PM
To: grass-us...@lists.osgeo.org
Subject: [GRASS-user] Uploading bounding box of vectors to database?


Hi everybody,

I would like to do a very simple thing:
upload the bounding box for each geometry (areas, boundaries, lines) to 
the attribute table.


v.to.db does not seem to provide this functionality. Is there an elegant 
way for doing this?


Of course, I could write out the map using v.out.ascii in standard format, 
parse this file using Python and extract the bounding box for each 
geometry this way. Is probably not very elegant, but could lead to a 
working Python module.


Or would it be more useful to implement this functionality in v.to.db? (I 
did never program in C with GRASS, but maybe, I could try with some 
help...)


Thank you for any suggestion.

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


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


Re: [GRASS-user] Show / Print current mapset

2009-12-10 Thread Christian Schwartze

Hi,

try command g.gisenv MAPSET, it should print out current mapset as you 
like...


Christian.

--
From: Tim Michelsen timmichel...@gmx-topmail.de
Sent: Thursday, December 10, 2009 12:45 AM
To: grass-user@lists.osgeo.org
Subject: [GRASS-user] Show / Print current mapset


Hello,
which command line and GUI options do I have to get the current mapset?

I am looking for a command that tells me the mapset selected when
eneting GRASS.

g.mapsets shows with its -p option all mapsets in the search path and
g.mapset shows all in open locations.
Could these two commands be merged into one?

Thanks and regards,
Timmie

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


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


[GRASS-user] Short r.watershed question

2009-08-24 Thread Christian Schwartze
Dear GRASS user,

maybe you can help me in understanding the stream network map provided by 
r.watshed analysis tool. Am i right in thinking that each segment given by an 
odd integer drains into a segment with a lower identifier?

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


AW: [GRASS-user] Some issues with r.mapcalc

2009-04-01 Thread Christian Schwartze
You can change the NULL value using r.null map null=x to avoid the null()
handling. Is it your question..??

Christian.

-Ursprüngliche Nachricht-
Von: grass-user-boun...@lists.osgeo.org
[mailto:grass-user-boun...@lists.osgeo.org] Im Auftrag von Fulvio
Mastrogiovanni
Gesendet: Mittwoch, 1. April 2009 13:45
An: grass-user@lists.osgeo.org
Betreff: [GRASS-user] Some issues with r.mapcalc

Hi everyone,

I hope you can help me in solving this issue. Basically, what I want to do
is to
create a new raster map whose cells are simply given by the or of other
two
maps (possibly for specific categories), as follows:

r.mapcalc test=if(vegcover==1 || railroads==1)

However, maps like railroads are null() when not equal to 1. The resulting
map
test is null() wherever cells in railroads are null(), therefore making
null() also cells where vegcover is 1.

How can I solve this issue?

Thanks!

Fulvio


-- 
Fulvio Mastrogiovanni
DIST|University of Genova|Italy

Email: fulvio.mastrogiova...@unige.it
WWW: http://www.laboratorium.dist.unige.it/~fulvio/
Phone: (+39)0103532801

Chi è abile nel sortire bizzarri stratagemmi è inesauribile come il
Cielo, la Terra e i grandi fiumi. Giunto al termine riparte, come il
Sole e la Luna; dopo morto rinasce, come le quattro stagioni.
___
grass-user mailing list
grass-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-user

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


Re: [GRASS-user] reclass

2009-03-19 Thread Christian Schwartze
What just doesn't work? Tried this:
cat rule | r.reclass input=map_a output=map_b
while rule contains your new classes like
1 = 2 some labels
..

Christian

 Hello, I', new in grass

 I'm trying  to do a raster reclassification (r.reclass) but i can't set the
 rules. Someone can teach me how to do it?



 Yks







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




 
 This mail was sent through http://webmail.uni-jena.de






This mail was sent through http://webmail.uni-jena.de
___
grass-user mailing list
grass-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-user


Re: [GRASS-user] How to write scripts in GRASS

2008-10-08 Thread Christian Schwartze
http://grass.osgeo.org/wiki/GRASS_and_Python   ...maybe your starting point.

Regards,
Christian.

Zitat von Gabriel Messner [EMAIL PROTECTED]:

 I´d very grateful if anyone can point any tutorial on how to write scripts
 in Python to perform routine tasks. I remember to have seen anyone at GRASS
 web site, but I can´t find it.

 Thanks.






This mail was sent through http://webmail.uni-jena.de
___
grass-user mailing list
grass-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-user


Re: [GRASS-user] r.mapcalc concatenates values?

2008-09-10 Thread Christian Schwartze
Hi Gabriele,

using r.mapcalc and the @-operator within the calculation you have access to the
labels, but in IF statements it works only on labels that starts with a number
(int vals). So looking for a string is not possible.
But why not using the cats or int labels(with @) in mapcalc, then asigning a new
and unique cat value, following a reclass new_cat_by_mapcalc -- string label?

r.mapcalc 'mapA=if((@landuse==1@soils==2),12,null())

r.reclass with something like 12 = 1 forest,loam

Dont know if my notes helpful...

Regards,
Christian.



This mail was sent through http://webmail.uni-jena.de
___
grass-user mailing list
grass-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-user


[GRASS-user] different flow directions

2008-08-27 Thread Christian Schwartze
Dear list,

can somebody explain me the differences between the flow direction raster
calculated by r.fill.dir and that one which comes from r.watershed. I know
about the different cats in both, but whats the background? Whats better?

Thanks a lot for answering!

Christian.




This mail was sent through http://webmail.uni-jena.de
___
grass-user mailing list
grass-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-user


[GRASS-user] Automate way for filling category labels

2008-08-22 Thread Christian Schwartze
Hi GRASS users,

I was wondering if I do somewhat right all the time... There is r.in.gdal what I
use for the import of a geotiff. Basically the entries for the labels of the
cats are empty after the import. So I do some pipelining combined with awk,
like:

r.stats -n input=img | awk '{print $1,\ = \,$1,$1;}' | r.reclass input=img
output=img_new

So the labels are filled with the category, that works fine and I need the
non-empty labels in further steps, e.g. in r.statistics.
It seems to me a little bit tricky but I found no other solution..., what do you
think?

Regards,
Christian.


This mail was sent through http://webmail.uni-jena.de
___
grass-user mailing list
grass-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-user


Re: [GRASS-user] Automate way for filling category labels

2008-08-22 Thread Christian Schwartze
Thanks, now I know that r.category is only part of grass = 6.3 ;)

Christian.


Am Freitag, den 22.08.2008, 16:15 +0200 schrieb Markus Neteler:
 On Fri, Aug 22, 2008 at 11:12 AM, Christian Schwartze
 [EMAIL PROTECTED] wrote:
  Hi GRASS users,
 
  I was wondering if I do somewhat right all the time... There is r.in.gdal 
  what I
  use for the import of a geotiff. Basically the entries for the labels of the
  cats are empty after the import. So I do some pipelining combined with awk,
  like:
 
  r.stats -n input=img | awk '{print $1,\ = \,$1,$1;}' | r.reclass input=img
  output=img_new
 
  So the labels are filled with the category, that works fine and I need the
  non-empty labels in further steps, e.g. in r.statistics.
  It seems to me a little bit tricky but I found no other solution..., what 
  do you
  think?
 
 Wouldn't r.category help here?
 
 r.category diseasemap  rules=-  EOF
 1:potential absence
 2:potential presence
 EOF
 
 Markus

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


[GRASS-user] Reorg cat entry?

2008-07-17 Thread Christian Schwartze
Hi,

I have performed the following steps on raster A:

vectorize(A) -- clean by removing small areas -- rasterize back

Now I have cats with large gaps and not starting by 0, hence an expanded range
of cats. How can reorg so that range starts at 0 with step=1?

Thanks a lot!

Regards,
Christian.




This mail was sent through http://webmail.uni-jena.de
___
grass-user mailing list
grass-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-user


Re: [GRASS-user] Reorg cat entry?

2008-07-17 Thread Christian Schwartze
Thanks Nikos,

I use v.clean instead because so I am sure that the eleminated areas are
relocated to neighbours with longest bounds. With r.reclass.area the min areas
get lost, right? But nevertheless the cats would start at 0 and increases by 1
when using r.reclass.area?

Regards,
Christian.

Zitat von Nikos Alexandris [EMAIL PROTECTED]:

 On Thu, 2008-07-17 at 11:59 +0200, Christian Schwartze wrote:
  Hi,
 
  I have performed the following steps on raster A:
 
  vectorize(A) -- clean by removing small areas -- rasterize back
 
  Now I have cats with large gaps and not starting by 0, hence an expanded
 range
  of cats. How can reorg so that range starts at 0 with step=1?
 
  Thanks a lot!
 
  Regards,
  Christian.

 Hi Christian!

 If removing small areas is your target why not use r.reclass.area?

 Kind regards,
 Nikos







This mail was sent through http://webmail.uni-jena.de
___
grass-user mailing list
grass-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-user


Re: [GRASS-user] Reorg cat entry?

2008-07-17 Thread Christian Schwartze
Thank you Maciej,

it solves the task in this way that the cats are gap-less now, but still starts
with x0. And the label column get lost.

Regards,
Christian.



Zitat von Maciej Sieczka [EMAIL PROTECTED]:

 Christian Schwartze pisze:
  Hi,
 
  I have performed the following steps on raster A:
 
  vectorize(A) -- clean by removing small areas -- rasterize back

 Given the v.clean output name is cleaned:

 v.category in=cleaned out=cleaned_rmc opt=del
 v.category in=cleaned_rmc out=cleaned_rmc_adc opt=add

 Maciek

 --
 Maciej Sieczka
 www.sieczka.org






This mail was sent through http://webmail.uni-jena.de
___
grass-user mailing list
grass-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-user


[GRASS-user] (no subject)

2008-07-14 Thread Christian Schwartze
Dear GRASS users,

could somebody help me to find some solution for the following task?
I have a raster map representing many distinct areas (MAP_1) and a second int
raster with specific values (MAP_2). The result map should contain the same
areas of MAP_1 but with the max MAP_2 value of each area as IDs. I tried some
approaches with r.mapcalc but I don't know how to code the region aspect of
MAP_1 into r.mapcalc.

MAP_1   MAP_2   ---MAP_MAX
-   -   ---

32  5266723974  95
111222  1429784155  ---777555
111322  4152763923  777955
12  4125718443  75

Thanks a lot for any help!
Regards,
Christian.




This mail was sent through http://webmail.uni-jena.de
___
grass-user mailing list
grass-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-user


[GRASS-user] r.mapcalc and producing a max value map

2008-07-14 Thread Christian Schwartze
Dear GRASS users,

could somebody help me to find some solution for the following task?
I have a raster map representing many distinct areas (MAP_1) and a second int
raster with specific values (MAP_2). The result map should contain the same
areas of MAP_1 but with the max MAP_2 value of each area as IDs. I tried some
approaches with r.mapcalc but I don't know how to code the region aspect of
MAP_1 into r.mapcalc.

MAP_1   MAP_2   ---MAP_MAX
-   -   ---

32  5266723974  95
111222  1429784155  ---777555
111322  4152763923  777955
12  4125718443  75

Thanks a lot for any help!
Regards,
Christian.




This mail was sent through http://webmail.uni-jena.de
___
grass-user mailing list
grass-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-user


Re: [GRASS-user] Two questions - vector data and Mac install

2008-06-25 Thread Christian Schwartze
Hi,

 Hi all,

 1) v.overlay question

 I have three maps: two area vectors (A and B), and a v.overlay result
 (C). Is there a simple way to assign the percentage of areas in (A)
 covered by the overlay (C)?

What I think of in a rush is to rasterize the areas first and afterwards asking
for the overlapping areas in percent with r.stats -a input=map1,map2

Regards,
Christian.


 2) Mac install

 Wish 8.4 is breaking on a friends new installation, with the reason as
 image not found. Do we need to reinstall X or is it something else?

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






This mail was sent through http://webmail.uni-jena.de
___
grass-user mailing list
grass-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-user


Re: [GRASS-user] Vector dbf files + Spatial join

2008-06-24 Thread Christian Schwartze
Hi,

using e.g. postgres or mysql as storage backend for vector data you can use
modules like v.db.join or db.execute for complex querying your vector data.

Regards,
Christian.

Zitat von Wesley Roberts [EMAIL PROTECTED]:

 Hi All,

 Before I head into learning mySQL I would like to know if grass has a command
 that can merge / spatial join dbf attribute tables (similar to the spatial
 join used in ESRI).

 Reading the archives I see people have used anything from PostgreSQL to mySQL
 to combine the attributes of vectors. I have a 13 point data sets with 15625
 points with attributes attached. I would like to combine all 13 into one
 dbase file and then import into a stats package.

 Do I need to use something like mySQL or does GRASS have a builtin function
 for this sort of application? If not could someone point me towards a GRASS
 orientated mySQL tutorial

 Many thanks,
 Wesley

 Wesley Roberts MSc.
 Researcher: Forest Assessment (Remote Sensing  GIS)
 Forestry and Forest Products Research Centre
 CSIR
 Tel: +27 (31) 242-2353
 Fax: +27 (31) 261-1216
 http://ffp.csir.co.za/

 To know the road ahead, ask those coming back.
 - Chinese proverb

 --
 This message is subject to the CSIR's copyright terms and conditions, e-mail
 legal notice, and implemented Open Document Format (ODF) standard.
 The full disclaimer details can be found at
 http://www.csir.co.za/disclaimer.html.

 This message has been scanned for viruses and dangerous content by
 MailScanner,
 and is believed to be clean.  MailScanner thanks Transtec Computers for their
 support.

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






This mail was sent through http://webmail.uni-jena.de
___
grass-user mailing list
grass-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-user


Re: [GRASS-user] problem with column label using r.cross

2008-06-24 Thread Christian Schwartze
Ok and thanks, better to look at first within GRASS if eveything is working fine
;) (in cats/ full category values) Because the reduced line comes from QGIS
(selection tool). I forgot to say that following r.cross I do a conversion with
r.to.vect and export the result to a shapefile. So the original label vals were
mapped to dbf-column type C. But why exporting only 80 chars?

Regards,
Christian.

Zitat von Hamish [EMAIL PROTECTED]:

 Christian Schwartze wrote:
  I use r.cross for combining the raster data values of up to
  9 layers/maps. The combinations are stored in column label of each
  new generated area. But column label seems to be limited to a specific
  number of characters, so that some information get lost in my case of 9
  combining maps. My label column only shows a subpart like:
 
  category 2; category 3; category 2; category 0; category 0; category 9;
 category

 (above ends at the 80th character)

  Something is missing in every row. How to solve it?

 how are you viewing the cats? where does that cut-short line come from?



 I have just done a little test, and it seemed to write the cats file ok.
 Both raw if you look in the $MAPSET/cats/$MAPNAME file and printed with
 r.category. Only issue I found was that the cats file was huge and things
 like r.info took a long time. As I used fake data I won't worry about that.

 my test:

 g.region n=4925010 s=4913700 w=589980 e=603000 res=30

 for i in `seq 10` ; do
r.surf.gauss out=surf.gauss_tmp_$i
r.mapcalc surf.gauss_$i = int( surf.gauss_tmp_$i )
g.remove surf.gauss_tmp_$i --quiet
 done

 r.cross input=`g.mlist rast pat=surf.gauss_* sep=,` output=surf.gauss.x


 ?
 Hamish











This mail was sent through http://webmail.uni-jena.de
___
grass-user mailing list
grass-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-user


Re: [GRASS-user] problem with column label using r.cross

2008-06-24 Thread Christian Schwartze
Just now I read in the gdal description for shapefile driver:
String fields without an assigned width are treated as 80 characters.
How can I modify that?

Christian.

Zitat von Hamish [EMAIL PROTECTED]:

 Christian Schwartze wrote:
  I use r.cross for combining the raster data values of up to
  9 layers/maps. The combinations are stored in column label of each
  new generated area. But column label seems to be limited to a specific
  number of characters, so that some information get lost in my case of 9
  combining maps. My label column only shows a subpart like:
 
  category 2; category 3; category 2; category 0; category 0; category 9;
 category

 (above ends at the 80th character)

  Something is missing in every row. How to solve it?

 how are you viewing the cats? where does that cut-short line come from?



 I have just done a little test, and it seemed to write the cats file ok.
 Both raw if you look in the $MAPSET/cats/$MAPNAME file and printed with
 r.category. Only issue I found was that the cats file was huge and things
 like r.info took a long time. As I used fake data I won't worry about that.

 my test:

 g.region n=4925010 s=4913700 w=589980 e=603000 res=30

 for i in `seq 10` ; do
r.surf.gauss out=surf.gauss_tmp_$i
r.mapcalc surf.gauss_$i = int( surf.gauss_tmp_$i )
g.remove surf.gauss_tmp_$i --quiet
 done

 r.cross input=`g.mlist rast pat=surf.gauss_* sep=,` output=surf.gauss.x


 ?
 Hamish











This mail was sent through http://webmail.uni-jena.de
___
grass-user mailing list
grass-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-user


Re: [GRASS-user] problem with column label using r.cross

2008-06-24 Thread Christian Schwartze
Zitat von Hamish [EMAIL PROTECTED]:

  Christian Schwartze
  Ok and thanks, better to look at first within GRASS if
  eveything is working fine
  ;) (in cats/ full category values) Because the reduced line
  comes from QGIS
  (selection tool). I forgot to say that following r.cross I
  do a conversion with
  r.to.vect and export the result to a shapefile. So the
  original label vals were
  mapped to dbf-column type C. But why exporting only 80 chars?


 Does v.db.select show the cut string?
 which DB backend? (dbf?)

v.db.select shows the full length of column label for all data rows - nothing is
missing. I use dbf backend.


 db.describe -c vect_map ?

ncols:3
Column 1:cat:INTEGER
Column 2:value:INTEGER
Column 3:label:CHARACTER




Christian.



 Hamish











This mail was sent through http://webmail.uni-jena.de
___
grass-user mailing list
grass-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-user


Re: [GRASS-user] import multiple shapefiles automatically

2008-06-19 Thread Christian Schwartze
HI,

use parameter dsn to specify only the folder of your shape files and ignore the
layer param.

Regards,
Christian.

Zitat von Barbosa, A.  Marcia [EMAIL PROTECTED]:

 Hi,

 Another beginner's question. I need to import big groups of shapefiles to
 GRASS. So far I'm using

 v.in.ogr 'dsn=C:/QGIS/species_shapefiles/XXX.shp' output=XXX -o

 and replacing the names of the shapefiles by hand in each command line. But
 is there a way to tell GRASS to import all the shapefiles in a certain folder
 (I've tried *.shp but it didn't work), and give each output map the same name
 as the original shapefile?

 Cheers,
 Márcia

 - - -
 A. Márcia Barbosa
 Dept. Biological Sciences, North 2.1
 Imperial College at Silwood Park
 Ascot, Berkshire SL5 7PY
 United Kingdom








This mail was sent through http://webmail.uni-jena.de
___
grass-user mailing list
grass-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-user


Re: [GRASS-user] Centerlines of Polygons (skeletons)

2008-06-18 Thread Christian Schwartze
Hi,

I only know the way for raster data using r.thin to get a center line
for e.g. wide raster streams.

Christian. 

Am Mittwoch, den 18.06.2008, 10:24 -0700 schrieb Aurora Geomatics:
 Wondering if there is a simple way in GRASS to produce skeletons of  
 Polygons (rivers/streams), to find the flow centerline.
 
 thanks
 
 
 Mars Sjoden
 Aurora Geomatics
 [EMAIL PROTECTED]
 http://arorageo.blogspot.com/
 
 ___
 grass-user mailing list
 grass-user@lists.osgeo.org
 http://lists.osgeo.org/mailman/listinfo/grass-user


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


Re: [GRASS-user] Enclose the polygons within 50 metres

2008-06-17 Thread Christian Schwartze
Hi,

don't know if I unterstood you right, but what about buffering your
polygons (v.buffer with buffer=50m), i.e. the buildings. So you get a
map of overlapping areas where features not more far away than 50
meters. Afterwards you can use v.to.rast for rasterizing the buffer
zones and describing small towns for you case.

Regards,
Christian.


Am Sonntag, den 15.06.2008, 08:43 -0700 schrieb Gabriele N.:
 Hi all

 I have 2 vector polygonal; one representing the buildings and another that
 represents the infrastructure.
 I think to put them together with v.patch.

 I have to create another vector polygonal, which is to enclose all the
 polygons that are close to each other within 50 metres. I need to identify
 small towns.

 How can I do?
 1) v.patch
 2) v.distance?
 3)?

 Thank you very much

 Gabriele




This mail was sent through http://webmail.uni-jena.de
___
grass-user mailing list
grass-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-user


[GRASS-user] Multiple usage of r.water.outlet

2008-05-15 Thread Christian Schwartze
Dear GRASS user,

the problem I have is using r.water.outlet for some scripting in Python. Below I
want to explain the proceeding in detail. It should be mentioned in advance that
the necessary drainage raster has nearly 1 rows and columns, so it's not
really small...
I have a point shape file (or generally point coordinates, more than 100 pairs)
that presents the input for multiple calls of r.water.outlet. To produce a map
representing the corresponding watersheds of all these points I thought of the
three following approaches:

(A)  At certain intervals (of the r.water.outlet iteration) I sort the previous
calculated basins by area and use the resulting and ascending order as an input
for r.patch. So the basins can not hide each other.

(B) At certain intervals I execute r.cross for overlaying the previous basins.

(C) I use r.mapcalc in every iteration step with an expression like
allbasins = allbasins +
if(isnull(allbasins),basinx,if(allbasins=1basinx==1,newBasinID,allbasins))
where allbasins is initially a novalue raster.


All methods above are working right, but have the same lack: the performance -
too slow!
Remember that the working raster has an extent of 1x1 pixel. The single
calculated basins and their extents compared to entire drainage raster are very
small (see the attachment). While the duration of r.water.outlet is barely 
acceptable, the merging step (regardless of the technique in A, B or C) takes
too long.
What do you think about the three approaches for a script in Python and how can
i minimize the performance problem when bringing the basins together within a
large area? Many thanks for any advice!

Regards,
Christian.


This mail was sent through http://webmail.uni-jena.de
___
grass-user mailing list
grass-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-user


[GRASS-user] Multiple usage of r.water.outlet

2008-05-15 Thread Christian Schwartze
Dear GRASS user,

the problem I have is using r.water.outlet for some scripting in Python. Below I
want to explain the proceeding in detail. It should be mentioned in advance that
the necessary drainage raster has nearly 1 rows and columns, so it's not
really small...
I have a point shape file (or generally point coordinates, more than 100 pairs)
that presents the input for multiple calls of r.water.outlet. To produce a map
representing the corresponding watersheds of all these points I thought of the
three following approaches:

(A)  At certain intervals (of the r.water.outlet iteration) I sort the previous
calculated basins by area and use the resulting and ascending order as an input
for r.patch. So the basins can not hide each other.

(B) At certain intervals I execute r.cross for overlaying the previous basins.

(C) I use r.mapcalc in every iteration step with an expression like
allbasins = allbasins +
if(isnull(allbasins),basinx,if(allbasins=1basinx==1,newBasinID,allbasins))
where allbasins is initially a novalue raster.


All methods above are working right, but have the same lack: the performance -
too slow!
Remember that the working raster has an extent of 1x1 pixel. The single
calculated basins and their extents compared to entire drainage raster are very
small (see the attachment). While the duration of r.water.outlet is barely
acceptable, the merging step (regardless of the technique in A, B or C) takes
too long.
What do you think about the three approaches for a script in Python and how can
i minimize the performance problem when bringing the basins together within a
large area? Many thanks for any advice!

Regards,
Christian.




This mail was sent through http://webmail.uni-jena.de
attachment: wateroutlet.png___
grass-user mailing list
grass-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-user


Re: [GRASS-user] Multiple usage of r.water.outlet

2008-05-15 Thread Christian Schwartze
Yes, thats right, and I tried this with g.region zoom=basinx for example. But
I have to merge more than one area and they could be distributed far away each
other, in worst case.

Regards,
Christian.

Zitat von Michael Barton [EMAIL PROTECTED]:

 If you run g.region to set the computational region to just the area of each
 basin before doing the other calculations, it might run a lot faster.

 Michael


 On 5/15/08 5:02 AM, [EMAIL PROTECTED]
 [EMAIL PROTECTED] wrote:

  Date: Thu, 15 May 2008 14:00:14 +0200
  From: Christian Schwartze [EMAIL PROTECTED]
  Subject: [GRASS-user] Multiple usage of r.water.outlet
  To: grass-user@lists.osgeo.org
  Message-ID: [EMAIL PROTECTED]
  Content-Type: text/plain; charset=ISO-8859-1
 
  Dear GRASS user,
 
  the problem I have is using r.water.outlet for some scripting in Python.
 Below
  I
  want to explain the proceeding in detail. It should be mentioned in advance
  that
  the necessary drainage raster has nearly 1 rows and columns, so it's
 not
  really small...
  I have a point shape file (or generally point coordinates, more than 100
  pairs)
  that presents the input for multiple calls of r.water.outlet. To produce a
 map
  representing the corresponding watersheds of all these points I thought of
 the
  three following approaches:
 
  (A)  At certain intervals (of the r.water.outlet iteration) I sort the
  previous
  calculated basins by area and use the resulting and ascending order as an
  input
  for r.patch. So the basins can not hide each other.
 
  (B) At certain intervals I execute r.cross for overlaying the previous
 basins.
 
  (C) I use r.mapcalc in every iteration step with an expression like
  allbasins = allbasins +
 
 if(isnull(allbasins),basinx,if(allbasins=1basinx==1,newBasinID,allbas
  ins))
  where allbasins is initially a novalue raster.
 
 
  All methods above are working right, but have the same lack: the
 performance -
  too slow!
  Remember that the working raster has an extent of 1x1 pixel. The
  single
  calculated basins and their extents compared to entire drainage raster are
  very
  small (see the attachment). While the duration of r.water.outlet is barely
  acceptable, the merging step (regardless of the technique in A, B or C)
 takes
  too long.
  What do you think about the three approaches for a script in Python and how
  can
  i minimize the performance problem when bringing the basins together within
 a
  large area? Many thanks for any advice!
 
  Regards,
  Christian.

 __
 Michael Barton, Professor of Anthropology
 Director of Graduate Studies
 School of Human Evolution  Social Change
 Center for Social Dynamics  Complexity
 Arizona State University

 phone: 480-965-6213
 fax: 480-965-7671
 www: http://www.public.asu.edu/~cmbarton


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






This mail was sent through http://webmail.uni-jena.de
___
grass-user mailing list
grass-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-user