Re: [GRASS-user] How I can develope code for Polar Diagram(Rose Diagram) in windows

2012-09-05 Thread Marcello Gorini
Hamish wrote:



 anyway, I use this python one which is quite nice.

 http://youarealegend.blogspot.co.nz/2008_09_01_archive.html
 http://downloads.sourceforge.net/project/windrose/



Wow, very nice indeed! Thanks for the links!

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


Re: [GRASS-user] Invalid region and coordinates when trying to reproject.

2012-07-02 Thread Marcello Gorini
Thanks for the suggestions.

Markus:

 Please post
 g.proj -p

-PROJ_INFO
-
name   : Mercator
proj   : merc
datum  : wgs84
ellps  : wgs84
lon_0  : 0
k  : 1
x_0: 0
y_0: 0
no_defs: defined
-PROJ_UNITS
unit   : metre
units  : metres
meters : 1

Doesn't seem to have a problem, does it?

Now I looked at the revised wiki (thanks Hamish) and followed it entirely.

It worked. I guess either I hadn't followed everything the last time or
this r.region part was
really needed.

OK, but I have another problem.

When I first imported the data to the latlog location, besides being
flipped, it appeared stretched in the N-S direction.
When I fixed it with region w=-180 e=180, everything fell back to its
correct place and it was fine, with no more stretching.

Now, when I reprojected it, it is stretched again.

Doing g.region in my latlong location, I get a resolution of 5 minutes with
rows=2159 cols=4321.
When I r.proj -g in the mercator location, following Hamish suggestion, I
get
Input Projection Parameters:  +proj=longlat +no_defs +a=6378137
+rf=298.257223563 +towgs84=0.000,0.000,0.000
Input Unit Factor: 1
Output Projection Parameters:  +proj=merc +lon_0=0 +k=1 +x_0=0 +y_0=0
+no_defs +a=6378137 +rf=298.257223563 +towgs84=0.000,0.000,0.000
Output Unit Factor: 1
Input map rbd@ATLANTIC in location GEBCO_GEODETIC:
n=46050366.66617828 s=-46050366.66617872 w=-20028233.86541469
e=20028233.86541469 rows=2159 cols=4321

But when I apply the n-s w-e it suggests and r.proj again:

Input:
Cols: 4321 (4321)
Rows: 2159 (2159)
North: 89.916705 (89.916705)
South: -89.916705 (-89.916705)
West: -179.916686 (-179.916686)
East: 179.916686 (179.916686)
EW-res: 0.083275
NS-res: 0.083295

Output:
Cols: 4321 (4321)
Rows: 2159 (2159)
North: 46050366.666178 (46050366.666178)
South: -46050366.666179 (-46050366.666179)
West: -20028233.865415 (-20028233.865415)
East: 20028233.865415 (20028233.865415)
EW-res: 9270.184617
NS-res: 42658.977921


You see? It stretched the NS-res. Is it me or the data? (probably me, of
course).

Thanks again,
Marcello.


On Mon, Jul 2, 2012 at 2:47 AM, Hamish hamis...@yahoo.com wrote:

 Markus:
  ...
|
 Projection: x,y
 
  ... this looks suspicious! Above output may help us to find
  the problem.

 probably he was following my tutorial at
  http://grass.osgeo.org/wiki/Global_datasets#ETOPO1_.28DEM.29

 which uses a nasty hack to get around the original grid-registered
 data exceeding the limits of polar coordinate space:
 r.in.bin -f in=etopo1_bed_g.flt out=etopo1_bed_g \
n=90.0085 s=-90.0085 e=180.0083334 \
w=-180.0083334 rows=10801 cols=21601 anull=-

 but the cellhd/ file was not reset in sync with the location.

 I have now rewriten that wiki entry to use a r.region cleanup
 method instead of ugly filesystem edits.


 Hamish

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


Re: [GRASS-user] Invalid region and coordinates when trying to reproject.

2012-07-02 Thread Marcello Gorini
Makus:


 What are the extents of the vector in latlon before projecting into
 the mercator location? Note that regions spanning 180 degrees
 longitude or more can not be reprojected to mercator locations due to
 mathematical constraints.20037508.34278924


That's the result of v.info of the of the result of v.in.region

 |   N:  89:55:00.138825NS:
89:55:00.138825S |
 |   E: 179:55:00.069428EW: 179:55:00.069428W



 This inf looks very suspicious, the latlon vector extents very
 probably too large and could not be represented in the projection of
 the target location.



Too much for mercator? I am really lost here

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


Re: [GRASS-user] Invalid region and coordinates when trying to reproject.

2012-07-02 Thread Marcello Gorini
Hamish said:


 It is impossible to reproject from a simple XY location to a
 projected location, or vice versa. Simple XY is just like graph
 paper, with no Earth-based geo-* part to it. It is most commonly
 used for imagery where x,y are measured in pixels, and manual geo-
 referencing must be performed, not a reprojection between known
 coord systems.


Yes, I hadn't noticed this xy. Sure it won't work.



 Start over from the beginning, creating a new lat/lon location and
 importing your data into it. (assuming that's what the source
 data's native coordinates are in)



I did and it worked flawlessly.



 sorry for introducing the nasty hack which suggested using xy,
 Hamish


I really don't remember doing that, but anyway, since you updated
the wiki page, I cannot press charges against you anymore.

Thanks a lot!!

All the best,
Marcello.
___
grass-user mailing list
grass-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-user


Re: [GRASS-user] Correct import of a global grid (0E to 360E) to GRASS (-180W to 180E).

2012-07-01 Thread Marcello Gorini
Michael  wrote:

 Which way does it get flipped?
 
  Most NetCDF files will import via r.in.gdal correctly, but they
  are displayed as (from L-R) as 0-180E/180W-0. This is the way
  that most climate model files are created and then stored.



It's not a climate model, but that's exactly the way it gets flipped.


Hamish wrote:


 note I've had some data in the past which either had bad meta-
 data embedded in it or GDAL was reading wrong. GRASS itself should
 deal with 0-360 longitudes just fine for raster maps. But if the
 import goes wrong for whatever reason it is easy to fix by
 resetting the bounds with r.region.



Thanks a lot, that solved it. Believe it or not I never used r.region,
so it didn't come into my mind: Simply doing:

r.region map=mymap e=180 w=-180

did the trick. Thanks again.

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


[GRASS-user] Invalid region and coordinates when trying to reproject.

2012-07-01 Thread Marcello Gorini
Dear all,

After importing a netCDF file and correcting its bounds using
r.region so that it spans from -180/180 instead of 0/360, a tried to
reproject it in the way I always do, following the GRASS book.

I use v.in.region to get the region as a vector, v.proj in a mercator
location and then g.region to the projected vector, before applying
r.proj to my raster.

But when trying to do g.region I get

ERROR: Invalid region: Invalid coordinates

Following a recent Hamish reply, I noticed that summing the cells
I get more than 180 N-S and more than 360 E-W. This time, it's not
because the cell size is greater than it should be, but I think that's
because the grid is gridline-registered and than GRASS is creating
an extra cell in both directions.

Although this is not a ETOPO1 grid (but it's in a way based on it), I
followed GRASS Wiki and did something like this

# reduce region by 1 cell
g.region rast=etopo1_bed_g
eval `g.region -g`
g.region n=n-$nsres s=s+$nsres e=e-$ewres -p

# save smaller raster and remove original
r.mapcalc etopo1_bed_g.crop = etopo1_bed_g
g.remove etopo1_bed_g


Now, the new grid is within accepted bounds, but the error persists and
the result of v.info of the projected region is

++
 | Layer:   rbd
 | Mapset:
BRASIL
 | Location:
GEBCO_MERCATOR
 | Database:
/home/marcello/grassdata
 |
Title:
 | Map scale:
1:1
 | Map format:  native
 | Name of creator:
marcello
 | Organization:
 | Source date: Sun Jul  1 07:55:56 2012
 |
 |   Type of Map:  vector (level: 2)
 |

 |   Number of points:   0   Number of areas:  0
 |   Number of lines:0   Number of islands:
0
 |   Number of boundaries:   1   Number of faces:  0
 |   Number of centroids:1   Number of kernels:0
 |

 |   Map is 3D:  No
 |   Number of dblinks:  0
 |
 | Projection: x,y
 |   N:   infS:
-4605.12989327
 |   E:   infW: -20037508.34278924
 |

 |   Digitization threshold:
0
 |   Comments:
 |
 ++

Obviously, something is wrong with the N and E coordinates.

Any ideas?

Thanks in advance.

Marcello.

















the problem is with broken cellsize value, resulting in a
latitude beyond the north pole.

 0.008337679505 * 18000 - 60
ans =  90.07823109

which is  90.

it seems that whatever software exported it (don't be afraid to
name names :) was holding or calculating the resolution with
single-precision floating point numbers but exporting it as if
it were a double-precision number. So the second half the number
is inexact jibberish.

Edit the cell size back to 0.00833 (no small feat with a
3.7gb file, even for vi) and it'll work.


Importing with GDAL would give the same illegal-north latitude
result, although r.in.gdal now has a '-l' flag to reset the
northern boundary into something legal (after which you Must
repair it to the real value with r.region), although you could
get the same effect by editing the header to lie about the
cellsize or southern value to get it to fit into legal lat/lon,
then again use r.region to set the bounds exactly. (the
resolution as seen with r.info should end up exactly at 30 arc-
sec; bypass the built in failsafe checks at your own risk)
But the real solution is to get the software that created it
to not export broken files.
___
grass-user mailing list
grass-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-user


[GRASS-user] Correct import of a global grid (0E to 360E) to GRASS (-180W to 180E).

2012-06-30 Thread Marcello Gorini
Dear all,

I am pretty sure this must be easy, but I just can't find the correct
answer.

My grid is a netcdf geographic grid that spans from 0E to 360E and from 90N
to -90S.

I use r.in.gdal to import it, but it gets flipped since GRASS region spans
from -180W to 180E.

How to do it right?

Thanks in advance.

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


Re: [GRASS-user] Correct import of a global grid (0E to 360E) to GRASS (-180W to 180E).

2012-06-30 Thread Marcello Gorini
Thanks for he fast response

Daniel:


 you should be able to define a location with that CRS using either the
 correct EPSG code or a WKT string.



I don't have the EPSG code. Only know that it isin lat long and that long
is 0-360.



 If need be, you can always create a WKT string as well, although I don't
 know how to do that.




Me neither.

I will keep trying. Thanks again.

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


Re: [GRASS-user] How to implement this kind of operation?

2012-06-29 Thread Marcello Gorini
DavidRA wrote:

Hi, here's the problem: I need to implement an operation in GRASS wich takes
 an UNDEFINED number of raster layers and, for each position, takes the cell
 of each raster, sort those values, makes some calculations and store the
 result in the same position of the output raster.



Hey,

R.series does all the following calculations for any number of rasters at
once:

*average, count, median, mode, minimum, min_raster, maximum, max_raster,
stddev, range, sum, variance, diversity, slope, offset, detcoeff, quart1,
quart3, perc90, quantile, skewness, kurtosis

If you need more advanced calculations, I think you will need to use
scripting. Or maybe you can tweak the code of r.series to put your own
formulas.

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


Re: [GRASS-user] calculate mode value on moving window (with mapalgebra) with null value cells

2012-06-19 Thread Marcello Gorini
G. Allegri wrote:

I need to assign values to a the cells on the border of a raster. The
 inside and the outside are distinguished by having or not having null
 values assigned.
 I also need to keep the other cell values (internals) untouched.


 Hey,

Check out r.grow. I am pretty sure you can modify the example given in the
manual to find the borders of your raster. Something like:

# creates an inverted raster from your raster
 r.mapcalc raster_inverted=if(isnull(raster,1,null())
# grow this inverted raster by one cell
 r.grow in=raster_inverted out=raster_inverted_grown
# now both rasters overlap at the border, so you can do whatever you want
with it, for instance, extract it
 r.mapcalc border=if(raster_inverted_grown==1 
isnull(raster)==0,raster,null())

Hope it helps.

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


Re: [GRASS-user] calculate mode value on moving window (with mapalgebra) with null value cells

2012-06-19 Thread Marcello Gorini
OK, sorry for that. So your problem is the famous edge effect that affects
us all.

Well, I think you have a real problem there.

If you find a good solution, please share.

Best,
Marcello.






On Tue, Jun 19, 2012 at 11:39 AM, G. Allegri gioha...@gmail.com wrote:

 Hi Marcello,
 thanks, but my problem is not finding the border. I already have it (with
 its own category) but assigning it the value from the surrounding (not
 null) value, e.g. max/min/etc.
 The problem with kernel filters/moving windows is that they do not filter
 out null values...

 giovanni


 2012/6/19 Marcello Gorini gor...@gmail.com



 G. Allegri wrote:

 I need to assign values to a the cells on the border of a raster. The
 inside and the outside are distinguished by having or not having null
 values assigned.
 I also need to keep the other cell values (internals) untouched.


  Hey,

 Check out r.grow. I am pretty sure you can modify the example given in
 the manual to find the borders of your raster. Something like:

 # creates an inverted raster from your raster
  r.mapcalc raster_inverted=if(isnull(raster,1,null())
 # grow this inverted raster by one cell
  r.grow in=raster_inverted out=raster_inverted_grown
 # now both rasters overlap at the border, so you can do whatever you want
 with it, for instance, extract it
  r.mapcalc border=if(raster_inverted_grown==1 
 isnull(raster)==0,raster,null())

 Hope it helps.

 Cheers,
 Marcello.





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


Re: [GRASS-user] Add up several maps, which hold different regions, with mapcalc

2012-06-18 Thread Marcello Gorini
Büro Seling said:


 My problem begins, when I now try to add up all these single maps into one
 larger map.
 I searched for a solution and tried several things, but nothing worked.

 Any tipps or hinds?



Hey,

As always, there is probably a much more elegant solution to this problem,
but this should get you going for now:

  g.region
rast=map1,map2
# just to make sure your region encompass everything
 r.mapcalc
bigmap=if(isnull(map1),9,map1)+if(inull(map2),9,map2)   #
replace nulls on the fly by a specific value that your data does not contain
 r.mapcalc
bigmap=if(bigmap==9,null(),bigmap)
# put back the nulls

Well, ugly like all my codes, but it works.

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


Re: [GRASS-user] Add up several maps, which hold different regions, with mapcalc

2012-06-18 Thread Marcello Gorini
I knew it! Just testing you all :)


On Mon, Jun 18, 2012 at 12:54 PM, Paulo van Breugel
p.vanbreu...@gmail.comwrote:

  First set the region to fit all maps, like suggested by Marcello. Then,
 use r.patch to combine the maps.

 Cheers,

 Paulo




 On 06/18/2012 01:36 PM, Marcello Gorini wrote:

 Büro Seling said:


 My problem begins, when I now try to add up all these single maps into
 one larger map.
 I searched for a solution and tried several things, but nothing worked.

 Any tipps or hinds?



 Hey,

 As always, there is probably a much more elegant solution to this problem,
 but this should get you going for now:

   g.region
 rast=map1,map2
 # just to make sure your region encompass everything
  r.mapcalc
 bigmap=if(isnull(map1),9,map1)+if(inull(map2),9,map2)   #
 replace nulls on the fly by a specific value that your data does not contain
  r.mapcalc
 bigmap=if(bigmap==9,null(),bigmap)
 # put back the nulls

 Well, ugly like all my codes, but it works.

 Cheers,
 Marcello.





 This body part will be downloaded on demand.



 ___
 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] Euclidean distance (grow.distance) on raster to certain extent?

2012-05-07 Thread Marcello Gorini
 Tanya wrote:


 I am trying to run the grow.distance command to create a raster that
 displays the euclidean distance from an 'orchard' outward to 1108m.  I am
 not trying to measure the distance between 2 non-null features, but simply
 wish to have the euclidean distance extend out from the orchard to 1108m.



 I don´t know r.grow.distance or why it is not working for you, but every
time I need distance rasters, I use the procedure found in the GRASS book,
as follows:

r.mapcalc area1=1
r.cost -k in=area1 out=distance_to_orchard start_rast=orchard_location  --o
--q
r.mapcalc  distance_to_orchard=distance_to_orchard * (ewres() +
nsres())/2.

It is an approximate measure, but you can evolve this idea for a better
solution for your case. Then you only need to use your buffer as a mask to
get the final raster you want or simply use:

r.mapcalc
final_raster=if(distance_to_orchard=1108,distance_to_orchard,null())

Hope it helps.
Cheers,
Marcello.
___
grass-user mailing list
grass-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-user


Re: [GRASS-user] Measuring Distance Along a Line

2012-01-18 Thread Marcello Gorini
On Wed, Jan 18, 2012 at 4:07 PM, Rich Shepard rshep...@appl-ecosys.comwrote:

  I have a map with a couple of transect lines that intersect points on a
 separate map. I want to measure the distance from one end of each transect
 line to the point which it overlays. While I thought there was a v. module
 to do this, I'm not seeing it. If it's v.distance, I don't see how to apply
 that module to measuring a distance along one line interactively.


Again, vectors are not my thing, but maybe you could include the end point
into your vector and use v.to.db with option=length to get the distance
along your line vector.

A raster solution to similar problems that you could maybe use somehow is
to generate distance maps from target points, lines or areas and then
extract the values of these maps through other vectors or using r.mapcalc.

I've used this solution in many different cases and it is very nice to see
the distance maps. The procedure is described in the GRASS book as:

r.mapcalc area_one=1
r.cost -k in=area_one out=distance_to_something start_rast=something
r.mapcalc approx_distance_in_meters=dist_to_something * (ewres() + nsres())
/ 2.)

Hope it gives you some insights.

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


Re: [GRASS-user] Subtracting One Vector Map From Another

2012-01-16 Thread Marcello Gorini
On Mon, Jan 16, 2012 at 10:37 PM, Rich Shepard rshep...@appl-ecosys.comwrote:

  Somehow, my streets map also contains lines for streams. I would like to
 subtract the stream lines from the street lines but do not see a module to
 do this. Map algebra works well with raster maps (r.mapcalc), but what
 module will allow me to do this with two vector maps?


Vectors are not my thing, but I checked the GRASS Book... maybe v.select?

*v.select* - Selects features from vector map (A) by features from other
vector map (B).

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


[GRASS-user] Re: Extracting centroids as a raster (and are these centroids really at the center?)

2012-01-09 Thread Marcello Gorini
Marcello:

 Dear all,

 I need to extract the center of raster areas as another raster.

 Since my script is totaly raster-based (and I am not used to using
 vectors),
 I tried to find some kind of r.thin that would generate the centroids,
 instead of trying to force the area into lines.

Markus:

find a script attached which calculated centroids from raster areas.
You may expand it with a final r.in.xyz step to write out the calculated
centroid(s) as raster map.

Hope this helps,
Markus

Thanks A LOT !!

Now the centroids are in the center :)

