[GRASS-user] Question regarding grass.mapcalc
Greetings I'm doing a Python script to calibrate a raster image. Since I need to do 3 different calculations I'm using a tempfile (tempL) This is the code: tempL = grass.read_command(g.tempfile, pid = 1) grass.mapcalc($L=$lmin+ (($lmax-$lmin)/($QCALmax-$QCALmin))* ($raster_file-$QCALmin), L=tempL, lmin=lmin, lmax=lmax, QCALmax=QCALmax, QCALmin=QCALmin, raster_file=raster_file) Where tempL is a temporary, (lmin,lmax) are floats, QCALmax and QCALmin are int and raster_file is a raster map used as input. And I get this: syntax error, unexpected '/', expecting NAME or STRING Parse error ERROR: An error occurred while running r.mapcalc What is happening? I believe it has something to do with tempL. Maybe I'm not doing this right. Can anyone help me on this? Thanks Kim ___ grass-user mailing list grass-user@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/grass-user
Re: [GRASS-user] Question regarding grass.mapcalc
Kim Besson wrote: I'm doing a Python script to calibrate a raster image. Since I need to do 3 different calculations I'm using a tempfile (tempL) This is the code: tempL = grass.read_command(g.tempfile, pid = 1) grass.mapcalc($L=$lmin+ (($lmax-$lmin)/($QCALmax-$QCALmin))* ($raster_file-$QCALmin), L=tempL, lmin=lmin, lmax=lmax, QCALmax=QCALmax, QCALmin=QCALmin, raster_file=raster_file) Where tempL is a temporary, (lmin,lmax) are floats, QCALmax and QCALmin are int and raster_file is a raster map used as input. And I get this: syntax error, unexpected '/', expecting NAME or STRING Parse error ERROR: An error occurred while running r.mapcalc What is happening? I believe it has something to do with tempL. Maybe I'm not doing this right. Can anyone help me on this? g.tempfile returns the full pathname to a temporary file, not a map name. There isn't a module to generate temporary map names. A common approach is to use the name of the script followed by .tmp. -- Glynn Clements gl...@gclements.plus.com ___ grass-user mailing list grass-user@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/grass-user
Re: [GRASS-user] converting lines to polygons
On 09/24/2010 12:45 AM, Bryan Keith wrote: Orange boundaries are duplicates - overlapping lines - that GRASS topology doesn't allow. You should be able to get rid of these with: v.clean in=... out=... tool=break,bpol,rmdupl But I've never had good luck with this. The alternative that might work better for you: Re-import the layer from the original shapefiles (or where ever they came from) but use the type=line option to v.in.ogr. (No centroids will be created) Now do v.clean on this new GRASS vector, using tool=snap,break,rmdupl. Next use v.type ... type=line,boundary to convert the (cleaned) lines to boundaries, and then v.centroids ... opt=add to create area centroids inside each closed boundary. Micha, Yes, thank you, that worked! Here's what I did: Cheers. Although I think I misled you a bit. I was mistaken about the orange line color in the digitizer. It simply indicates a boundary that is wholly shared by two adjacent areas. *Not* a topological error. In any case, importing polygon shapefiles first as lines (not boundaries), doing the topology cleanup, and then convert to boundaries and add centroids seems to be the smoother way to go. -- Micha v.in.ogr -o dsn=C:\path\to\shapefile\test_ln.shp output=testm_ln type=line v.clean input=testm_ln output=testmclean_ln tool=snap,break,rmdupl thresh=0.2,0,0 v.type input=testmclean_ln output=testmclean_bnd type=line,boundary v.centroids input=testmclean_bnd output=testmclean_py option=add Thanks for all the help. Bryan -- Micha Silver Arava Development Co. +972-52-3665918 http://surfaces.co.il ___ grass-user mailing list grass-user@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/grass-user
Re: [GRASS-user] Connecting GRASS to a MySQL database?
Richard, Thanks! That was exactly the information I needed. Now to figure out how to merge layers... Thom Sent via DROID on Verizon Wireless -Original message- From: Richard Chirgwin rchirg...@ozemail.com.au To: grass-user@lists.osgeo.org Sent: 2010 Sep, Thu, 23 07:20:51 GMT+00:00 Subject: Re: [GRASS-user] Connecting GRASS to a MySQL database? On 23/09/10 5:13 PM, grass-user-requ...@lists.osgeo.org wrote: Message: 3 Date: Wed, 22 Sep 2010 16:51:08 -0400 (EDT) From: PixelPusherpixelpus...@cox.net Subject: [GRASS-user] Connecting GRASS to a MySQL database? To:grass-user@lists.osgeo.org Message-ID:cbcc5e.5f72.12b3b36ce33.webto...@cox.net Content-Type: text/plain; charset=UTF-8; format=flowed; delsp=no Sorry for the n00bish question, but I'm confused by the GRASS on-line docs. I have a MySQL database running on my local computer. Let's say that the MySQL user name is TRD and he has access to a database called TRD where I want to store my StateBoundaries table. I can start the GRASS (6.4.0) Python interface and select Database-Manage Databases-Connect from the pulldown menu. I am then faced with the choice of driver, where I select mysql. But, then it needs the Database name. This is where I get lost. The string in the text field says, $GISDBASE/$LOCATION_NAME/$MAPSET/TRD. I'm not sure where GRASS is getting the values that substitute for those things that look like script variables. I guess the $LOCATION_NAME and $MAPSET come from the location and mapset that I selected when GRASS started. But, where is $GISDBASE set? I also step through the log in process by setting the appropriate user name and password. I know that I can use this combination to access the MySQL database through its command line interface. The next thing I do is try to test the connection. However, this results in lots of errors like, Cannot connect to MySQL, Access denied for user and ERROR: Unable to open database $GISDBASE/$LOCATION_NAME/$MAPSET/TRD. It looks like GRASS is not using the right username and password and not doing the variable substitution that I was expecting. Can anoyone give me some hints on how to get this thing started? Thanks! Thom Thom, Having taught a few people how to use Grass-GIS, I can say that database parameters confuse a great many of them! The parameters you see are for the default dbf driver (Grass-GIS uses this driver as the default for any new mapset). For MySQL, you provide the database location, and also login. So where you see the $GISDBASE/$LOCATION_NAME/$MAPSET/dbf/ string, you want: database=host=ip address,dbname=TRD But you'll also have to login. Eg (command line): db.login user=TRD password=somepassword (the inverted commas are needed at the command line but not using the GUI) Notes: 1. From now on, every map you make in this particular mapset will use the MySQL database as its default connection. Don't try to mix different database drivers within a mapset - you'll get a headache! 2. Database parameters are stored only within the mapset you're using. If you want to connect a different mapset to MySQL, you have to set its connection. Richard Chirgwin ___ 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] inconsistency between i.atcorr manual and wiki
On Fri, Jul 30, 2010 at 7:20 PM, Daniel Victoria daniel.victo...@gmail.com wrote: Hi all, Reading on the Atmospheric Correction Wiki [1] and the i.atcorr man page [2] I noticed some inconsistencies. In the manual, the exemple uses the lsat7_2002_40 image from the NC dataset directlly but, on the wiki tutorial, the image is first converted to TOA radiance and then intput into i.atcorr. Seeing that i.atcorr scales the input image to 0 - 255 (iscl parameter), is it necessary to convert the images to TOA radiance? Should I follow the i.atcorr manual exemple or the wiki exemple? Yes. I have made significant updates in the manual page today (all GRASS versions). Also the Wiki page received a fix for the overpass time. Markus Thanks Daniel [1] - http://grass.osgeo.org/wiki/Atmospheric_correction [2] - http://grass.itc.it/gdp/html_grass64/i.atcorr.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
[GRASS-user] Re: QGIS GRASS plugin shadedrelief issue
Date: Thu, 23 Sep 2010 11:06:21 +0300 From: Maris Nartiss maris@gmail.com Subject: Re: [GRASS-user] Re: QGIS GRASS plugin shadedrelief issue To: nunosousa84 nuno_sousa_1...@hotmail.com Sorry for You. You do made backup of important data before messing around with QGIS, right? You can try to launch GRASS and rebuild vector topology with v.build. If it doesn't help - You'r SOL. And don't forget to infrorm QGIS developers how well their GRASS support works. Good luck, Maris. Hi all. Sorry I was unclear: it is a known bug for QGIS to crash in case of an unclean vector. There is no indication that QGIS is more inclined to spoil your vector than any other GRASS GUI. If you stop GRASS while it is writing a vector, problems are likely to occur, with any UI (even from the shell). You can clean your vector also from within QGIS, by simply running v.build.all. And yes, backupping data is always a good idea, regardless of what sw you are using. BTW: Maris, why are you trolling around? We do our best, like everybody, to improve the tools we are using, for the benefit of everybody, and it's no fun to read your polemic notes. All the best. -- Paolo Cavallini: http://www.faunalia.it/pc ___ 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
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] Floating Grid to raster GRASS
I have a bunch of files that are floating grid data. They have the file extension .flt and there is a header file .hdr. r.in.gdal reads in the .flt file fine, but errors out with the hdr. The gdalinfo spits out a res=0.3, but the attached metadata says that the resolution is 1m. Is there a way to find out what the reality is without talking with the folks that provided the data? Thanks for all of the help. -- Stephen Sefick | Auburn University | | Department of 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-user
Re: [GRASS-user] Question regarding grass.mapcalc
Kim Besson wrote: So your suggestion would be rass.mapcalc($L=$lmin+ (($lmax-$lmin)/($QCALmax-$QCALmin)) ($raster_file-$QCALmin), L=tempL, lmin=lmin, lmax=lmax, QCALmax=QCALmax, QCALmin=QCALmin, raster_file=raster_file) and at the end delete L file? My suggestion would be to replace: tempL = grass.read_command(g.tempfile, pid = 1) with: tempL = myscript.tmp Any temporary maps should be deleted upon termination. Use atexit.register() to register a function which deletes any temporary maps (if they exist). This will ensure that the maps get deleted regardless of whether the script terminates normally or due to an exception. Look at the scripts in 7.0 for examples. -- Glynn Clements gl...@gclements.plus.com ___ grass-user mailing list grass-user@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/grass-user
Re: [GRASS-user] r.in.gdal 0.3m res into 1m res mapset question
stephen sefick wrote: I have a bunch of floating point grids that I need to bring into GRASS. They say that they are 0.3m res where the documentation says they are 1m- I will ferrett this out of the data providers. My question is I will bring these layers into a 1m resolution mapset. Will they be automatically resampled to the regions resolution or do they remain intact waiting for me to do the resampling? Thanks for all of your help. kindest regards, If I am not wrong, importing does not change the original resolution of a raster no matter what the resolution of the region is. Nikos ___ grass-user mailing list grass-user@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/grass-user
Re: [GRASS-user] Re: A Script that only selects raster inside a polygon
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 (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) All the best, Nikos Cheers, Nikos ___ grass-user mailing list grass-user@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/grass-user
Re: [GRASS-user] Re: A Script that only selects raster inside a polygon
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). ...forgot (that the) default (is) value=1 which will work just fine. :-P Nikos r.mask input=your_vector_rasterized r.mapcalc clipped_raster=original_raster r.mask -r ___ grass-user mailing list grass-user@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/grass-user
Re: [GRASS-user] Connecting GRASS to a MySQL database?
It depends on what you mean by merge. v.patch is the official tool to merge two vectors, but you could use v.overlay (option=or). Richard On 24/09/10 10:56 PM, Thom DeCarlo wrote: Richard, Thanks! That was exactly the information I needed. Now to figure out how to merge layers... Thom /Sent via DROID on Verizon Wireless/ -Original message- *From: *Richard Chirgwin rchirg...@ozemail.com.au* To: *grass-u...@lists.osgeo.org* Sent: *2010 Sep, Thu, 23 07:20:51 GMT+00:00* Subject: *Re: [GRASS-user] Connecting GRASS to a MySQL database? On 23/09/10 5:13 PM, grass-user-requ...@lists.osgeo.org wrote: Message: 3 Date: Wed, 22 Sep 2010 16:51:08 -0400 (EDT) From: PixelPusher Subject: [GRASS-user] Connecting GRASS to a MySQL database? To:grass-user@lists.osgeo.org Message-ID: Content-Type: text/plain; charset=UTF-8; format=flowed; delsp=no Sorry for the n00bish question, but I'm confused by the GRASS on-line docs. I have a MySQL database running on my local computer. Let's say that the MySQL user name is TRD and he has access to a database called TRD where I want to store my StateBoundaries table. I can start the GRASS (6.4.0) Python interface and select Database-Manage Databases-Connect from the pulldown menu. I am then faced with the choice of driver, where I select mysql. But, then it needs the Database name. This is where I get lost. The string in the text field says, $GISDBASE/$LOCATION_NAME/$MAPSET/TRD. I'm not sure where GRASS is getting the values that substitute for those things that look like script variables. I guess the $LOCATION_NAME and $MAPSET come from the location and mapset that I selected when GRASS started. But, where is $GISDBASE set? I also step through the log in process by setting the appropriate user name and password. I know that I can use this combination to access the MySQL database through its command line interface. The next thing I do is try to test the connection. However, this results in lots of errors like, Cannot connect to MySQL, Access denied for user and ERROR: Unable to open database $GISDBASE/$LOCATION_NAME/$MAPSET/TRD. It looks like GRASS is not using the right username and password and not doing the variable substitution that I was expecting. Can anoyone give me some hints on how to get this thing started? Thanks! Thom Thom, Having taught a few people how to use Grass-GIS, I can say that database parameters confuse a great many of them! The parameters you see are for the default dbf driver (Grass-GIS uses this driver as the default for any new mapset). For MySQL, you provide the database location, and also login. So where you see the $GISDBASE/$LOCATION_NAME/$MAPSET/dbf/ string, you want: database=host=,dbname=TRD But you'll also have to login. Eg (command line): db.login user=TRD password=somepassword (the inverted commas are needed at the command line but not using the GUI) Notes: 1. From now on, every map you make in this particular mapset will use the MySQL database as its default connection. Don't try to mix different database drivers within a mapset - you'll get a headache! 2. Database parameters are stored only within the mapset you're using. If you want to connect a different mapset to MySQL, you have to set its connection. Richard Chirgwin ___ 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: A Script that only selects raster inside a polygon
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] First time trying to install add on g.extension (r.stream.order)
Hi, I am fairly new to GRASS and have what many of you would consider a trivial or newb problem. Regardless any help would be appreciated. Using GRASS 6.4.0 on windows vista I type g.extension extension=r.stream.order in the command line at the bottom of the layer manager window. The following error is returned: Error: svn client required. Please install Subversion first. I have looked through many posts and help files to no avail, if anyone can tell me what additional steps/programs/plugins are required to install addons I would really appreciate the help. Thanks ___ grass-user mailing list grass-user@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/grass-user
Re: [GRASS-user] First time trying to install add on g.extension (r.stream.order)
David wrote: Using GRASS 6.4.0 on windows vista I type g.extension extension=r.stream.order in the command line at the bottom of the layer manager window. The following error is returned: Error: svn client required. Please install Subversion first. I have looked through many posts and help files to no avail, if anyone can tell me what additional steps/programs/plugins are required to install addons I would really appreciate the help. see http://subversion.apache.org note g.extension is rather new and untested compared the rest of the software, especially on Windows. Besides svn for building C modules, you will need a C compiler which doesn't ship with the GRASS installer. Hamish ___ grass-user mailing list grass-user@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/grass-user
Re: [GRASS-user] Re: QGIS GRASS plugin shadedrelief issue
Micha wrote: We're used to perceiving shadows below and highlights above what is being lit. The same holds for a hill-shaded terrain. When we see shadows on a slope, it seems to be south facing, and highlights appear north facing. So if you place the sun at 130° (SE) then you are lighting the south facing slope, and making it appear north facing, thus causing the valleys to appear to be hills, and the peaks appear as valleys. We have a set of ortho-photos that were shot early in the morning (sun in the east) and a colleague always turns the maps upside down (N pointing down) so that the hills and valleys look right. The most natural looking hillshading is with azimuth between 270 - 315° (W to NW). note that in most places GRASS uses the cartesian convention of theta as degrees counter-clockwise from the positive x-axis, not navigational convention of degrees being measured clockwise from north. (convert between the two with '90-angle') By the way GRASS as any map composer like QGIS to be able to finish the work (put scale bar, north, legend, title,...)? Yes, QGIS is a good choice. GRASS does have a full set of map composer tools, but some graphic elements require a bit more fiddling to get them right. Mind you, the results can be quite rewarding. (see the help pages for the d.* modules and ps.map, and the cartography section of the grass web site) Hamish ___ grass-user mailing list grass-user@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/grass-user
Re: [GRASS-user] Unable to load gdal library error
Daniel wrote: Tried recompiling grass but that did not change anything. So I ran ldd `which r.what` and it did not show any links to a gdal library... This is what I got GRASS 6.5.svn (br_wgs84):~ ldd `which r.what` linux-gate.so.1 = (0x00f71000) libgrass_gis.so = /usr/local/grass-6.5.svn/lib/libgrass_gis.so (0x00a31000) libgrass_datetime.so = /usr/local/grass-6.5.svn/lib/libgrass_datetime.so (0x00c02000) libz.so.1 = /lib/libz.so.1 (0x002ca000) libm.so.6 = /lib/tls/i686/cmov/libm.so.6 (0x00681000) libc.so.6 = /lib/tls/i686/cmov/libc.so.6 (0x00d3d000) libdl.so.2 = /lib/tls/i686/cmov/libdl.so.2 (0x00ace000) /lib/ld-linux.so.2 (0x005a5000) GRASS 6.5.svn (br_wgs84):~ Does this means that I messed up during compilation? no, just that a library calls gdal not the module. try: ldd /usr/local/grass-6.5.svn/lib/libgrass_gis.so Hamish ___ grass-user mailing list grass-user@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/grass-user