Re: [GRASS-user] Python placeholder (%d) in stdin statement of db.execute
On Thu, Apr 11, 2013 at 8:58 AM, Hamish hamis...@yahoo.com wrote: Johannes wrote: I just tested it again and realized this problem is not related to the placeholder in the python code, but probably an other issue of my pythoncode line nothing is update when use: grass.write_command(db.execute, stdin = UPDATE my points SET prob=100) but using UPDATE my points SET prob=100 in the module GUI works as mentioned already before. Has anyone experience in using db.execute in python with standard input in GRASS7? in GRASS7 you need to add input=- as an option to trigger reading input stdin. (or else stalled module gui headaches..) perhaps this needs to be changed to YES? input-required = NO; No, because db.execute sql=SQL statement works just fine, input is not required. Markus M ___ grass-user mailing list grass-user@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/grass-user
[GRASS-user] confused by the GRASS Programmer's topology examples...
Hi all, I'm reading the GRASS7 programmer's manual, to update my experience with GRASS (I'm going to use it for some network analysis, and probably I will need to extend it) Looking at the topology examples [1] I fill a bit confused by the types of nodes and lines, which vary between the different kind of topological structures. - Point example: a point doesn't have nodes but have a line (P_LINE), with type GV_POINT. It's enough for me to get confused :) A P_LINE structure has a void * topo opaque element [2], which will point to the relative topology structure depending on the type. In case of a G_POINT type, what is the topology structure attached to the topo pointer? - Line example: two nodes with type GV_LINE. A P_NODE doesn't have a type [3], so how can it be... a GV_LINE? :( I'm missing something. Could you help to understand it? Thanks a lot, giovanni [1] http://grass.osgeo.org/programming7/vlibTopology.html#vlibTopoExamples [2] http://grass.osgeo.org/programming7/structP__line.html [3] http://grass.osgeo.org/programming7/structP__node.html -- Giovanni Allegri http://about.me/giovanniallegri blog: http://blog.spaziogis.it GEO+ geomatica in Italia http://bit.ly/GEOplus ___ grass-user mailing list grass-user@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/grass-user
Re: [GRASS-user] Python placeholder (%d) in stdin statement of db.execute
Hi all, Thank you Hamish, including the option input=- in the python line (for GRASS7) solved the problem. Now I get an update/entry in my attribute table. This is a different behavior from grass65 where this additional option is not needed. /johannes On Thu, Apr 11, 2013 at 11:15 AM, Markus Metz markus.metz.gisw...@gmail.com wrote: On Thu, Apr 11, 2013 at 8:58 AM, Hamish hamis...@yahoo.com wrote: Johannes wrote: I just tested it again and realized this problem is not related to the placeholder in the python code, but probably an other issue of my pythoncode line nothing is update when use: grass.write_command(db.execute, stdin = UPDATE my points SET prob=100) but using UPDATE my points SET prob=100 in the module GUI works as mentioned already before. Has anyone experience in using db.execute in python with standard input in GRASS7? in GRASS7 you need to add input=- as an option to trigger reading input stdin. (or else stalled module gui headaches..) perhaps this needs to be changed to YES? input-required = NO; No, because db.execute sql=SQL statement works just fine, input is not required. Markus M ___ grass-user mailing list grass-user@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/grass-user
[GRASS-user] GRASS-Python Script: Check if output already exists, overwrite
Hi, I would like to check if the file defined as output in a python script already exists and fire an error when it exists and the overwrite flag is not set. Furhtermore I'd like to check this already in the beginning before all calculations in the script are executed. I thought about something like: output = options['output'] if (grass.find_file(name = output, element = 'cell')['file'] and grass.read_command(g.gisenv, get = GRASS_OVERWRITE)!=1): grass.fatal(_(Output file exists already, either change output name or set overwrite-flag)) but what is the correct way to get the information if the overwrite flag is set or not for that script? The GRASS-OVERWRITE variable is not set although the script is launched with --overwrite. So how to get this info? /Johannes ___ grass-user mailing list grass-user@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/grass-user
Re: [GRASS-user] confused by the GRASS Programmer's topology examples...
Going on grasping the data structures... - Point example: a point doesn't have nodes but have a line (P_LINE), with type GV_POINT. It's enough for me to get confused :) A P_LINE structure has a void * topo opaque element [2], which will point to the relative topology structure depending on the type. In case of a G_POINT type, what is the topology structure attached to the topo pointer? Ok, as I supposed the topo pointer is NULL for points. - Line example: two nodes with type GV_LINE. A P_NODE doesn't have a type [3], so how can it be... a GV_LINE? :( Sorry, this is clear now. The type is referring to the lines attached to the node. I'm missing something. Could you help to understand it? Thanks a lot, giovanni [1] http://grass.osgeo.org/programming7/vlibTopology.html#vlibTopoExamples [2] http://grass.osgeo.org/programming7/structP__line.html [3] http://grass.osgeo.org/programming7/structP__node.html -- Giovanni Allegri http://about.me/giovanniallegri blog: http://blog.spaziogis.it GEO+ geomatica in Italia http://bit.ly/GEOplus -- Giovanni Allegri http://about.me/giovanniallegri blog: http://blog.spaziogis.it GEO+ geomatica in Italia http://bit.ly/GEOplus ___ grass-user mailing list grass-user@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/grass-user
Re: [GRASS-user] Python placeholder (%d) in stdin statement of db.execute
Johannes Radinger wrote: Thank you Hamish, including the option input=- in the python line (for GRASS7) solved the problem. Why read the command from stdin rather than using sql=...? E.g.: grass.write_command(db.execute, sql = UPDATE my points SET prob=100) -- 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] GRASS-Python Script: Check if output already exists, overwrite
Johannes Radinger wrote: I would like to check if the file defined as output in a python script already exists and fire an error when it exists and the overwrite flag is not set. Furhtermore I'd like to check this already in the beginning before all calculations in the script are executed. g.parser should do this automatically. If an option has new in the gisprompt field, G_parser() checks that either the file/map/etc doesn't exist or overwrite is enabled. The only time you should need to do this manually is if an output name isn't simply an option value (e.g. r.mapcalc's output maps are specified in the expression, r.rgb takes an output template to which it appends a .r/.g/.b suffix, etc). I thought about something like: output = options['output'] if (grass.find_file(name = output, element = 'cell')['file'] and grass.read_command(g.gisenv, get = GRASS_OVERWRITE)!=1): grass.fatal(_(Output file exists already, either change output name or set overwrite-flag)) but what is the correct way to get the information if the overwrite flag is set or not for that script? The GRASS-OVERWRITE variable is not set although the script is launched with --overwrite. So how to get this info? The grass.script.overwrite() function returns True if overwrite is enabled. Also, os.environ['GRASS_OVERWRITE'] will have been set to '1' by grass.script.parser() so that the overwrite status propagates down to any commands executed by the script. -- Glynn Clements gl...@gclements.plus.com ___ grass-user mailing list grass-user@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/grass-user
[GRASS-user] How to start GRASS 6.4 command line on linux
Dear all, I recently switched to linux (Mint KDE) and I simply don't find how to start the command line terminal of grass. Could someone help me? thanks Lucien ___ grass-user mailing list grass-user@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/grass-user
Re: [GRASS-user] How to start GRASS 6.4 command line on linux
Hey Lucien, If you start a new terminal and start grass (by typing grass), you will be able to execute grass commands from the terminal. Success! Miguel 2013/4/11 BLANDENIER Lucien lucien.blanden...@unine.ch Dear all, I recently switched to linux (Mint KDE) and I simply don't find how to start the command line terminal of grass. Could someone help me? thanks Lucien ___ 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] red square around node topology information?
I apologize for the naive question but I haven't been able to find an explanation for the meaning of the square boxes that appear around my lines layer's nodes, when I display topological informations on the map. I thought they could indicate errors, but my layer appear to be topologically ok. I'm sorry for asking so much difficult questions! :-) giovanni Sent from Nexus ___ grass-user mailing list grass-user@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/grass-user
Re: [GRASS-user] red square around node topology information?
On Thu, Apr 11, 2013 at 3:21 PM, G. Allegri gioha...@gmail.com wrote: I apologize for the naive question but I haven't been able to find an explanation for the meaning of the square boxes that appear around my lines layer's nodes, when I display topological informations on the map. These square boxes are the bounding boxes for each line. I thought they could indicate errors, but my layer appear to be topologically ok. I'm sorry for asking so much difficult questions! :-) giovanni Sent from Nexus ___ 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] GRASS-Python Script: Check if output already exists, overwrite
Thank you! The grass.script.overwrite() function was the one I was looking for. :) On Thu, Apr 11, 2013 at 1:00 PM, Glynn Clements gl...@gclements.plus.comwrote: Johannes Radinger wrote: I would like to check if the file defined as output in a python script already exists and fire an error when it exists and the overwrite flag is not set. Furhtermore I'd like to check this already in the beginning before all calculations in the script are executed. g.parser should do this automatically. If an option has new in the gisprompt field, G_parser() checks that either the file/map/etc doesn't exist or overwrite is enabled. The only time you should need to do this manually is if an output name isn't simply an option value (e.g. r.mapcalc's output maps are specified in the expression, r.rgb takes an output template to which it appends a .r/.g/.b suffix, etc). I thought about something like: output = options['output'] if (grass.find_file(name = output, element = 'cell')['file'] and grass.read_command(g.gisenv, get = GRASS_OVERWRITE)!=1): grass.fatal(_(Output file exists already, either change output name or set overwrite-flag)) but what is the correct way to get the information if the overwrite flag is set or not for that script? The GRASS-OVERWRITE variable is not set although the script is launched with --overwrite. So how to get this info? The grass.script.overwrite() function returns True if overwrite is enabled. Also, os.environ['GRASS_OVERWRITE'] will have been set to '1' by grass.script.parser() so that the overwrite status propagates down to any commands executed by the script. -- 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] Python placeholder (%d) in stdin statement of db.execute
Oh yes, of course I could use the sql= option... I just overlooked that after moving from GRASS6.5 where this option is not yet existing. Thank you ... /Johannes On Thu, Apr 11, 2013 at 12:47 PM, Glynn Clements gl...@gclements.plus.comwrote: Johannes Radinger wrote: Thank you Hamish, including the option input=- in the python line (for GRASS7) solved the problem. Why read the command from stdin rather than using sql=...? E.g.: grass.write_command(db.execute, sql = UPDATE my points SET prob=100) -- 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] How to start GRASS 6.4 command line on linux
grass --help tells you to use grass -text Marco Am 11.04.2013 14:30, schrieb José Miguel Barrios: Hey Lucien, If you start a new terminal and start grass (by typing grass), you will be able to execute grass commands from the terminal. Success! Miguel 2013/4/11 BLANDENIER Lucien lucien.blanden...@unine.ch mailto:lucien.blanden...@unine.ch Dear all, I recently switched to linux (Mint KDE) and I simply don't find how to start the command line terminal of grass. Could someone help me? thanks Lucien ___ grass-user mailing list grass-user@lists.osgeo.org mailto: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 -- + FOSSGIS 2013, Die Konferenz für Open Source GIS mit OpenData und OpenStreetMap erstmals in der Schweiz! 12.-14. Juni, HSR, Rapperswil, http://www.fossgis.de/konferenz/2013/ + FOSSGIS e.V. die unabhängige Hilfe bei freier GIS-Software und freien Geodaten http://www.fossgis.de + ___ grass-user mailing list grass-user@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/grass-user
[GRASS-user] Fuzzy K-mean
Hello All, I am trying to find a way to process a fuzzy K-mean cluster using multiple rasters/grids in GRASS. Is anyone aware of a grass add-on or another simple process I can use to accomplish this? Thanks, Robert Brown PhD Student Purdue University Department of Agronomy ___ grass-user mailing list grass-user@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/grass-user
Re: [GRASS-user] Fuzzy K-mean
Robert I would recommend a combination of GRASS and R (http://cran.r-project.org/). R has fuzzy K-mean cluster capability, using the R addon package spgrass6 to read/write to/from GRASS and R. Also, see this: http://www.r-bloggers.com/fuzzy-clustering-with-fanny/ and this: http://stats.stackexchange.com/questions/31906/fuzzy-k-means-cluster-sizesas starting points. Tom On Thu, Apr 11, 2013 at 12:48 PM, Robert A Brown brown...@purdue.eduwrote: Hello All, I am trying to find a way to process a fuzzy K-mean cluster using multiple rasters/grids in GRASS. Is anyone aware of a grass add-on or another simple process I can use to accomplish this? Thanks, Robert Brown PhD Student Purdue University Department of Agronomy ___ 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] Exercises and Tutorials for GRASS GIS
On Wed, Apr 10, 2013 at 1:06 PM, Adrian Kirilov kirilov.adr...@gmail.com wrote: Hello to all GRASS GIS users, My name is Adrian Kirilov. I'm currently student and I'm making my thesis this semester. I have to use GIS software for it and I decided to use GRASS GIS. I have to work with vector data and specifically with ASCII text files from lidar processed data. Besides the suggestions from Johannes, check also http://grasswiki.osgeo.org/wiki/LIDAR Intro material also here: http://grass.osgeo.org/documentation/tutorials/ Best Markus PS: Online course with material: http://geostat-course.org/Topic_NetelerMetz_2012 ___ grass-user mailing list grass-user@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/grass-user
Re: [GRASS-user] Fuzzy K-mean
Hi Tom, I am an avid R user and forgot about the spgrass6 addon. I have linked to grass through R and read in my rasters with the following script. The process worked beautifully and I appreciate you reminding me of the package and process!!! Script for reading the rasters ### require(spgrass6) require(EMCluster) require(rgdal) initGRASS(C:/Program Files (x86)/GRASS GIS 7.0.svn, gisDbase=C:/Users/brown782/Desktop,location=grass_data,mapset =PERMANENT, override=T) require(spgrass6) require(EMCluster) require(rgdal) rasters - readRAST6(c(slope_pct, wetness_indx, nomralized_height), cat=c(T, F, F), useGDAL=T) # I decided to use the EMCluster package in R instead of the cmeans package. Yesterday, I only tried to work in the R interface with the raster and cmeans(e1071) packages and read in the grids as ascii files. My issue was that when I stacked the grids and tried using cmeans it seemed that the fuzzy cluster process did not seem to understand that my stacked grids were spatial data. So now that I am using the EMCluster package R is giving me an error that the rasters object needs to be a matrix. I used the following script to convert the data to a matrix. rasters2 = as.matrix(rasters) It seemed to work but R gave me the below warning that the Spatial.Data.Frame ## In as.matrix.SpatialGridDataFrame(rasters) : as.matrix.SpatialPixelsDataFrame uses first column; pass subset or [] for other columns # It seems that the as.matrix function somehow combined the three rasters into one because when I looked at the dimensions of the newly formed matrix it only gave me one set of dimensions. All of the rasters have the same dimensions. Where the Dimensions are below for the three rasters and the newly formed matrix. slope_pct = raster: rows: 6750 columns 9152 wetness_indx = raster: rows: 6750 columns 9152 normalized_height = raster rows: 6750 columns 9152 rasters2 = Matrix rows: 6750 columns 9152 can I convert the three individual grids to their own matrix then in run the EMCluster with the following script? results = simple.init(slope_pct, wetness_indx, normalized_height, nclass = 5) results = simple.init(slope_pct + wetness_indx + normalized_height, nclass = 5) I tried the second above option and it failed to produce any kind of meaningful cluster it just gave me a short list of NA and NAN Errors. Below I used the following code for the EMCluster package with the rasters2 matrix but would like to replace it with either of the codes above? results = simple.init(rasters2, nclass = 5) This may be something I need to post in the R discussion forum. Thanks for all of your help! Robert Brown - Original Message - From: Thomas Adams tea...@gmail.com To: Robert A Brown brown...@purdue.edu Cc: grass-user@lists.osgeo.org, Markus Metz markus.metz.gisw...@gmail.com Sent: Thursday, April 11, 2013 1:30:25 PM Subject: Re: [GRASS-user] Fuzzy K-mean Robert I would recommend a combination of GRASS and R ( http://cran.r-project.org/ ). R has fuzzy K-mean cluster capability, using the R addon package spgrass6 to read/write to/from GRASS and R. Also, see this: http://www.r-bloggers.com/fuzzy-clustering-with-fanny/ and this: http://stats.stackexchange.com/questions/31906/fuzzy-k-means-cluster-sizes as starting points. Tom On Thu, Apr 11, 2013 at 12:48 PM, Robert A Brown brown...@purdue.edu wrote: Hello All, I am trying to find a way to process a fuzzy K-mean cluster using multiple rasters/grids in GRASS. Is anyone aware of a grass add-on or another simple process I can use to accomplish this? Thanks, Robert Brown PhD Student Purdue University Department of Agronomy ___ 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] red square around node topology information?
Giovanni wrote: I haven't been able to find an explanation for the meaning of the square boxes that appear around my lines layer's nodes, when I display topological informations on the map. I thought they could indicate errors, but my layer appear to be topologically ok. they are just simple boxes drawn around all nodes. see {D|G}_plot_icon() at the end of d.vect/topo.c https://trac.osgeo.org/grass/browser/grass/trunk/display/d.vect/topo.c#L75 Hamish ___ grass-user mailing list grass-user@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/grass-user
Re: [GRASS-user] Fuzzy K-mean
Tom wrote: I would recommend a combination of GRASS and R (http://cran.r- project.org/). R has fuzzy K-mean cluster capability, using the R addon package spgrass6 to read/write to/from GRASS and R. see Roger's tutorial here: http://grasswiki.osgeo.org/wiki/R_statistics Hamish ___ grass-user mailing list grass-user@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/grass-user