You can see in the attached image the new ones in pink. Great!

But I encountered a few problems to get there. I don't know if it is
something with me or my system (6.4.0svn on old ubuntu 9.1), but the script
wasn't looping correctly over the different areas.

It seemed that r.category was ignoring the mask created in the loop and that
was causing trouble. So, instead of using r.mask, I actually created a
temporary raster containing only the selected area in the loop. I also put
the area calculation with r.stats inside the loop.

Also, as you instructed, I made the program output the centroid coordinates
to a file and then use it as input to r.in.xyz to create the raster. It
worked as a charm!

Thanks again,
Marcello.

P.S.; I also attached the modified r.centroid.new if you would like to take
a look. I hope I didn't deform your script too much :)

http://osgeo-org.1803224.n2.nabble.com/file/n7168100/centroids.png 

http://osgeo-org.1803224.n2.nabble.com/file/n7168100/r.centroid.new
r.centroid.new 

--
View this message in context: 
http://osgeo-org.1803224.n2.nabble.com/Extracting-centroids-as-a-raster-and-are-these-centroids-really-at-the-center-tp7146840p7168100.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] Extracting centroids as a raster (and are these centroids really at the center?)

2012-01-03 Thread Marcello Gorini
Dear all,

I need to extract the center of raster areas as another raster. 

Since my script is totaly raster-based (and I am not used to using vectors),
I tried to find some kind of r.thin that would generate the centroids,
instead of trying to force the area into lines.

I believe there is no such module (please correct me if I'm wrong), so I had
to use vectors. 

I then did:
- r.to.vect input=raster_areas output=vectorized_areas feature=area
- v.to.points in=vectorized_areas out=vector_centroids type=centroid
- v.to.rast input=vector_centroids output=raster_centroids use=val

I was succesfull, but I have to questions:
1- Is there a better way to accomplish this? 
2 - How are these centroids calculated? I ask this because they don't seem
to be the actual visual centroid, as the attached image hopefully clarifies
to you. The image shows three example areas with the centroids both as an
x and as a raster in pink.

I thank you all very much for any help and wish you a great new year with a
lot of intelectual challenges.

Best,
Marcello.

http://osgeo-org.1803224.n2.nabble.com/file/n7146840/areas.png 

--
View this message in context: 
http://osgeo-org.1803224.n2.nabble.com/Extracting-centroids-as-a-raster-and-are-these-centroids-really-at-the-center-tp7146840p7146840.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


Re: [GRASS-user] GRASS citation?

2011-12-15 Thread Marcello Gorini
Markus:



 Please use
 ... GRASS GIS (© 1999-2011 GRASS Development Team) version is 6.4.2svn and
 the main modules that compose 


But the version is 6.4.0svn (2010) actually...


  and then when I talk about a specific module I say like
 
  the minimum-watershed-size threshold was set to 100 cells (GRASS GIS
  6.4.0svn Reference Manual, 2010)...

 I suppose you use 6.4.2svn Reference Manual, 2011 ?


In truth, I only consult the manual via g.manual module, so I believe it
is 6.4.0svn (2010) as well, isnn't it?
___
grass-user mailing list
grass-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-user


Re: [GRASS-user] GRASS citation?

2011-12-15 Thread Marcello Gorini
OK, thanks.

And by the way... congrats on the GRASS paper!


On Thu, Dec 15, 2011 at 6:22 PM, Markus Neteler nete...@osgeo.org wrote:

 On Thu, Dec 15, 2011 at 9:10 PM, Marcello Gorini gor...@gmail.com wrote:
 
  Markus:
 
 
 
  Please use
  ... GRASS GIS (© 1999-2011 GRASS Development Team) version is 6.4.2svn
  and
  the main modules that compose 
 
 
  But the version is 6.4.0svn (2010) actually...

 Of course, if you used 6.4.0svn (2010) then cite it as that.

 For the more general GRASS citation, see my previous message.

 Markus

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


Re: [GRASS-user] GRASS citation?

2011-12-14 Thread Marcello Gorini
Humm I think you forgot the thing :) , no?



On Wed, Dec 14, 2011 at 5:22 PM, Stephen Sefick sas0...@auburn.edu wrote:

 I saw a paper on this list the other day, but have deleted the original
 email.  Is this the appropriate thing to cite when referring to GRASS GIS
 in a paper?
 many thanks,

 --
 Stephen Sefick
 
 Auburn University
 Biological Sciences
 331 Funchess Hall
 Auburn, Alabama
 36849
 
 sas0...@auburn.edu
 http://www.auburn.edu/~sas0025
 

 Let's not spend our time and resources thinking about things that are so
 little or so large that all they really do for us is puff us up and make us
 feel like gods.  We are mammals, and have not exhausted the annoying little
 problems of being mammals.

-K. Mullis

 A big computer, a complex algorithm and a long time does not equal
 science.

  -Robert Gentleman


 __**_
 grass-user mailing list
 grass-user@lists.osgeo.org
 http://lists.osgeo.org/**mailman/listinfo/grass-userhttp://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] GRASS citation?

2011-12-14 Thread Marcello Gorini
Stephen Sefick:


  I saw a paper on this list the other day, but have deleted the original
  email.  Is this the appropriate thing to cite when referring to GRASS
 GIS in
  a paper?


Markus Neteler:


 You may cite as this:

 (from http://grass.osgeo.org/download/index.php)

 *  GRASS Development Team, 2010. Geographic Resources Analysis Support
 System (GRASS) Software, Version 6.4. Open Source Geospatial
 Foundation. http://grass.osgeo.org
 *  GRASS Development Team, 2010. Geographic Resources Analysis Support
 System (GRASS) Programmer's Manual. Open Source Geospatial Foundation.
 Electronic document: http://grass.osgeo.org/programming6/


In three days time I will be submitting a paper to Geomorphology where the
main research was made entirely with GRASS.

I was willing to ask you: right now when I mention I used GRASS I refer to
it like

... GRASS GIS (© 1999-2010 GRASS Development Team) version is 6.4.0svn and
the main modules that compose 


and then when I talk about a specific module I say like

the minimum-watershed-size threshold was set to 100 cells (GRASS GIS
6.4.0svn Reference Manual, 2010)...


Is it correct? If so, should I use the same two aforementioned references
at the reference list, but replacing Programmer's Manual by Reference
Manual?

Thanks for the help. I really want to do it right.

Best,

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


Re: [GRASS-user] How to initialize raster maps.

2011-12-10 Thread Marcello Gorini
Moritz:

As Glynn suggests:



 for i = 1 to 10
 sum_new = sum + i
 g.remove rast=sum
 g.rename rast=sum_new,sum



OK, sorry, I got so scared I overlooked Glynn's suggestion. I did another
experiment to see the differences in processing time. Since I iterate 1260
times in my script, I tried the following alternatives with i varying
from 1 to 1260:

1 - r.mapcalc sum=sum+$i  # my suspicious way

2 - r.mapcalc sum_new = sum + $i  # Glynn's suggestion after
Moritz's explanation
g.remove rast=sum --q
g.rename rast=sum_new,sum --q

3 - r.mapcalc sum_new = sum + $i  # Moritz's suggestion
g.rename rast=sum_new,sum --overwrite --q

Results:

1 - 125 seconds
2 - 183 seconds
3 - 154 seconds

Bottom line:

If Glynn says Moritz suggestion with the g.rename --overwrite is OK, I will
give back the 30 seconds Moritz had saved me before :) and end up with 30
seconds more of processing time, but with no undefined behaviour.

If method number 2 must be used, I will end up with 60 seconds more, what
won't do me any harm anyway.

Thanks a lot for this interesting exercise.

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


Re: [GRASS-user] How to find the second largest value in a series of rasters.

2011-12-09 Thread Marcello Gorini
Marcello:

 I have to find the maximum value for each cell in a series
  of rasters and generate both a maximum value map and a
  categorical map with the raster number which contains the
  maximum value.


Hamish:


 see also:

 http://grass.osgeo.org/wiki/Time_series#Common_legends_for_many_raster_maps

 it sounds like you have done something similar already, but
 maybe you could adapt it somehow, or it is faster.

 I think you'll have to use g.copy + r.null (or better r.reclass)
 to hide the highest values.


Thanks for the ideas. I still haven't quite figured out how to do it
without a loop, but I will keep trying.

Anyway, I found very useful this kind of expression:

 for MAP in `g.mlist rast pattern=$MAP_PATTERN` ; do
   eval `r.info -r $MAP`

I didn't know it was possible. Thanks.

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


Re: [GRASS-user] How to initialize raster maps.

2011-12-09 Thread Marcello Gorini
Marcello:

  But there is no way to avoid r.mapcalc, is there?


Hamish:


 I doubt you'd get very much faster or more efficient even by
 writing your own C module. (it would probably only take you a
 minute to create a r.zero module out of the doc/raster/r.example
 code; just change return x; to return 0; and compile.


Well, out of curiosity, I made the changes to r.example and compiled it. I
then made a small script that initializes a map with the dimensions of one
of my maps ( 677 x 1114) inside a loop using the three approaches mentioned
in this thread:

1 - r.mapcalc initialized_map=if(base_map99,1,0)  # my very smart
method :)
2 - r.mapcalc initialized_map=0 # Moritz method
3 - r.example input=initialized_map output=zero_map   # Hamish idea

Since I initialize rasters 374 times in my original script, I made the loop
in this way.

Results:
1 - 49 seconds
2 - 19 seconds
3 - 58 seconds

Bottom line:
- Thanks Moritz for the tip, it will save me at least 30 seconds from now
on.
- Thanks Hamish, because I never knew r.example existed and it was fun to
test the different approaches. But, no, r.example should stay just as
that an example :)

Thanks to all.

Cheers,
Marcello.


P.S.:

Hamish:

 tip: to avoid all your scripts breaking when you want to use
 grass7, always add a space around the '=' in r.mapcalc.

  r.mapcalc initialized_map = 0


I will keep it in mind from now on. Tks.
___
grass-user mailing list
grass-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-user


Re: [GRASS-user] How to initialize raster maps.

2011-12-09 Thread Marcello Gorini
Glynn:


 Note that using the same map as both input and output results in
 undefined behaviour. Even if it happens to work, there's no guarantee
 that it will continue to work in future versions.

 If you need to implement an iterative algorithm, you should generate a
 new map, then replace the original with g.remove+g.rename afterwards.


Now, you scared me, because my ongoing work is pretty much based on this
kind of code. I use r.mapcalc to create maps that serve as counters such as
the command i++ in C. I initialize them as zero maps and then based on some
logic I keep incrementing them, pretty much like the following pseudo-code
to implement a sum:

sum = 0
for i = 1 to 10
 sum = sum + i
end

But I do more that that.

For instance, if certain conditions are met in other maps at a given
iteration and the initialized map is zero, then update the initialized map
with the value of i. If not, don't change it. In this way, my map is
updated every iteration until no more cells meet the condition or some
threshold is met and processing stops. I even use d.rast to display the map
as it is being updated.

How should I proceed to avoid the undefined behaviour and still get what
I want? (I hope I was able to make myself understood :) )

Thanks for your comments.

Glynn:


 There is no point in referring to your original map in the r.mapcalc
 expression; the result will always be created with the bounds and
 resolution of the current region. AFAIK, the only modules which don't
 behave this way are r.in.*, which create the output to match the size
 of the input file.


Yes, Moritz's suggestion showed me that. I perfectly understand it now,
thanks.


Glynn:

I'm sure that there are other ways to create a map consisting of
 zeros, but there's no reason to suspect that any of them will be
 faster than r.mapcalc.


 There really isn't. I just suspected it was taking too long and found out
in my little experiment that was only my fault, putting a logic expression
where there was no need of it. Setting the region and r.mapcalc zero_map =
0 does the job.

Thank you.

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


Re: [GRASS-user] How to find the second largest value in a series of rasters.

2011-12-09 Thread Marcello Gorini
Marcello:


  My problem is that I also need to find the *second largest* value and the
  corresponding raster number which contains the second largest value.
 
  I am doing that by iterating over all classes through a shell script,
 but it
  obviously takes much more time than using a simple r.series command.
 
  Can anyone share any idea on how to accomplish that using r.series or
  something similar?


Glynn:


 There isn't an efficient way to do this using existing tools. If you
 need the efficiency, I suggest adding a second largest aggregate to
 lib/stats (based upon c_max.c and c_maxx.c), and updating r.series to
 use it.


Thanks for pointing me the way. I think it is a little beyond my skills,
but I might give it a try.

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


[GRASS-user] How to find the second largest value in a series of rasters.

2011-12-08 Thread Marcello Gorini
Dear all,

I have to find the maximum value for each cell in a series of rasters and
generate both a maximum value map and a categorical map with the raster
number which contains the maximum value.

R.series is, therefore, perfect to accomplish that using
method=maximum,max_raster.

My problem is that I also need to find the *second largest* value and the
corresponding raster number which contains the second largest value.

I am doing that by iterating over all classes through a shell script, but it
obviously takes much more time than using a simple r.series command.

Can anyone share any idea on how to accomplish that using r.series or
something similar?

Thanks in advance for your thoughts.

Best regards,
Marcello. 


--
View this message in context: 
http://osgeo-org.1803224.n2.nabble.com/How-to-find-the-second-largest-value-in-a-series-of-rasters-tp7075764p7075764.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] How to initialize raster maps.

2011-12-08 Thread Marcello Gorini
Dear all,

Inside a loop in a shell script, I keep incrementing the values of a raster
map using r.mapcalc with some logical expressions. 

Therefore, I need to initialize the raster map before the loop itself.
Ideally, I would like to initialize it as a raster with the same dimensions
as my base map, but containing only zeros.

In order to do that, I use the following expression:

r.mapcalc initialized_map=if(base_map99,1,0)

Besides being one of the ugliest pieces of code one could ever write, it
also incurs in waste of processing time.

Which would be a more elegant and optimized way of initializing these raster
maps?

Thanks in advance for any thoughts you could share.

Best regards,
Marcello. 

--
View this message in context: 
http://osgeo-org.1803224.n2.nabble.com/How-to-initialize-raster-maps-tp7075938p7075938.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


Re: [GRASS-user] How to initialize raster maps.

2011-12-08 Thread Marcello Gorini
:)  how difficult, isn't it?

Thanks!

But there is no way to avoid r.mapcalc, is there?



On Thu, Dec 8, 2011 at 8:04 PM, Moritz Lennert mlenn...@club.worldonline.be
 wrote:

 On 08/12/11 22:26, Marcello Gorini wrote:

 Dear all,

 Inside a loop in a shell script, I keep incrementing the values of a
 raster
 map using r.mapcalc with some logical expressions.

 Therefore, I need to initialize the raster map before the loop itself.
 Ideally, I would like to initialize it as a raster with the same
 dimensions
 as my base map, but containing only zeros.

 In order to do that, I use the following expression:

 r.mapcalc initialized_map=if(base_map**99,1,0)

 Besides being one of the ugliest pieces of code one could ever write, it
 also incurs in waste of processing time.

 Which would be a more elegant and optimized way of initializing these
 raster
 maps?

 Thanks in advance for any thoughts you could share.


 g.region rast=YourBaseMap
 r.mapcalc initialized_map=0

 Moritz

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


Re: [GRASS-user] How to find the second largest value in a series of rasters.

2011-12-08 Thread Marcello Gorini
 Moritz:


 Since you have the max_raster value, can't you just take that map out of
 the list you submit to r.series and find the new max_raster and value ?



Unfortunately, I can't. There is not on single map which is the maximum
everywhere. The calculation is done in a cell-by-cell basis, so different
maps have the maximum value locally.

Somehow, if after identifying the maximum value, I could make it zero or
-, for instance, then I could re-run r.series to get the second largest
value, but I don't know how to do it.

But thanks anyway.

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


Re: [GRASS-user] Generate a box that matches the exact processing region

2011-11-23 Thread Marcello Gorini
Hey Antonio,

The command v.in.region is exactly what you want. I use that all the time.

Cheers,
Marcello.



2011/11/23 António Rocha antonio.ro...@deimos.com.pt

 Greetings

 I would like to know how can I generate a polygon for the exact
 computational region (a square). Is this possible? IF so, how can I do that.
 Thanks
 Antonio


 __ Information from ESET NOD32 Antivirus, version of virus
 signature database 6654 (2023) __

 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-userhttp://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] how to count number of occurrences of a specific category value in the neighborhood of a given pixel

2011-11-23 Thread Marcello Gorini
Moritz:

Hello,

 Does anyone see an easy way to count the number of times a specific
 category value occurs in a given neighborhood of a central pixel ?


As always, there is surely a better way in GRASS (probably one single
command), but you could binarize your map (1 for your desired category and
zero for everything else) and then use r.neighbors method=sum
size=desired_neighborhood.

The result would be the desired count.

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


Re: [GRASS-user] Alternative to r.stats to generate % of surface

2011-11-15 Thread Marcello Gorini
Hi Helena,

I have come to the same problem and solved it with ugly and very specific
shell scripts. There is most certainly a better way within GRASS and no
doubt you can code it much better in Shell, but anyway, this may get you
going somehow.

Code snippet:

MAP=$1

g.region rast=$MAP
max_cats=9
file=true_percentages.txt
rm $file

tot=$(r.univar $MAP | grep ^n:  | awk '{print $2}')
r.stats -cn $MAP  stats.txt

cats=1
while [ $cats -le $max_cats ]; do

ncat=`head -$cats stats.txt | tail -1 | awk '{print $2}'`
cat=`head -$cats stats.txt | tail -1 | awk '{print $1}'`
perc=`echo $tot $ncat | awk '{printf(%.5f, $2 / $1 * 100);}'`

echo $cat $perc  $file

cats=$(expr $cats + 1)

done

I wanted everything in text files, so I generated these stats.txt and
true_percentages.txt. The idea of the script is to use the actual cell
count given by r.stats -cn and divide it by the total count given by
r.univar.

Note that this script is very specific and only work for categories that
are incremented by 1. In my case, they go from 1 to 9.

How brave I am to publicize such an ugly script, huh? :) The result sums up
to 1 at least. Just give the name of the categorical map as input.

Hope it helps somehow.

Marcello.



On Tue, Nov 15, 2011 at 9:36 AM, Helena Herrera helenaherrera1...@gmail.com
 wrote:

 Greetings

 I want to calculte % of surface in a raster map for each Integer class
 value. The thing is that I'm, using r.stats but the sum % values is always
 much more (104 or 102 or 105). Is there any other (more precised) method to
 calculate this ?
 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] Alternative to r.stats to generate % of surface

2011-11-15 Thread Marcello Gorini
See? I knew there was a much better way :)



On Tue, Nov 15, 2011 at 2:29 PM, Michael Barton michael.bar...@asu.eduwrote:

 Use r.report.

 This will do exactly what you want and output to a file too.

 Michael
 
 C. Michael Barton
 Director, Center for Social Dynamics  Complexity
 Professor of Anthropology, School of Human Evolution  Social Change
 Arizona State University

 voice:  480-965-6262 (SHESC), 480-727-9746 (CSDC)
 fax:  480-965-7671 (SHESC),  480-727-0709 (CSDC)
 www: http://www.public.asu.edu/~cmbarton, http://csdc.asu.edu











 On Nov 16, 2011, at 2:58 PM, grass-user-requ...@lists.osgeo.org wrote:

  Date: Tue, 15 Nov 2011 11:36:12 +
  From: Helena Herrera helenaherrera1...@gmail.com
  Subject: [GRASS-user] Alternative to r.stats to generate % of surface
  To: grass-user@lists.osgeo.org
  Message-ID:
 CACCE9tiQOu_A2Xt82ZdTLwM28eMX8ze=
 0zkdhsy97khfi9n...@mail.gmail.com
  Content-Type: text/plain; charset=iso-8859-1
 
  Greetings
 
  I want to calculte % of surface in a raster map for each Integer class
  value. The thing is that I'm, using r.stats but the sum % values is
 always
  much more (104 or 102 or 105). Is there any other (more precised) method
 to
  calculate this ?
  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] How to generate a bigger PNG file

2011-11-04 Thread Marcello Gorini
Marcello Gorini wrote:



  Or I guess you could export it with a larger number of pixels by setting
  some environment variables.
 
 export GRASS_WIDTH=
 export GRASS_HEIGHT=


Glynn:


 Those will affect the size of images generated by d.* commands using
 the PNG driver. They won't have any effect upon the images generated
 by d.out.png.


True, my bad, sorry. Once again, I am so used to use d.mon star=PNG
etc... that I bypassed the r.out.png part of her e-mail :)

Hamish:

The book is good, d.out.file is simply using the PNG driver internally. :-)

Oh, no, the book is not good... it is awesome! :) It has got me going
really fast in the beggining and still helps me a lot. The most usefull
book I have by far!

n.b. I typically use this when I want to show multiple overlaid rasters
in ps.map, which can only display one raster at a time. d.out.file format=
geotiff then r.in.gdal + r.composite (or ps.map's rgb instruction).

Thanks for the tip!
Cheers,
Marcello.
___
grass-user mailing list
grass-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-user


Re: [GRASS-user] How to generate a bigger PNG file

2011-11-03 Thread Marcello Gorini
Luisa said:

I'm using r.out.png to generate PNG files from a small patch (like 6x15
pixels) but I'm obtaining a really small PNG file. Sicne I want to
display it a little bit bigger in a website I need to create a bigger
(in size) PNG. What can I do to do this?

Ben said:

You can simply increase the resolution of your
current working region. Then you will get more
cells (and a bigger image) but exactly the same
information.


Or I guess you could export it with a larger number of pixels by setting
some environment variables.

export GRASS_WIDTH=
export GRASS_HEIGHT=

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


Re: [GRASS-user] Re: How to generate a bigger PNG file

2011-11-03 Thread Marcello Gorini
My friend, by your intention of helping Luisa, you ended up helping me a
lot.

I guess I am so attached to the GRASS book that I was conformed to the fact
that I could only export the active display monitor by using the PNG
driver.

D.out.file will help me a lot. Thanks.

Marcello.



On Thu, Nov 3, 2011 at 3:10 PM, Alexander Muriy amu...@gmail.com wrote:

 Luisa, you can use module d.out.file (
 http://grass.gis-lab.info/grass64/manuals/html64_user/d.out.file.html)
 with the *resolution* parameter (double size or quadruple of the image).


 Date: Thu, 3 Nov 2011 12:16:58 +
 From: Luisa Pe?a luisapena1...@gmail.com
 Subject: [GRASS-user] How to generate a bigger PNG file
 To: GRASS user list grass-user@lists.osgeo.org
 Message-ID:

 cah+a188ytff79mfg0ya6f9l9w9ockmxsj6bn1yxxpuguoyr...@mail.gmail.com
 Content-Type: text/plain; charset=iso-8859-1

 Greetings

 I'm using r.out.png to generate PNG files from a small patch (like 6x15
 pixels) but I'm obtaining a really small PNG file. Sicne I want to display
 it a little bit bigger in a website I need to create a bigger (in size)
 PNG. What can I do to do this?
 One idea was to rescale it in a image processing software but I get a low
 quality image
 Is there any solution by using grass?
 Thanks
 Luisa
 -- next part --
 An HTML attachment was scrubbed...
 URL:
 http://lists.osgeo.org/pipermail/grass-user/attachments/2003/6cef341b/attachment-0001.html


 ___
 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] v.to.points

2011-10-18 Thread Marcello Gorini
As far as I know, v.to.points does not write to an external file, it creates
a point vector map within GRASS.

So you should do output=pointmap and then use another module such as
v.out.ascii to generate an actual text file with the points.

Also, when you do that, do not enclose the output portion of the code with
quotes, you don't need them to set a path to the ouput file.

Hope it helps,
Marcello.



On Tue, Oct 18, 2011 at 9:59 AM, ALT SHN i.geograf...@alt-shn.org wrote:

 Hello,

 I'm having problmes with module v.to.points.
 The input is a line shapefile with only two atributtes (both of them
 integers). I always get this error message:

 v.to.points input=AplanadoGRASS@InterpolationTEST type=line llayer=1
 output=C:/Users/Andre
 Mano/Desktop/InterpolationBenchmark/Vectores_Pontos/pontosaplanado dmax=20
 -v

 Nome de arquivo ilegal. O caractere n�o � permitido.


 Illegal vector map name . Character ':' not allowed.


 Output vector map name is not valid map name

 Finished with error



 I'm using GRASS 6.4 through QGIS 1.7 GRASS plugin in a Windows 7
 Professional environment

 Any hints would be very welcomed!!



 --
 ---
 Associação Leonel Trindade
 SOCIEDADE DE HISTÓRIA NATURAL

 Apartado 25 2564-909 Torres Vedras Portugal
 Sede e Biblioteca: rua Cavaleiros da Espora Dourada, 27A 2560 Torres Vedras

 Laboratório de Paleontologia e Paleoecologia: Polígono Industrial do Alto
 do Ameal 2565-641 Ramalhal
 http://alt-shn.blogspot.com
 www.alt-shn.org

 ___
 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] Re: xy to lat long

2011-09-27 Thread Marcello Gorini
Raphael wrote:
  i have imported the etopo dem (geotifff) into grass.
  It appears to be in XY and i would like to convert
  these to lat longs.

Markus:
 But in any case the ETOPO2 will be better (see wiki for an
 article how to import it).

Hamish:
yes for ease of import, but not so much for modernity. 
Historic ETOPO2v2 and ETOPO5 global relief grids are deprecated
but still available.


Another option is to go for the GEBCO_08 or SRTM30_plus grid. I use to
download a gebco grid directly in lat long from
https://www.bodc.ac.uk/data/online_delivery/gebco/select/ in netCDF format.

Then I literally go by the book and do what the GRASS book tell us. I
import the grid into a latlong location using r.in.gdal and generates a
vector of the bounding region:
r.in.gdal -o input=gebco_input.nc output=gebco_output
g.region rast=gebco_output
v.in.region output=boundingbox

Then I open a projected location, project the bounding box and then the
grid:
v.proj input=boundingbox location=GEBCO_GEODETIC mapset=MYMAPSET --o
g.region vect=boundingbox res=1000 -pa
r.proj in=gebco_output location=GEBCO_GEODETIC mapset=MYMAPSET method=cubic
--o

Of course this is the opposite direction of what you want, but if you go for
the gebco grid, it is already in latlong anyway. But then you can use this
procedure to project back and forth your grid.

Hope it helps,
Marcello.




--
View this message in context: 
http://osgeo-org.1803224.n2.nabble.com/xy-to-lat-long-tp6832256p6835646.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] Re: Desperate help needed: GRASS can' t find any add-ons anymore.

2011-09-19 Thread Marcello Gorini
## SOLVED ## 

The problem was located in-between the computer and my chair :)

Thanks to Hamish for pointing it.

Cheers,
Marcello.


Marcello Gorini wrote:
 
 Sorry for this desperate message, but I am having all kinds of troubles in
 the worst moment ever!
 
 My GRASS 6.4.0RC6 on ubuntu 9.10 (old and in need of update, I know)
 suddenly stopped being able to find all my own shell scripts in the
 scripts folder and also all add-ons that I had installed. Some kind of
 path must have been lost, but I have no idea what is going on. 
 
 If I type for instance: r.fuzzy.system help, it prompts r.fuzzy.system:
 command not found.
 
 But I have been using it forever!!
 
 I tried re-installing the add-ons in the same way I have always done, but
 it still can' t find them anymore.
 
 With respect to simple shell modules, If I simply go to the scripts
 folder, open a working script such as r.mapcalculator and save it as
 r.mapcalculator2, give appropriate permissions with chmod and try to use
 it, it gives the same error. GRASS cannot find it!
 
 Any ideas? I am in a serious need to get my add-ons functional, so I would
 really appreciate if anyone could help me on this one (and also my next
 post please).
 
 Best regards,
 Marcello.
 


--
View this message in context: 
http://osgeo-org.1803224.n2.nabble.com/Desperate-help-needed-GRASS-can-t-find-any-add-ons-anymore-tp6806032p6809090.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] Re: Desperate help needed 2: can' t install add-ons in other versions of GRASS.

2011-09-19 Thread Marcello Gorini
Glynn Clements wrote:

It looks like you're trying to build a 6.x add-on against 7.0. 
Probably because of:

svnurl=http://svn.osgeo.org/grass/grass-addons/

For 7, hits should be

   svnurl=https://svn.osgeo.org/grass/grass-addons/grass7


That' s exactly what I am doing, thanks. I tried the correct way and
downloaded r.fuzzy.


Again, this is the 6.x version. 7.0 doesn't have r.fuzzy.system as a
separate add-on; it has a single add-on named r.fuzzy which provides
the modules r.fuzzy.set, r.fuzzy.logic and r.fuzzy.system.

You can have 6.x and 7.0 installed on the same system, but they're
distinct packages. Add-ons written for one won't work with the other.

Thanks for the info. I see that now. I wasn' t able to install it anyway
though, it says  make: *** No rule to make target `install'.  Stop , but
that' s something for another day. 

I was advised not to go into grass 7.0 if I wanted a fast result and that's
what I am going to do. Since I eventually managed to get my old 6.4.0svn
version up and running again, I am sticking with it for the time being.

Thank you very much for your help.

Best regards,
Marcello.

--
View this message in context: 
http://osgeo-org.1803224.n2.nabble.com/Desperate-help-needed-2-can-t-install-add-ons-in-other-versions-of-GRASS-tp6806040p6809145.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


Re: [GRASS-user] Re: Desperate help needed 2: can' t install add-ons in other versions of GRASS.

2011-09-19 Thread Marcello Gorini
On Mon, Sep 19, 2011 at 6:43 PM, Marcello Gorini gor...@gmail.com wrote:

...
  I was advised not to go into grass 7.0 if I wanted a fast result


On Mon, Sep 19, 2011 at 7:24 PM, Markus Neteler nete...@osgeo.org wrote:


 ... are you sure about this?


Sorry, I must explain better.

I am in a hurry to deliver some work, so the advice was in the sense that it
would be easier (and worthier) to try to fix my older installation than
trying to get around grass 7. No doubt once I get used to grass 7, things
will get faster and better, but I would probably loose some precious time
with respect to my work at this moment.

And since my problem with my usual grass was simply due to my own
clumsiness, itś already fixed and I can get straight to work.


  and that's
  what I am going to do. Since I eventually managed to get my old 6.4.0svn
  version up and running again, I am sticking with it for the time being.

 6.4.0 is rather old, consider to use 6.4.2svn.

 Markus



I sure will. Thanks for the advice and comments.

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


[GRASS-user] Desperate help needed: GRASS can' t find any add-ons anymore.

2011-09-18 Thread Marcello Gorini
Sorry for this desperate message, but I am having all kinds of troubles in
the worst moment ever!

My GRASS 6.4.0RC6 on ubuntu 9.10 (old and in need of update, I know)
suddenly stopped being able to find all my own shell scripts in the scripts
folder and also all add-ons that I had installed. Some kind of path must
have been lost, but I have no idea what is going on. 

If I type for instance: r.fuzzy.system help, it prompts r.fuzzy.system:
command not found.

But I have been using it forever!!

I tried re-installing the add-ons in the same way I have always done, but it
still can' t find them anymore.

With respect to simple shell modules, If I simply go to the scripts folder,
open a working script such as r.mapcalculator and save it as
r.mapcalculator2, give appropriate permissions with chmod and try to use it,
it gives the same error. GRASS cannot find it!

Any ideas? I am in a serious need to get my add-ons functional, so I would
really appreciate if anyone could help me on this one (and also my next post
please).

Best regards,
Marcello.


--
View this message in context: 
http://osgeo-org.1803224.n2.nabble.com/Desperate-help-needed-GRASS-can-t-find-any-add-ons-anymore-tp6806032p6806032.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] Desperate help needed 2: can' t install add-ons in other versions of GRASS.

2011-09-18 Thread Marcello Gorini
Sorry for this another desperate message, but I am really having all kinds of
troubles in the worst moment ever!

In order to bypass the problem in my previous post, I installed both GRASS
7.0 from svn checkout https://svn.osgeo.org/grass/grass/trunk grass_trunk
and GRASS 6.4.1 from Synaptic in another computer.

Then I can' t install any add-ons! Since I get all kinds of errors, I will
concentrate in the r.fuzzy.system module since it is the really essential
one.
In GRASS 7.0:
  g.extension extension=r.fuzzy.system
svnurl=http://svn.osgeo.org/grass/grass-addons/

result:
*Fetching 'r.fuzzy.system' from GRASS-Addons SVN (be patient)...
Ar.fuzzy.system/flood.map
Ar.fuzzy.system/helpers.c
Ar.fuzzy.system/local_proto.h
Ar.fuzzy.system/flood.rul
Ar.fuzzy.system/rule_parser.c
Ar.fuzzy.system/main.c
Ar.fuzzy.system/system.c
Ar.fuzzy.system/description.html
Ar.fuzzy.system/f_result.png
Ar.fuzzy.system/fuzzylogic.c
Ar.fuzzy.system/io.c
Ar.fuzzy.system/map_parser.c
Ar.fuzzy.system/Makefile
 U   r.fuzzy.system
Checked out revision 48345.
Compiling 'r.fuzzy.system'...
test -d OBJ.x86_64-unknown-linux-gnu || mkdir -p
OBJ.x86_64-unknown-linux-gnu
gcc  -mtune=nocona -minline-all-stringops -O2 -Wall -D_FILE_OFFSET_BITS=64  
-I/usr/local/grass-7.0.svn/include -I/usr/local/grass-7.0.svn/include 
-D_FILE_OFFSET_BITS=64  -DPACKAGE=\grassmods\  
-I/usr/local/grass-7.0.svn/include -I/usr/local/grass-7.0.svn/include -o
OBJ.x86_64-unknown-linux-gnu/fuzzylogic.o -c fuzzylogic.c
In file included from fuzzylogic.c:1:0:
local_proto.h:106:5: error: expected specifier-qualifier-list before
‘RASTER_MAP_TYPE’
make: *** [OBJ.x86_64-unknown-linux-gnu/fuzzylogic.o] Error 1
ERROR: Compilation failed, sorry. Please check above error messages.*

I have no idea what  local_proto.h:106:5: error: expected
specifier-qualifier-list before ‘RASTER_MAP_TYPE’  means!

I have found the following thread:
http://permalink.gmane.org/gmane.comp.gis.grass.user/40781
but no real answers.

Then I downloaded it using:
svn checkout https://svn.osgeo.org/grass/grass-addons/raster/r.fuzzy.system/
then cd to the r.fuzzy.system folder and, following GRASS wiki
(http://grass.osgeo.org/wiki/Compile_and_Install#Addons):
make MODULE_TOPDIR=/usr/local/grass-7.0.svn

But I get:
*gcc  -mtune=nocona -minline-all-stringops -O2 -Wall -D_FILE_OFFSET_BITS=64  
-I/usr/local/grass-7.0.svn/include -I/usr/local/grass-7.0.svn/include 
-D_FILE_OFFSET_BITS=64  -DPACKAGE=\grassmods\  
-I/usr/local/grass-7.0.svn/include -I/usr/local/grass-7.0.svn/include -o
OBJ.x86_64-unknown-linux-gnu/fuzzylogic.o -c fuzzylogic.c
In file included from fuzzylogic.c:1:0:
local_proto.h:106:5: error: expected specifier-qualifier-list before
‘RASTER_MAP_TYPE’
make: *** [OBJ.x86_64-unknown-linux-gnu/fuzzylogic.o] Error 1
*
I won't comment on my tries with GRASS 6.4.1 so that this email does not get
excessively long, but no need to say that I had no success.

I am in a serious need to get any GRASS installation up and running with
add-ons, so I would really appreciate if anyone could help me on this one
(and also my previous post please).

Best regards,
Marcello.


--
View this message in context: 
http://osgeo-org.1803224.n2.nabble.com/Desperate-help-needed-2-can-t-install-add-ons-in-other-versions-of-GRASS-tp6806040p6806040.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] Re: How to extract one single contour.

2011-08-01 Thread Marcello Gorini
Also, even when I zoom in to extract only one contour, the exported points
are not always in order in the file, in a way that when I use it to plot in
another program as a line, it connects the points in a wrong way.

How can I export contours in an amenable way to use in other programs, such
as Matlab, for instance?

Thanks in advance.

Marcello.





Marcello Gorini wrote:
 
 Dear all,
 
 I am interested in extracting the longest -1,000 meter contour from a
 bathymetric DEM and to save it in a text file as points.
 
 By doing:
 
 r.contour in=my_dem out=contour levels=-1000
 v.to.points in=contour out=contour_points dmax=my_resolution
 v.out.ascii in=contour_points out=contour_points.txt fs=  dp=4
 
 ... I get a text file with the contour points, however, it includes many
 different isolated contours, all with the same category (1).
 
 Since I need only the longest, I believe I need to separate the different
 contours, maybe assigning different categories somehow, then maybe
 updating the database with v.to.db using option=length and then
 v.db.select the longest contour.
 
 But I am not very used to working with vectors, so I don't know if that's
 the correct approach (nor how to accomplish it), so I would appreciate
 very much any help.
 
 Many thanks.
 
 Marcello.
 


--
View this message in context: 
http://osgeo-org.1803224.n2.nabble.com/How-to-extract-one-single-contour-tp6639491p6641376.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] How to extract one single contour.

2011-07-31 Thread Marcello Gorini
Dear all,

I am interested in extracting the longest -1,000 meter contour from a
bathymetric DEM and to save it in a text file as points.

By doing:

r.contour in=my_dem out=contour levels=-1000
v.to.points in=contour out=contour_points dmax=my_resolution
v.out.ascii in=contour_points out=contour_points.txt fs=  dp=4

... I get a text file with the contour points, however, it includes many
different isolated contours, all with the same category (1).

Since I need only the longest, I believe I need to separate the different
contours, maybe assigning different categories somehow, then maybe updating
the database with v.to.db using option=length and then v.db.select the
longest contour.

But I am not very used to working with vectors, so I don't know if that's
the correct approach (nor how to accomplish it), so I would appreciate very
much any help.

Many thanks.

Marcello.


--
View this message in context: 
http://osgeo-org.1803224.n2.nabble.com/How-to-extract-one-single-contour-tp6639491p6639491.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


Re: [GRASS-user] Mapcalc to replace a range of values

2011-07-13 Thread Marcello Gorini
r.mapcalc new_raster=if(old_raster-0.01  old_raster0.01,0,old_raster)

Cheers,
Marcello.


On Wed, Jul 13, 2011 at 10:10 AM, Rebecca Bennett rabenn...@ymail.comwrote:

 Hello Grass users,

 I have a (hopefully) quick question - I would like to replace all values in
 a raster that fall in the range -0.01 to 0.01 (i.e. 0.01-0.01) with 0 but
 can't quite work out how to express this in mapcalc.

 Can anyone set me on the right track?

 Thanks for reading,
 Rebecca

 ___
 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] Re: Monte Carlo realizations of categorical maps.

2011-07-05 Thread Marcello Gorini
Dear all,

This is just a follow-up of my original message as I promissed.

It has been two weeks since I tried to contact the author, but received no
response. 

I eventually used a workaround based on r.random.surface itself. I added
random fields to the original continuous parameters instead of using the
categorical maps. It is not the same thing, but it was enough for me.

Anyway, if anybody gets any info with respect to the r.random.model module,
it would be interest to hear about.

Thanks.

Marcello.

--
View this message in context: 
http://osgeo-org.1803224.n2.nabble.com/Monte-Carlo-realizations-of-categorical-maps-tp6502447p6550076.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] R.fuzzy.system bug/limitation or just me ?

2011-07-05 Thread Marcello Gorini
Dear all,

I am using r.fuzzy.system for quite a while now, but still have a persisting
bug/problem that I can't solve. Hopefully it is just me doing something
wrong.

A use a GRASS/Shell script to automatically parse the input .map file (that
contains all the fuzzy sets definitions) and update it with values based on
some input raster's statistics. The problem is that I get errors depending
on these values, but they don't make sense to me.

A wrong fuzzy set definition and the corresponding error is as follows:

Fussy set (*wrong*):
%Xmargin_crosc_3
$ concave {right; -0.014310,-0.009618; linear; 0; 1}
$ planar {both; *-0.014310,-0.009618,0.010177,0.015142*; linear; 0; 1}
$ convex {left; 0.010177,0.015142; linear; 0; 1}

Error:
*ERRO:Map: Xmargin_crosc_3, Membership: planar: Points sequence must be
 non-declining*

If I am not mistaken, the sequence [-0.014310,-0.009618,0.010177,0.015142]
is non-declining, is it not?

Now, if I take one decimal place out, it works nicely.

Fussy set (*OK*):
%Xmargin_crosc_3
$ concave {right; -0.01431,-0.00962; linear; 0; 1}
$ planar {both; *-0.01431,-0.00962,0.01018,0.01514*; linear; 0; 1}
$ convex {left; 0.01018,0.01514; linear; 0; 1}

But it is not a question of decimal places, I believe, because if I keep the
original 6 decimal places, but multiply the original input data by 100, it
also works nicely.

Fussy set (*OK*):
%Xmargin_crosc_3
$ concave {right; -1.431014,-0.961829; linear; 0; 1}
$ planar {both; *-1.431014,-0.961829,1.017739,1.514197*; linear; 0; 1}
$ convex {left; 1.017739,1.514197; linear; 0; 1}

But even more confusing is when I allow 9 decimal places in the fuzzy set
definition. Then I get a very strange error:

Fussy set (*wrong*):
%Xmargin_crosc_3
$ concave {right; -0.014310295,-0.009618395; linear; 0; 1}
$ planar {both; *-0.014310295,-0.009618395,0.010177389,0.015141969*; linear;
0; 1}
$ convex {left; 0.010177389,0.015141969; linear; 0; 1}

Error:
*ERRO:Map: Xmargin_crosc_3, Variable: planar: Points must be numeric but
 is: or space between '-' and digit*

So I am really stuck here. I am very sorry for this boring post and problem,
but it is very important for me to get it solved. Eventually, I would like
my complete work to become a GRASS Add-on (if there will be interest from
the GRASS community), but I don't want to put some ugly workaround in the
code (as it is right now).

Thanks a lot for any help (or even just for reading this long post).

Marcello.

--
View this message in context: 
http://osgeo-org.1803224.n2.nabble.com/R-fuzzy-system-bug-limitation-or-just-me-tp6550095p6550095.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] Re: Monte Carlo realizations of categorical maps.

2011-06-23 Thread Marcello Gorini
Hamish wrote:

also, for a categorical map you might try r.to.vect + the v.random.cover
module for GRASS 6 from addons:
   http://grass.osgeo.org/wiki/Addons#v.random.cover

v.random.cover is a shell script for creating random points constrained
within an irregularly shaped vector area. (v.random places points only in
current region rectangle). Optionally the user can upload raster values at
the points. See also 'r.random cover= vector_output='


Thanks for your comments Hammish. I am not sure how to do it this way, but
yes, there is probably a workaround. For now, I will just wait for a
response from the author.

Rainer:
 so why not contact the author?

Hamish:
(he still emails comments from time to time, so your chances are good.
let me know if the email you tried was too old, I may have a newer one
somewhere)

I tried:
charles.r.ehlschlae...@usace.army.mil

Let's see if it works.
Thanks a lot,
Marcello.



--
View this message in context: 
http://osgeo-org.1803224.n2.nabble.com/Monte-Carlo-realizations-of-categorical-maps-tp6502447p6508407.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] Re: Monte Carlo realizations of categorical maps.

2011-06-22 Thread Marcello Gorini
On Wed, Jun 22, 2011 at 2:24 AM, Marcello Gorini lt;gor...@gmail.comgt;
wrote:

 Deal all,

 I am interested in a module that seems to be discontinued since GRASS 4.
 It
 is called r.random.model and it is used for Monte Carlo realizations of
 categorical maps.


Rainer:

Me to - sounds really interesting. But even a google search did not result
in anyhing - so why not contact the author?
And please post your findings here!


I just sent him an e-mail. I sure will post any response here.
Thanks for your interest.

Cheers,
Marcello.


--
View this message in context: 
http://osgeo-org.1803224.n2.nabble.com/Monte-Carlo-realizations-of-categorical-maps-tp6502447p6506921.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] Monte Carlo realizations of categorical maps.

2011-06-21 Thread Marcello Gorini
Deal all,

I am interested in a module that seems to be discontinued since GRASS 4. It
is called r.random.model and it is used for Monte Carlo realizations of
categorical maps.

I found the reference for this module in the man page of r.random.surface,
more specifically in 

http://chuck.ehlschlaeger.info/older/acm/paper.html

Can anybody help me find/use this module or any other GRASS tool that could
achieve similar results?

The overall idea is to generate spatially autocorrelated random realizations
of categorical maps based on a set of probability maps for each category. 

Thanks in advance.

Best regards,
Marcello Gorini.

--
View this message in context: 
http://osgeo-org.1803224.n2.nabble.com/Monte-Carlo-realizations-of-categorical-maps-tp6502447p6502447.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] Re: Duplication of lines in output of r.profile.

2011-04-06 Thread Marcello Gorini
Marcello wrote:
 I solved it using:
 
  d.where  map_profile
 
 instead of:
 
  r.profile -ig input=map output=map_profile
 
 The only problem is that I can't see the points while I am digitizing.

Hamish wrote:
use the middle mouse button with d.where to show the line.

Yes, thanks, it helped. Then I can see the line after I digitize it, but the
good thing about r.profile is that you can see it WHILE you are digitizing,
so you can get your bearings better. But that's a minor problem anyway.


  I get many duplicated lines, some of which are not exactly duplicated,
  but displace the coordinates by a very small distance, affecting also
  the distance.

Hamish asked:
what version of GRASS? what kind of machine/OS?

It's GRASS 6.4.0svn on a Linux Ubuntu 9.10, sorry not to have said it
before.

how about if you trim off the 3rd,4th columns from what becomes the input
file?

OK, so I tried this:

r.profile -ig input=map output=map_profile
cat map_profile | cut -d' ' -f1,2 | r.profile -g input=another_map
output=another_map_profile --o 

Was that what you meant? I get the same weird results, unfortunately.

Any other ideas?

Thanks for the help,

Marcello.



--
View this message in context: 
http://osgeo-org.1803224.n2.nabble.com/Duplication-of-lines-in-output-of-r-profile-tp6242694p6245727.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] Re: create 3D raster and display

2011-04-06 Thread Marcello Gorini
Janet Choate said:

i want to display a raster in 3D. i.e. display landscape maps 'draped on
top' of the dem so i can show the terrain in 3D rather than as a flat
image.


do i need to convert a raster to a 3D raster via r.to.rast3 or
r.to.rast3elev, set the region for 3D?
how to display?

Not at all. As far as I know, r.to.rast3 is for real 3D with volume and all.

What you want is sometimes called 2.5D and is simply achieved by:

nviz elevation=dem color=landscale_map

The nviz screen should pop open and then you should be able to move your 3D
display as desired.

Regards,
Marcello.

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



--
View this message in context: 
http://osgeo-org.1803224.n2.nabble.com/create-3D-raster-and-display-tp6248005p6248180.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] Duplication of lines in output of r.profile.

2011-04-05 Thread Marcello Gorini
Dear all,

My problem (a very common one) is that I want to digitize a profile and then
sample other maps using the extracted coordinates. In order to do so, I
tried the following;

r.profile -ig input=map output=map_profile 

With that, I managed to digitize the profile and to get the following file
(a piece of it):

-8063204.17 4311231.25 0.00 -3769.528809
-8062653.139926 4312065.737586 1000.00 -3768.805176
-8062102.113186 4312900.225172 2000.00 -3768.805176
-8061551.086445 4313734.712758 3000.00 -3767.810791
-8061000.059705 4314569.200344 4000.00 -3764.308105
-8060449.032965 4315403.687930 5000.00 -3764.054199
-8059898.006224 4316238.175517 6000.00 -3763.437500
-8059346.979484 4317072.663103 7000.00 -3760.115723
-8058795.952743 4317907.150689 8000.00 -3759.792236
-8058244.926003 4318741.638275 9000.00 -3758.425537

Which is correct. I have eastings, northings, distance (which increases in
steps equal to the resolution of 1000 meters) and then the sampled depth.

Ok, but the problem appears when I try to use this profile to sample another
map... 

cat map_profile | r.profile -g input=another_map output=another_map_profile

 the following happens:

-8063204.17 4311231.25 0.00 8
-8062653.139927 4312065.737586 1000.00 8
-8062653.139926 4312065.737586 1000.00 8
-8062102.113186 4312900.225172 2000.00 8
-8061551.086446 4313734.712758 3000.00 8
-8061551.086445 4313734.712758 3000.00 8
-8061000.059705 4314569.200344 4000.00 8
-8060449.032965 4315403.687930 4999.99 8
-8059898.006225 4316238.175516 5999.99 8
-8059898.006224 4316238.175517 6000.00 8
-8059346.979484 4317072.663103 7000.00 8
-8058795.952744 4317907.150689 8000.00 8
-8058795.952743 4317907.150689 8000.00 8

I get many duplicated lines, some of which are not exactly duplicated, but
displace the coordinates by a very small distance, affecting also the
distance. The 8 in the last column is correct, don't worry.

Any ideas about what might be happening?

I thank you all very much in advance for any help.

Best regards,
Marcello.


--
View this message in context: 
http://osgeo-org.1803224.n2.nabble.com/Duplication-of-lines-in-output-of-r-profile-tp6242694p6242694.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] Re: Duplication of lines in output of r.profile.

2011-04-05 Thread Marcello Gorini
Dear all,

I solved it using:

 d.where  map_profile

instead of:

 r.profile -ig input=map output=map_profile

The only problem is that I can't see the points while I am digitizing. Also,
it demands another line of code to get the actual topographic profile since
d.where only gets the coordinates, instead of sampling the raster.
Still don't know why the method with r.profile doesn't work right though. If
anybody does, I would be glad to hear.

Thanks,
Marcello.


Marcello Gorini wrote:
 
 Dear all,
 
 My problem (a very common one) is that I want to digitize a profile and
 then sample other maps using the extracted coordinates. In order to do so,
 I tried the following;
 
r.profile -ig input=map output=map_profile 
 
 With that, I managed to digitize the profile and to get the following file
 (a piece of it):
 
 -8063204.17 4311231.25 0.00 -3769.528809
 -8062653.139926 4312065.737586 1000.00 -3768.805176
 -8062102.113186 4312900.225172 2000.00 -3768.805176
 -8061551.086445 4313734.712758 3000.00 -3767.810791
 -8061000.059705 4314569.200344 4000.00 -3764.308105
 -8060449.032965 4315403.687930 5000.00 -3764.054199
 -8059898.006224 4316238.175517 6000.00 -3763.437500
 -8059346.979484 4317072.663103 7000.00 -3760.115723
 -8058795.952743 4317907.150689 8000.00 -3759.792236
 -8058244.926003 4318741.638275 9000.00 -3758.425537
 
 Which is correct. I have eastings, northings, distance (which increases in
 steps equal to the resolution of 1000 meters) and then the sampled depth.
 
 Ok, but the problem appears when I try to use this profile to sample
 another map... 
 
cat map_profile | r.profile -g input=another_map
output=another_map_profile
 
  the following happens:
 
 -8063204.17 4311231.25 0.00 8
 -8062653.139927 4312065.737586 1000.00 8
 -8062653.139926 4312065.737586 1000.00 8
 -8062102.113186 4312900.225172 2000.00 8
 -8061551.086446 4313734.712758 3000.00 8
 -8061551.086445 4313734.712758 3000.00 8
 -8061000.059705 4314569.200344 4000.00 8
 -8060449.032965 4315403.687930 4999.99 8
 -8059898.006225 4316238.175516 5999.99 8
 -8059898.006224 4316238.175517 6000.00 8
 -8059346.979484 4317072.663103 7000.00 8
 -8058795.952744 4317907.150689 8000.00 8
 -8058795.952743 4317907.150689 8000.00 8
 
 I get many duplicated lines, some of which are not exactly duplicated, but
 displace the coordinates by a very small distance, affecting also the
 distance. The 8 in the last column is correct, don't worry.
 
 Any ideas about what might be happening?
 
 I thank you all very much in advance for any help.
 
 Best regards,
 Marcello.
 


--
View this message in context: 
http://osgeo-org.1803224.n2.nabble.com/Duplication-of-lines-in-output-of-r-profile-tp6242694p6244412.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] Re: Region definition

2011-03-26 Thread Marcello Gorini

Luisa Peña wrote:
 
 Greetings
 
 I have a raster map with a size like 25000 x 3 with valid values on
 all
 its extent. With another raster, I defined a sub-extent of this raster,
 much
 smaller where only a small area is valid and the rest it NULL() like this:
 r.mapcalc output = if(regional_area@PERMANENTgt;0,2004@Reg,null())
 In this case, regional_area is a smaller area and I want to select only a
 portion of 2004@Reg that falls inside regional_area.
 So I obtained output as a raster map with only some values (4000x3000)
 If I define g.region rast=output I still obtain a 25000 x3 region
 which
 does not make sense since I only have a small valid area.
 How can I define a region, using g.region for only output valid pixels?
 
 Thanks
 Luisa
 
 ___
 grass-user mailing list
 grass-user@lists.osgeo.org
 http://lists.osgeo.org/mailman/listinfo/grass-user
 


g.region zoom=output ?

--
View this message in context: 
http://osgeo-org.1803224.n2.nabble.com/Region-definition-tp6207972p6210464.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] Re: Creating raster of geographic coordinates

2011-03-03 Thread Marcello Gorini

Nepomuk Reinhard wrote:
 
 Dear all,
 
 I'm a newbie in grass GIS so I'm sorry, if this question is very simple.
 Has anyone any idea how to create a raster map including only the
 information of the latitude and longitude of each cell? I want to write a
 script to compute the solar elevation angle for a large area and time
 range and it would be easier with this map. Can anyone help me? Thank you
 very much
 

Hey,

You can assess the internal variables which r.mapcalc work with by some
specific commands. x() and y() retrieve the coordinate information. 

So, after definining your region of calculation with g.region, you can then
do:

r.mapcalc long=x()   
r.mapcalc lat=y()

In this way, you will have two rasters, each of which contains one dimension
of your coordinates. Then you can do calculations with them as you like.

Is it what you wanted? Hope it helps.

Cheers,
Marcello.

--
View this message in context: 
http://osgeo-org.1803224.n2.nabble.com/Creating-raster-of-geographic-coordinates-tp6080460p6085591.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] Re: Calculate averagfe of raster maps without mapcalc

2011-02-16 Thread Marcello Gorini

Kim:

I need to calculate the average of a set of raster images. How can I
calculate it without using mapcalc?
THanks


Hello Kim,

You can use the module r.series. Like this, if you have few images:

r.series input=image1,image2,image3... method=average output=averaged_image

Or if you have a bunch of images with similar names, you can do:

r.series input=`g.mlist pattern=the_pattern_within_the_ names sep=,`
method=average output=averaged_image

Hope this helps.

Marcello.



-- 
View this message in context: 
http://osgeo-org.1803224.n2.nabble.com/Calculate-averagfe-of-raster-maps-without-mapcalc-tp6031736p6032330.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] Re: Eliminating values based on a null

2011-02-16 Thread Marcello Gorini

Jenny:

in my base map (called X) I have a few null values and, in Y map I want to
eliminate pixels that match with null values in X. How can I do this?
besides using mapcalc

Hello Jenny,

I don't know if it is a coincidence, but your problem can be solved in the
same way as Kim's problem.

You can use the module r.series with the -n flag. It will propagate the
nulls among your input rasters. The method you use does not matter because
the -n flag overrides it. So it would be like this:

r.series -n input=X,Y output=Y_without_X_nulls method=average (or any
method)

Hope this helps,

Marcello.
-- 
View this message in context: 
http://osgeo-org.1803224.n2.nabble.com/Eliminating-values-based-on-a-null-tp6031771p6032382.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] Re: v.kernel -- how to get useful results

2011-02-15 Thread Marcello Gorini


Aren Cambre wrote:
 
 I am not getting any responses. :-) Am I doing something really dumb? Is
 this the right forum for this kind of question?
 
 Thanks,
 
 Aren
 
 On Sun, Feb 13, 2011 at 8:02 AM, Aren Cambre a...@arencambre.com wrote:
 
 Maybe I could clarify. Here's the command:
 *v.kernel --verbose input=master_grass7 output=master_grass7a_heatmap
 stddeviation=.0001*

 Here's the command output:
 *STDDEV: 0.000100*
 *RES: 200.00 ROWS: 1000 COLS: 1000*
 *
 *
 *Writing output raster map using smooth parameter=0.000100.*
 *
 *
 *Normalising factor=0.00.*
 *Maximum value in output: 0.00e+000.*

 If I change stddeviation to *100*, here's what I get:
 *STDDEV: 100.00*
 *RES: 200.00 ROWS: 1000 COLS: 1000*
 *
 *
 *Writing output raster map using smooth parameter=100.00.*
 *
 *
 *Normalising factor=64826.350188.*
 *Maximum value in output: 0.00e+000.*

 Either way, the resulting raster is a large salmon/pink square. I have no
 idea what I'm doing wrong. I've tried varying the *stddeviation
 *parameter
 from 100 to .0001 and some values in between, and I don't get anything
 different. Heck, I just now used 100 and .01 and got nothing
 different.

 I was really hoping to make a high res heat map of these 2.5 million
 points
 and overlay on to a street map layer.

 Aren


 On Fri, Feb 11, 2011 at 9:45 PM, Aren Cambre a...@arencambre.com wrote:

 I am not clear how to get useful results out of v.kernel. I have a
 vector
 layer imported from PostGIS that has about 2.5 million points. I want to
 make a high density raster to show where these points are clustered. I
 can
 get the vector layer to display in GRASS just fine, albeit without
 attributes because of http://trac.osgeo.org/grass/ticket/1274.

 It's not clear to me, based on
 http://grass.fbk.eu/gdp/html_grass64/v.kernel.html, how you can get it
 to
 do something besides make a big, pinkish (salmon-red?) square?

 Aren



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

Hey,

I had tried playing around with v.random and v.kernel to see if I could
understand your problem, but I couldn't find any solutions so I didn't post
it. But since you got upset with GRASS community, I will share what I found
out anyway :)

I tried with different numbers of points and with different resolutions and
I was amazed that you could make v.kernel work with 2.5 million points in a
200 meter resolution with a 100 stdeviation!! My quadcore computer took
so much that I gave up.

I noticed that it goes slower with increasing resolution, increasing number
of points and increasing stdev. I also noticed that you have to set a much
higher stdev for smaller resolutions and that this value is by no means
intuitive. 

For instance: for my 2.5 meter resolution, I got meaningful results for
1,000 points using a stdev of 30. However, this same 30 stdev in my 1,000
resolution region gives me the salmon/pink square. So, in this case, a
10,000 stdev begins to give me good results.

So, my humble opinion is that you should try stdevs greater than 100, but
still much smaller than 1,000,000. I believe that it is just a matter of
tuning these parameters with respect to your resolution and number of
points.

Hope this helps (or at least, keep you in the list :) )

Marcello.


-- 
View this message in context: 
http://osgeo-org.1803224.n2.nabble.com/v-kernel-how-to-get-useful-results-tp6018010p6027287.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] Re: v.kernel -- how to get useful results

2011-02-15 Thread Marcello Gorini

 Aren said:
Where is resolution adjusted?
http://grass.fbk.eu/gdp/html_grass64/v.kernel.html doesn't make that clear.

GRASS works with the region concept. You can adjust any region settings with
the command g.region, like:

g.region res=desired_resolution -p

The -p is for you to see the resulting changes. 

Am I supposed to have a pre-made raster layer already that corresponds to
my
vector layer?

No, you probably don't. I would suggest you play around with v.random to
create some random points and then use v.kernel to make the heat map. Do
that with different number points, stdev and resolutions to get the feel of
it.

Maybe in this way you will understand what is going on with your specific
case.

I really appreciate your advice! 

Any time! Sorry not to help you more.

I'm not upset with the list, was just afraid this was too esoteric or
poorly stated.

I think I myself have been a little upset a few times when I did not get any
responses to my querries :) that's why I mentioned, I guess. But I from
Brazil, so either I get upset or I get really happy :)

Cheers,
Marcello.

-- 
View this message in context: 
http://osgeo-org.1803224.n2.nabble.com/v-kernel-how-to-get-useful-results-tp6018010p6028684.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] Re: r.param.scale curvatures: are really OK

2010-11-02 Thread Marcello Gorini

Hello,

I cannot really answer your question, but I have been working with a
combination of your fuzzy modules for GRASS and r.param.scale in order to
accomplish a fuzzified version of Wood's morphometric feature extraction
method.

In doing so, I noticed that the results of r.param.scale param=feature
differ very much from the results of this same module in Wood's original
software Landserf, by using the same slope and curvature thresholds. Do you
think this can be an associated issue to what you mentioned?

All I can say is that the formula you described (the one used in GRASS) is
exactly the same that is in Wood's Ph.D. thesis, which in turn is based in
Evans (1979) work, as you probably already know.

By the way, great fuzzy modules!

Best regards,

Marcello.





Jarek Jasiewicz wrote:
 
 Hi
 while I modified r.param.scale for my purposes I noticed that some 
 formulas for curvatures differs from that I know:
 
 
 for example:
 
 plan curvature: is
 
 (2.0 * (b * d * d + a * e * e - c * d * e) /
  pow(e * e + d * d, 1.5));
 
 probably shall be:
 
 ( (b * d * d + a * e * e - 2.0 *(c * d * e)) /
  pow(e * e + d * d, 1.5));
 
 
 profile curvature: is
 
  return (-2.0 * (a * d * d + b * e * e + c * e * d) /
  ((e * e + d * d) * pow(1.0 + d * d + e * e, 1.5)));
 
 probably shall be:
 
  return (- (a * d * d + b * e * e + 2.0* (c * e * d)) /
  ((e * e + d * d) * pow(1.0 + d * d + e * e, 1.5)));
 
 Of course threre could be reasons why little different formulas are used 
 but I do not see any.
 
 This formulas is in grass 6.4, 6.5 and 7.0 and I assume in older version 
 too.
 
 regards
 Jarek
 ___
 grass-user mailing list
 grass-user@lists.osgeo.org
 http://lists.osgeo.org/mailman/listinfo/grass-user
 
 

-- 
View this message in context: 
http://osgeo-org.1803224.n2.nabble.com/r-param-scale-curvatures-are-really-OK-tp5696388p5698886.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] Re: reclassify raster based on distribution

2010-10-27 Thread Marcello Gorini

 Timmie says:
An assiciated question:
How do I get a diagram of the frequency distribution of 
the floating point values of a raster?

I tried histogram but I cannot get the label on the x and y axis.

Something like a plot of the r.report output.


Hello Timmie,

Not really an answer, but maybe some ideas. 

GRASS does not seem to be really powerful with respect to statistical plots,
so what you could do is to use a combination of GRASS+Shell+Python, more
specifically the library Matplotlib of Python.

I tried R for a while, but since I am not very good at scripting, Matplotlib
turned out to be much more user-friendly. 

You can parse the output of GRASS modules using unix commands and send them
to a python script that uses Matplotlib. You can see below an example of the
kind of plots I've been doing in this way.

http://osgeo-org.1803224.n2.nabble.com/file/n5680166/sample_feature_signature.png
 

The best way to get going I would say is to look at their examples gallery
http://matplotlib.sourceforge.net/gallery.html , then find the example that
better fits your needs and modify the code.

Hope it helped a bit.

Cheers,
Marcello.

-- 
View this message in context: 
http://osgeo-org.1803224.n2.nabble.com/reclassify-raster-based-on-distribution-tp5679127p5680166.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] Re: A Script that only selects raster inside a polygon

2010-09-24 Thread Marcello Gorini

Pedro Roma:

I want to develop a script that crops a raster in order to only have the
pixels that are located inside a vector polygon. 

There is probably a more elegant solution, but this will do:

g.region vect=your_vector
v.to.rast input=your_vector output=your_vector_rasterized use=val
r.mask input=your_vector_rasterized
r.mapcalc clipped_raster=original_raster
r.mask -r

Hope this helps,

Marcello.
-- 
View this message in context: 
http://osgeo-org.1803224.n2.nabble.com/A-Script-that-only-selects-raster-inside-a-polygon-tp5567368p5567467.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] Re: A Script that only selects raster inside a polygon

2010-09-24 Thread Marcello Gorini

Pedro Roma:

I want to develop a script that crops a raster in order to only have the
pixels that are located inside a vector polygon.

Marcello Gorini: 

 There is probably a more elegant solution, but this will do:
 
 g.region vect=your_vector
 v.to.rast input=your_vector output=your_vector_rasterized use=val

 Nikos:

(comment of minor importance I guess... the above needs value= to be fed 
with a value of course).

 r.mask input=your_vector_rasterized
 r.mapcalc clipped_raster=original_raster
 r.mask -r

Marcello,

honestly, it's very nice to see how you stepped up from 0 to 100 within
almost 
zero time :-)

(...watch out for curves and steep slopes :-p)

Thanks a lot for your comments Nikos! I am just trying to make up for lost
time due to my Windows point-and-click past life :-)

Cheers,
Marcello.

-- 
View this message in context: 
http://osgeo-org.1803224.n2.nabble.com/A-Script-that-only-selects-raster-inside-a-polygon-tp5567368p5568572.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] Re: Feature extraction in GRASS and Landserf.

2010-08-25 Thread Marcello Gorini

On Mon, Aug 16, 2010 at 10:20 PM, Marcello Gorini gor...@gmail.com wrote:

 Dear all,

 By comparing morphometric feature maps obtained from both r.param.scale
 in
 GRASS and the function sufparam using LandScript in Landserf (Wood,
 1996-2009), I noticed great discrepancies.

 Actually, a morphometric feature map derived in GRASS using slope
 tolerance
 of 3 and curvature tolerance of 0.03 is similar (visually) to a map
 derived in Landserf using 3 for slope and 0.05 for curvature.

Markus:

Please generate a difference map (color table differences) and put a
screenshot online somewhere. Perhaps also drawn over the shaded
DEM (r.shaded.relief) with d.his (h=differences i=shaded_terrain).

Markus

Dear Markus,

Sorry for my very late response, I was REALLY far away from the computer.

I attached the feature maps both from GRASS (the top one) and Landserf (the
bottom one). The DEM is a huge seamount and its surroundings, obtained from
the GEBCO grid (1000 meters grid size). As you can see, the discrepancies I
mentioned are so great that I believe no differences maps are needed (I
think you will agree with me, but if not I could gladly send you the dif
map).

Both maps use slope tolerance of 3 and curvature tolerance of 0.03. 

In order to make these maps look the same, I had to use curvature tolerance
of 0.11 in Landserf, leaving the same slope value. I know the slope value is
in degrees both in GRASS and Landserf and I know the curvature value in
Landserf is dimensionless, but I don't know the unit of curvature in GRASS.  

I believe that both GRASS and Landserf use the same Wood's algorithm, so
there should not be any differences, right?

Or are there any modifications in the GRASS version? With respect to units,
maybe?

I thank you very much for any help.

Marcello.
http://osgeo-org.1803224.n2.nabble.com/file/n5460832/GRASS_features.png 
http://osgeo-org.1803224.n2.nabble.com/file/n5460832/LANDSERF_features.png 

-- 
View this message in context: 
http://osgeo-org.1803224.n2.nabble.com/Feature-extraction-in-GRASS-and-Landserf-tp5429470p5460832.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] Re: Installing r.area

2010-08-01 Thread Marcello Gorini

Hello Daniel,

I also wanted to use r.area, so I installed it but had an error, as posted
here
http://osgeo-org.1803224.n2.nabble.com/New-modules-in-svn-add-on-r-area-and-r-convergence-td5161926.html#a5199839

Then afterwards Milton Ribeiro sent me another way to get the same results
in a rather fast way. 

I don't want to interrupt your struggle to get r.area working, but if you
need some fast results, I believe you could try this alternative:

r.stats -na input=clumped_map | awk '{print $1,=,int($2/1)+1}' |
r.reclass input=clumped_map output=clumped_map_AreaHA - --o

The area is calculated in squared meters than converted to hectares by awk
(but you can probably change units within r.stats) than sent to r.reclass.

Hope this helps in anyway.

Cheers,

Marcello.

-- 
View this message in context: 
http://osgeo-org.1803224.n2.nabble.com/Installing-r-area-tp5340139p5360992.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] Re: how to get raster region corresponding to vector polygon region?

2010-06-17 Thread Marcello Gorini


Kwas wrote:
 
 
 Hello, 
 I have a raster map (dem) and I want to select a region of the raster
 corresponding to a polygon that is in a vector map.nbsp; What is the best
 way to do this?nbsp; It looks like r.in.poly might be along the lines of
 what I need but in that case I think I would need to generate the ascii
 poly file first but I'm wondering if there is a better way?nbsp; Seems
 like
 there should be a single command to do this. 
 
 My vector map has 45 polygons with cat values 1..45,nbsp; so I would like
 to get a section from my raster map corresponding to one of the
 polygons specified by cat value. 
 
 appreciate any help! 
 thanks, 
 ken 
 
 ___
 grass-user mailing list
 grass-user@lists.osgeo.org
 http://lists.osgeo.org/mailman/listinfo/grass-user
 
 

Hello Ken,

I am also new to GRASS, but I have been doing what you want quite a lot
these days. There is probably a better way to do that (and I would like to
hear it very much, specially if there is a single command to do this), but
for now, I think the code below does the job:

g.region vect=your_vector
v.extract input=your_vector output=selected_polygon type=area
where=cat=desired_cat
v.to.rast input=selected_polygon output=polygon_rasterized use=val type=area
r.mask input=polygon_rasterized

Now, any processing that you do will be applied only in the region
corresponding to the selected polygon. 
If you want to create a raster corresponding to the selected polygon, just
do:

r.mapcalc new_raster=any_old_raster

To take out the mask, just type:
r.mask -r

Hope this helps,

Marcello.







-- 
View this message in context: 
http://osgeo-org.1803224.n2.nabble.com/how-to-get-raster-region-corresponding-to-vector-polygon-region-tp5192862p5193386.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] Re: Select random cells from map

2010-06-01 Thread Marcello Gorini

António Rocha:
Hi there
I need to randomly select non-null cells from a given map. I tried 
r.random.cells but I cannot define a maximum number random cells and 
some selected random cells are not valid values in my map. is there any 
other function to randomly select cells from a raster?

Hello Antônio,

This one I think I can help.
There is this command v.random that allows you to create a vector
containing random points in your current region. And you can control the
number of points with the parameter n. Than you can upload the vector
database with values from any raster with the command v.what.rast and than
export it to a file if you want.

The manual has this clarifying example:

v.random output=random_samples n=20
v.db.addtable map=random_samples layer=1 columns='cat INTEGER, sample DOUBLE
PRECISION'
v.what.rast vector=random_samples raster=elevation@permanent layer=1
column=sample 

However, I believe that if you have null cells in your raster and some of
the random points happen to fall over them, you will have less valid points
than you expect, so I would say that you should check the resultant
database.

Hope this helps.
Best regards,

Marcello.

-- 
View this message in context: 
http://osgeo-org.1803224.n2.nabble.com/Select-random-cells-from-map-tp5125298p5125703.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] Re: Trying python scripts.

2010-05-31 Thread Marcello Gorini

On Mon, May 31, 2010 at 12:11 AM, Marcello Gorini gor...@gmail.com wrote:

 OK, right after a wrote that, I thought I was being too bold.

 Should I go for:

svn checkout https://svn.osgeo.org/grass/grass/branches/releasebranch_6_4
grass64_release

Markus:
Yes.

Subsequently, it is sufficient to run

cd grass64_release
svn update

No need to checkout again and again since update will download
the changes.

Good, thanks for the tip.
Great that I am already in the new version. Everything is going to be easier
now.
Cheers,
Marcello.


-- 
View this message in context: 
http://osgeo-org.1803224.n2.nabble.com/Trying-python-scripts-tp5109105p5121589.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


Re: [GRASS-user] Re: Trying python scripts.

2010-05-31 Thread Marcello Gorini
On Mon, May 31, 2010 at 5:39 AM, Daniel Lee lee.daniel.1...@googlemail.com
 wrote:
Hi Marcello,

Great that everything's working for you ;) I'm also a beginner and loving
GRASS and Linux... Anyway, 'nuff said. To Python: Your script worked in the
new version? That means in the new 6-4?

Hello Daniel, how are you?
Yes, I mean https://svn.osgeo.org/grass/grass/branches/releasebranch_6_4 .
I've also tried running Python scripts and have had problems, I ended up
switching over to shell scripts because my work was very time sensitive, but
I really like working with Python and I know it better than shell
scripting. I noticed in your post earlier that you used the command:

*python myscript.py raster1=map1 raster2=map2 output=outmap*

Following questions:
- Is it necessary to input python in front of the script name?

No, you can use ./ only.

- I was under the impression that Python scripts can be saved into the
script directory (*/opt/grass/scripts*, if I'm not mistaken, right now I'm
on another computer so I can't check); is that necessary? If not, do you
just enter the entire path to the script?

Yes, you can also save it in the scripts directory and run it directly or
you can enter the entire path in terminal and ./script.

- I was also under the impression, that since you tell GRASS what kind of a
script it is in the first line (*#!/usr/bin/env python*), that you don't
need to save it as .py. Am I mistaken there?

You are also right. I renamed it without the .py extension and it worked as
well.

I've always saved my python scripts into the script directory and then
tried to run them from the GRASS wxPython GUI. It always seemed to find the
script and then fail to parse it correctly. Perhaps it was because I was
leaving off the python at the beginning of the command line; everything
else should be the same, the script was executable, etc. Any other
thoughts? I sadly can't give any examples at the moment because I'm on
another computer and after my new nstallation I don't have the failed
script outputs as examples any more.

I saved it as r.myscript in the script directory and was able to run
directly from the gui or the terminal with no problems. So I guess it is not
because of the python in the command line. If your version is the same as
mine now, I would check the code itself. But I am really a beginner in
everything so I wouldn't listen to me very much.
At least, I think I showed you that you are right in everything. If you can
post some examples of your failed scripts later on, I (and everybody else)
could try them for you. It would be good for my learning as well.

Thanks!
Daniel

No, I thank you, since you are the first person I might be helping a little
little bit in this list. It is good to at least try to contribute.

Best regards,

Marcello.

2010/5/31 Marcello Gorini gor...@gmail.com
___
grass-user mailing list
grass-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-user


[GRASS-user] Re: Trying python scripts.

2010-05-30 Thread Marcello Gorini


Nikos Alexandris wrote:
 
 Marcello Gorini:
 ...
 I am a total beginner in python and GRASS (and any other programming
 language), so I am trying to run the first examples found in
 http://grass.osgeo.org/wiki/GRASS_and_Python.
 
 Marcello,
 
  just fyi: I've added another simple example script in 
 http://grass.osgeo.org/wiki/GRASS_and_Python.
 
 Nikos
 ___
 grass-user mailing list
 grass-user@lists.osgeo.org
 http://lists.osgeo.org/mailman/listinfo/grass-user
 
 

Thanks Nikos, it worked fine for me. The grass.mapcalc code is the only one
that is giving me trouble though. I guess I will have to stick with shell
scripts for now. But won´t give up python, of course.

Best regards,

Marcello.
-- 
View this message in context: 
http://osgeo-org.1803224.n2.nabble.com/Trying-python-scripts-tp5109105p5118744.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] Re: Trying python scripts.

2010-05-30 Thread Marcello Gorini


Martin Landa wrote:
 
 Hi,
 
 2010/5/30 Marcello Gorini gor...@gmail.com:
 I am a total beginner in python and GRASS (and any other programming
 language), so I am trying to run the first examples found in
 http://grass.osgeo.org/wiki/GRASS_and_Python.
 
 GRASS 6.4.0RC5 is quite old. Try RC6 or better download code from SVN
 
 http://trac.osgeo.org/grass/wiki/DownloadSource#GRASS6.4
 
 Martin
 
 -- 
 Martin Landa landa.martin gmail.com * http://gama.fsv.cvut.cz/~landa
 ___
 grass-user mailing list
 grass-user@lists.osgeo.org
 http://lists.osgeo.org/mailman/listinfo/grass-user
 
 

Hello Martin,

Yes, I think I need to move on and download a newer version.
I will probably try to install GRASS 7.

Thanks for the suggestion.

Best regards,

Marcello.


-- 
View this message in context: 
http://osgeo-org.1803224.n2.nabble.com/Trying-python-scripts-tp5109105p5119718.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] Re: Trying python scripts.

2010-05-30 Thread Marcello Gorini

OK, right after a wrote that, I thought I was being too bold.

Should I go for: 

svn checkout https://svn.osgeo.org/grass/grass/branches/releasebranch_6_4
grass64_release

or this one?

svn checkout
https://svn.osgeo.org/grass/grass/tags/release_20090609_grass_6_4_0RC5
grass640_rc5

Thanks again and sorry for all the questions.

Best regards,
Marcello.
-- 
View this message in context: 
http://osgeo-org.1803224.n2.nabble.com/Trying-python-scripts-tp5109105p5119849.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] Re: Trying python scripts.

2010-05-30 Thread Marcello Gorini

On Monday 31 of May 2010 00:11:00 Marcello Gorini wrote:
 
Should I go for:
 
 svn checkout https://svn.osgeo.org/grass/grass/branches/releasebranch_6_4
 grass64_release

 or this one?
 
 svn checkout
 https://svn.osgeo.org/grass/grass/tags/release_20090609_grass_6_4_0RC5
 grass640_rc5

Nikos wrote:

Not sure about the extent of the differences. Go for the releasebranch,
should 
be the latest if I am not wrong.

FYI, there is also http://grass.osgeo.org/wiki/Compile_and_Install_Ubuntu 
which might not be 100% up-to-date but should do it.

Sorry, I just saw your e-mail. I guess it might answer some of my questions.
I am going into http://grass.osgeo.org/wiki/Compile_and_Install_Ubuntu right
now.

Thank you Nikos.


-- 
View this message in context: 
http://osgeo-org.1803224.n2.nabble.com/Trying-python-scripts-tp5109105p5120112.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] Re: Trying python scripts.

2010-05-30 Thread Marcello Gorini


hamish-2 wrote:
 
 Marcello wrote:
 checking for lex... no
 configure: error: *** Unable to locate lex.
 ...
 P.S. I use Ubuntu 9.10 64 bits.
 
 
 you need to install all the Build-depends packages listed here:
 
 http://svn.debian.org/viewsvn/pkg-grass/packages/grass/trunk/debian/control
 
 
 ( http://grass.osgeo.org/wiki/Compile_and_Install_Ubuntu#Dependencies )
 
 
 Hamish
 
 
   
 ___
 grass-user mailing list
 grass-user@lists.osgeo.org
 http://lists.osgeo.org/mailman/listinfo/grass-user
 
 

YES!!! Everything working with all the fuzzy modules already !!

I went through the steps in
http://grass.osgeo.org/wiki/Compile_and_Install_Ubunt, read the INSTALL file
and used Stephen's script and everything went OK! Great!

Thank you everyone!! Really! Now I am fully enjoying and understanding what
the FOSS community is, and especially the GRASS community. I really hope one
day I will know enough to be able to contribute as well.

Thank you Nikos, Carlos, Martin, Hamish, thank you Stephen for your script
that is a piece of art!!

Sorry for the small talk...but THANK YOU!

Cheers,

Marcello.






-- 
View this message in context: 
http://osgeo-org.1803224.n2.nabble.com/Trying-python-scripts-tp5109105p5120201.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] Re: Trying python scripts.

2010-05-30 Thread Marcello Gorini


Marcello Gorini wrote:
 
 
 hamish-2 wrote:
 
 Marcello wrote:
 checking for lex... no
 configure: error: *** Unable to locate lex.
 ...
 P.S. I use Ubuntu 9.10 64 bits.
 
 
 you need to install all the Build-depends packages listed here:
 
 http://svn.debian.org/viewsvn/pkg-grass/packages/grass/trunk/debian/control
 
 
 ( http://grass.osgeo.org/wiki/Compile_and_Install_Ubuntu#Dependencies )
 
 
 Hamish
 
 
   
 ___
 grass-user mailing list
 grass-user@lists.osgeo.org
 http://lists.osgeo.org/mailman/listinfo/grass-user
 
 
 
 YES!!! Everything working with all the fuzzy modules already
 !!
 
 I went through the steps in
 http://grass.osgeo.org/wiki/Compile_and_Install_Ubunt, read the INSTALL
 file and used Stephen's script and everything went OK! Great!
 
 Thank you everyone!! Really! Now I am fully enjoying and understanding
 what the FOSS community is, and especially the GRASS community. I really
 hope one day I will know enough to be able to contribute as well.
 
 Thank you Nikos, Carlos, Martin, Hamish, thank you Stephen for your script
 that is a piece of art!!
 
 Sorry for the small talk...but THANK YOU!
 
 Cheers,
 
 Marcello.
 

And guess what?! The python script works perfectly in this new version!

So I guess we can finally get out of this topic, huh? :)

Or change it for RUNNING python scripts.

I am really happy!

Cheers,
Marcello.

-- 
View this message in context: 
http://osgeo-org.1803224.n2.nabble.com/Trying-python-scripts-tp5109105p5120222.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] Re: Trying python scripts.

2010-05-28 Thread Marcello Gorini


Nikos Alexandris wrote:
 
 Marcello Gorini wrote:
 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?
 
 I don't think so. I work with Kubuntu Lucid 64 bit :-)
 
 Or could GRASS be sending the outcome somewhere else?
 
 Negative. You are running the script from within a grass-session (as you
 wrote 
 in the first post). Let's try to take this step by step. What is the
 result of 
 each of the following commands:
 
 ls -l myscript.py
 g.gisenv
 g.region -p
 r.info map1
 r.info map2
 
 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.
 
 Bah... it was only me trying to not forget the basics with python scripts. 
 You will get better and more precise replies from other advanced users and 
 developers.
 
 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.
 
 You are warned, you might get yourself into trouble ;-p
 Cheers, Nikos
 ___
 grass-user mailing list
 grass-user@lists.osgeo.org
 http://lists.osgeo.org/mailman/listinfo/grass-user
 
 

OK, thank you, so let's go step by step:
ls -l myscript.py
result:
-rwxr-xr-x 1 marcello marcello 1227 2010-05-28 08:13 myscript.py

g.gisenv
result:
GISDBASE=/home/marcello/grassdata
LOCATION_NAME=Ocean_floor
MAPSET=level4
MONITOR=x0
GRASS_GUI=tcltk

g.region -p
result:
projection: 99 (Mercator)
zone:   0
datum:  wgs84
ellipsoid:  wgs84
north:  3947900
south:  3633400
west:   -7366700
east:   -7022600
nsres:  3700
ewres:  3700
rows:   85
cols:   93
cells:  7905

r.info map1
result:
++
 | Layer:map1   Date: Thu May 27 18:48:30 2010   
|
 | Mapset:   level4 Login of Creator: marcello   
|
 | Location: Ocean_floor 
|
 | DataBase: /home/marcello/grassdata
|
 | Title: ( topmod ) 
|
 | Timestamp: none   
|

||
 |   
|
 |   Type of Map:  raster   Number of Categories: 255
|
 |   Data Type:FCELL 
|
 |   Rows: 1177  
|
 |   Columns:  1388  
|
 |   Total Cells:  1633676   
|
 |Projection: Mercator   
|
 |N:6358450S:2003550   Res:  3700
|
 |E:   -3920150W:   -9055750   Res:  3700
|
 |   Range of data:min = 0.00  max = 1.00
|
 |   
|
 |   Data Description:   
|
 |generated by r.mapcalc 
|
 |   
|
 |   Comments:   
|
 |if(topmod  0, 0, -topmod) 
|
 |   
|

++

r.info map2
result:
++
 | Layer:map2   Date: Thu May 27 18:49:29 2010   
|
 | Mapset:   level4 Login of Creator: marcello   
|
 | Location: Ocean_floor 
|
 | DataBase: /home/marcello/grassdata
|
 | Title: ( topmod2 )
|
 | Timestamp: none   
|

||
 |   
|
 |   Type of Map:  raster   Number of Categories: 255
|
 |   Data Type:FCELL 
|
 |   Rows: 1177

[GRASS-user] Re: Trying python scripts.

2010-05-28 Thread Marcello Gorini


Nikos Alexandris wrote:
 
 Marcello Gorini:
 ...let's go step by step:
 ls -l myscript.py
 
 -rwxr-xr-x 1 marcello marcello 1227 2010-05-28 08:13 myscript.py
 
 looks fine
 
 g.gisenv
 
 GISDBASE=/home/marcello/grassdata
 LOCATION_NAME=Ocean_floor
 MAPSET=level4
 MONITOR=x0
 GRASS_GUI=tcltk
 
 just out of curiosity (and not that, I think, it makes any differene): are
 you 
 running (grass and) the script via the gui's command line or in text-mode?
 
 g.region -p
 
 projection: 99 (Mercator)
 zone:   0
 datum:  wgs84
 ellipsoid:  wgs84
 north:  3947900
 south:  3633400
 west:   -7366700
 east:   -7022600
 nsres:  3700
 ewres:  3700
 rows:   85
 cols:   93
 cells:  7905
 
 looks ok (below also)
  
 r.info map1
 ...
  |   Range of data:min = 0.00  max = 1.00
 ...
 
 r.info map2
 ...
  |   Range of data:min = 1000.00  max = 1000.00
 ...
 
 Result of r.info outmap:
 ERROR: Raster map outmap not found
 
 Hmmm... I don't know what could be wrong here. I guess running directly
 in-
 grass what the python script is expected to do ( r.mapcalc outmap = map1
 + 
 map2 ) is ok, isn't it?
 
 Could you also please copy-paste the exact (python) command you use within
 the 
 grass-session to get the desired outmap?
 
 Nikos
 ___
 grass-user mailing list
 grass-user@lists.osgeo.org
 http://lists.osgeo.org/mailman/listinfo/grass-user
 
 

Ok, so answering your questions:

just out of curiosity (and not that, I think, it makes any differene): are
you 
running (grass and) the script via the gui's command line or in text-mode?

No gui, everything using the terminal.

Hmmm... I don't know what could be wrong here. I guess running directly
in-
grass what the python script is expected to do ( r.mapcalc outmap = map1
+ 
map2 ) is ok, isn't it?

Yep!

Could you also please copy-paste the exact (python) command you use within
the 
grass-session to get the desired outmap?

Sure: 
python myscript.py raster1=map1 raster2=map2 output=outmap

Well, I think that eventually we will find out that the problem lies between
my chair and my computer, and you are going to be mad with me :)

But for now, let's keep going.

Cheers,
Marcello.



-- 
View this message in context: 
http://osgeo-org.1803224.n2.nabble.com/Trying-python-scripts-tp5109105p5113299.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] Re: Trying python scripts.

2010-05-28 Thread Marcello Gorini


Carlos Grohmann-2 wrote:
 
 Hello Marcello.
 
 It's good to _finally_ see you here :)
 
 I tried your script and it worked for me, but I had to change the last
 line from
 
 sys.exit(main())
 
 to:
 
 main()
 
 
 could you try that?
 
 best
 
 Carlos
 
 
 
 On Fri, May 28, 2010 at 08:23, Marcello Gorini gor...@gmail.com wrote:


 Nikos Alexandris wrote:

 Marcello Gorini wrote:
 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?

 I don't think so. I work with Kubuntu Lucid 64 bit :-)

 Or could GRASS be sending the outcome somewhere else?

 Negative. You are running the script from within a grass-session (as you
 wrote
 in the first post). Let's try to take this step by step. What is the
 result of
 each of the following commands:

 ls -l myscript.py
 g.gisenv
 g.region -p
 r.info map1
 r.info map2

 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.

 Bah... it was only me trying to not forget the basics with python
 scripts.
 You will get better and more precise replies from other advanced users
 and
 developers.

 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.

 You are warned, you might get yourself into trouble ;-p
 Cheers, Nikos
 ___
 grass-user mailing list
 grass-user@lists.osgeo.org
 http://lists.osgeo.org/mailman/listinfo/grass-user



 OK, thank you, so let's go step by step:
 ls -l myscript.py
 result:
 -rwxr-xr-x 1 marcello marcello 1227 2010-05-28 08:13 myscript.py

 g.gisenv
 result:
 GISDBASE=/home/marcello/grassdata
 LOCATION_NAME=Ocean_floor
 MAPSET=level4
 MONITOR=x0
 GRASS_GUI=tcltk

 g.region -p
 result:
 projection: 99 (Mercator)
 zone:       0
 datum:      wgs84
 ellipsoid:  wgs84
 north:      3947900
 south:      3633400
 west:       -7366700
 east:       -7022600
 nsres:      3700
 ewres:      3700
 rows:       85
 cols:       93
 cells:      7905

 r.info map1
 result:
 ++
  | Layer:    map1                           Date: Thu May 27 18:48:30
 2010
 |
  | Mapset:   level4                         Login of Creator: marcello
 |
  | Location: Ocean_floor
 |
  | DataBase: /home/marcello/grassdata
 |
  | Title:     ( topmod )
 |
  | Timestamp: none
 |

 ||
  |
 |
  |   Type of Map:  raster               Number of Categories: 255
 |
  |   Data Type:    FCELL
 |
  |   Rows:         1177
 |
  |   Columns:      1388
 |
  |   Total Cells:  1633676
 |
  |        Projection: Mercator
 |
  |            N:    6358450    S:    2003550   Res:  3700
 |
  |            E:   -3920150    W:   -9055750   Res:  3700
 |
  |   Range of data:    min = 0.00  max = 1.00
 |
  |
 |
  |   Data Description:
 |
  |    generated by r.mapcalc
 |
  |
 |
  |   Comments:
 |
  |    if(topmod  0, 0, -topmod)
 |
  |
 |

 ++

 r.info map2
 result:
 ++
  | Layer:    map2                           Date: Thu May 27 18:49:29
 2010
 |
  | Mapset:   level4                         Login of Creator: marcello
 |
  | Location: Ocean_floor
 |
  | DataBase: /home/marcello/grassdata
 |
  | Title:     ( topmod2 )
 |
  | Timestamp: none
 |

 ||
  |
 |
  |   Type of Map:  raster               Number of Categories: 255
 |
  |   Data Type:    FCELL
 |
  |   Rows:         1177
 |
  |   Columns:      1388
 |
  |   Total Cells:  1633676
 |
  |        Projection: Mercator
 |
  |            N:    6358450    S:    2003550   Res:  3700
 |
  |            E:   -3920150    W:   -9055750   Res:  3700
 |
  |   Range of data:    min = 1000.00  max = 1000.00
 |
  |
 |
  |   Data Description:
 |
  |    generated by r.mapcalc
 |
  |
 |
  |   Comments:
 |
  |    if(topmod  -2, 1000, topmod)
 |
  |
 |

 ++

 Now just to emphasize :)
 Result of r.info outmap:
 ERROR: Raster map outmap not found

 Can you make anything out of it?

 Best regards,
 Marcello.
 --
 View this message in context:
 http://osgeo-org.1803224.n2.nabble.com/Trying-python-scripts-tp5109105p5112658.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

 
 
 
 -- 
 Prof. Carlos Henrique Grohmann - Geologist

[GRASS-user] Re: Trying python scripts.

2010-05-28 Thread Marcello Gorini

Nikos:
Just stick on Marcello. Get yourself the GRASS-book, look at the
GRASS-wiki,
invest some time generally and specifically, and you will be addicted ;-)
It
is worthwhile.

I will, don't worry. And I already bought the GRASS book. That is what
really got me going (after Carlos got me interested in the first place). I
must say that it is the best technical book I have ever bought. Almost
everything I needed to achieve my firsts goals with GRASS, I found in the
book only by turning the page. 

It seems strange though. We might need the guru's to solve this... (?). 

This one is probably a subliminal message somewhere in the book. I need to
look closer :)

Cheers,
Marcello.
-- 
View this message in context: 
http://osgeo-org.1803224.n2.nabble.com/Trying-python-scripts-tp5109105p5113440.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] Trying python scripts.

2010-05-27 Thread Marcello Gorini

Dear all,

This is kind of my first e-mail ever to ANY mailing list, so please forgive
me if I don't express myself in the best way. I will improve eventually.
I am a total beginner in python and GRASS (and any other programming
language), so I am trying to run the first examples found in
http://grass.osgeo.org/wiki/GRASS_and_Python.
I managed to run the shaded_relief one OK, but the one with respect to
mapcalc, I couldn't.
I copied a script found in
http://www.mail-archive.com/grass-...@lists.osgeo.org/msg14669.html
(transcribed below) and tried to run it:

#!/usr/bin/env python

# g.parser demo script for python programing

#%module
#%  description: g.parser test script (python) TUN
#%end
#%flag
#%  key: f
#%  description: A flag
#%end
#%flag
#%  key: n
#%  description: Another flag
#%end
#%option
#%  key: raster1
#%  type: string
#%  gisprompt: old,cell,raster
#%  description: Raster input map
#%  required : yes
#%end
#%option
#%  key: raster2
#%  type: string
#%  gisprompt: old,cell,raster
#%  description: Raster2 input map
#%  required : yes
#%end
#%option
#%  key: output
#%  type: string
#%  gisprompt: new,cell,raster
#%  description: Output
#%  required : yes
#%end

import os
import sys

import grass.script as grass

def main():
output = options['output']
raster1 = options['raster1']
raster2 = options['raster2']
grass.mapcalc($out = $rast1 + $rast2, out = output, rast1 = raster1, 
rast2 = raster2)
if flags['f']:
print Flag -f set
else:
print Flag -f not set

if flags['n']:
print Flag -n foi definida mas nao devia
else:
print Flag -n not set- GOOD  
print options
print flags
return 0

if __name__ == __main__:
options, flags = grass.parser()
sys.exit(main())


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.
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. 
Can anyone help me?

Best regards,
Marcello Gorini.
-- 
View this message in context: 
http://osgeo-org.1803224.n2.nabble.com/Trying-python-scripts-tp5109105p5109105.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] Re: Trying python scripts.

2010-05-27 Thread Marcello Gorini

Hello Nikos,

Marcello Gorini.

Nikos Alexandris wrote:
 
 Hi Marcello,
 
 Marcello Gorini:
 This is kind of my first e-mail ever to ANY mailing list, so please
 forgive
 me if I don't express myself in the best way. I will improve eventually.
 I am a total beginner in python and GRASS (and any other programming
 language), so I am trying to run the first examples found in
 http://grass.osgeo.org/wiki/GRASS_and_Python.
 I managed to run the shaded_relief one OK, but the one with respect to
 mapcalc, I couldn't.
 I copied a script found in
 http://www.mail-archive.com/grass-...@lists.osgeo.org/msg14669.html
 (transcribed below) and tried to run it:
 
 #!/usr/bin/env python
 
 # g.parser demo script for python programing
 
 #%module
 #%  description: g.parser test script (python) TUN
 #%end
 #%flag
 #%  key: f
 #%  description: A flag
 #%end
 #%flag
 #%  key: n
 #%  description: Another flag
 #%end
 #%option
 #%  key: raster1
 #%  type: string
 #%  gisprompt: old,cell,raster
 #%  description: Raster input map
 #%  required : yes
 #%end
 #%option
 #%  key: raster2
 #%  type: string
 #%  gisprompt: old,cell,raster
 #%  description: Raster2 input map
 #%  required : yes
 #%end
 #%option
 #%  key: output
 #%  type: string
 #%  gisprompt: new,cell,raster
 #%  description: Output
 #%  required : yes
 #%end
 
 import os
 import sys
 
 import grass.script as grass
 
 def main():
 output = options['output']
 raster1 = options['raster1']
 raster2 = options['raster2']
 grass.mapcalc($out = $rast1 + $rast2, out = output, rast1 =
 raster1,
 rast2 = raster2)
 if flags['f']:
 print Flag -f set
 else:
 print Flag -f not set
 
 if flags['n']:
 print Flag -n foi definida mas nao devia
 else:
 print Flag -n not set- GOOD
 print options
 print flags
 return 0
 
 if __name__ == __main__:
 options, flags = grass.parser()
 sys.exit(main())
 
 
 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.
 
 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?
 
 Regards, Nikos
 
 
 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?
 
 Best regards,
 
 Marcello.
 
 P.S.: By the way, is this the right way to quote answers?
 
 ___
 grass-user mailing list
 grass-user@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-tp5109105p5109431.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] Re: Trying python scripts.

2010-05-27 Thread Marcello Gorini

Oops, I guess I quoted the text in the wrong way. Sorry for that.


Marcello Gorini wrote:
 
 Hello Nikos,
 
 Marcello Gorini.
 
 Nikos Alexandris wrote:
 
 Hi Marcello,
 
 Marcello Gorini:
 This is kind of my first e-mail ever to ANY mailing list, so please
 forgive
 me if I don't express myself in the best way. I will improve eventually.
 I am a total beginner in python and GRASS (and any other programming
 language), so I am trying to run the first examples found in
 http://grass.osgeo.org/wiki/GRASS_and_Python.
 I managed to run the shaded_relief one OK, but the one with respect to
 mapcalc, I couldn't.
 I copied a script found in
 http://www.mail-archive.com/grass-...@lists.osgeo.org/msg14669.html
 (transcribed below) and tried to run it:
 
 #!/usr/bin/env python
 
 # g.parser demo script for python programing
 
 #%module
 #%  description: g.parser test script (python) TUN
 #%end
 #%flag
 #%  key: f
 #%  description: A flag
 #%end
 #%flag
 #%  key: n
 #%  description: Another flag
 #%end
 #%option
 #%  key: raster1
 #%  type: string
 #%  gisprompt: old,cell,raster
 #%  description: Raster input map
 #%  required : yes
 #%end
 #%option
 #%  key: raster2
 #%  type: string
 #%  gisprompt: old,cell,raster
 #%  description: Raster2 input map
 #%  required : yes
 #%end
 #%option
 #%  key: output
 #%  type: string
 #%  gisprompt: new,cell,raster
 #%  description: Output
 #%  required : yes
 #%end
 
 import os
 import sys
 
 import grass.script as grass
 
 def main():
 output = options['output']
 raster1 = options['raster1']
 raster2 = options['raster2']
 grass.mapcalc($out = $rast1 + $rast2, out = output, rast1 =
 raster1,
 rast2 = raster2)
 if flags['f']:
 print Flag -f set
 else:
 print Flag -f not set
 
 if flags['n']:
 print Flag -n foi definida mas nao devia
 else:
 print Flag -n not set- GOOD
 print options
 print flags
 return 0
 
 if __name__ == __main__:
 options, flags = grass.parser()
 sys.exit(main())
 
 
 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.
 
 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?
 
 Regards, Nikos
 
 
 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?
 
 Best regards,
 
 Marcello.
 
 P.S.: By the way, is this the right way to quote answers?
 
 ___
 grass-user mailing list
 grass-user@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-tp5109105p5109444.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] Re: Trying python scripts.

2010-05-27 Thread Marcello Gorini

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@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.
___
grass-user mailing list
grass-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-user