Re: [GRASS-user] get coords from a raster
Margherita, now I got your point...I had a very similar problem a short time ago, but finally I was able to solve it. If your are interested in, take a look to the following notes - I know, a bit complicated but it works - set your desired path as a mask for limiting following calculations using r.mask - r.describe -dr your_dem to fetch min and max of elevation along your path (use tool awk or any other string processing function like split() in Python) - r.to.vect to convert the mask into a vector line, and then v.to.db -p your_vector_path option=length column=s to print out the path length (therefor, parse the string again to fetch the column that contains the length) - now you can calculate the slope based on altitude difference and distance... Perhaps it is adaptable to yours... Christian. From: Margherita Di Leo Sent: Wednesday, June 02, 2010 6:50 PM To: Christian Schwartze Cc: grass-user@lists.osgeo.org Subject: Re: [GRASS-user] get coords from a raster Christian, thank you for answering. My problem is that I don't want to use the slope map to get slope, bu i want to calculate it as the ratio between the difference of the elevation and the distance between two given points (pixels). To do that, I need to get the coordinates of the points as a input file for r.profile. Margherita 2010/6/2 Christian Schwartze christian.schwar...@uni-jena.de Why are you not using r.statistics, since it takes one base map (your path as a raster) and another map containing data you want to analyze (your slope). With the average option/method you will get the desired result, if I understand you correctly... Christian. From: Margherita Di Leo Sent: Wednesday, June 02, 2010 6:17 PM To: grass-user@lists.osgeo.org Subject: [GRASS-user] get coords from a raster Hi List, I'm trying to make a script to calculate the slope along a path. I want to calculate the slope as the average of cell per cell slope. For my purpose I found r.profile to produce the input file for my script, but I have to give it the coordinates of the points. As I have a raster and not a vector, I was wondering if is there a non interactive way like a d.where or something like that, that i can use for my purpose. I mean, i have a raster in which there is the path i'm interested in, and the other cells are null. Thank you in advance Margherita -- ___ grass-user mailing list grass-user@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/grass-user Emoticon3.gif___ grass-user mailing list grass-user@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/grass-user
Re: [GRASS-user] get coords from a raster
Thank you everyone for your help. As always, GRASS offers many possibilities to do anything. I solved with r.out.xyz. Best, Margherita 2010/6/3 Christian Schwartze christian.schwar...@uni-jena.de Margherita, now I got your point...I had a very similar problem a short time ago, but finally I was able to solve it. If your are interested in, take a look to the following notes - I know, a bit complicated but it works [image: Zwinkerndes Smiley Emoticon] - set your desired path as a mask for limiting following calculations using r.mask - r.describe -dr your_dem to fetch min and max of elevation along your path (use tool awk or any other string processing function like split() in Python) - r.to.vect to convert the mask into a vector line, and then v.to.db -p your_vector_path option=length column=s to print out the path length (therefor, parse the string again to fetch the column that contains the length) - now you can calculate the slope based on altitude difference and distance... Perhaps it is adaptable to yours... Christian. *From:* Margherita Di Leo direg...@gmail.com *Sent:* Wednesday, June 02, 2010 6:50 PM *To:* Christian Schwartze christian.schwar...@uni-jena.de *Cc:* grass-user@lists.osgeo.org *Subject:* Re: [GRASS-user] get coords from a raster Christian, thank you for answering. My problem is that I don't want to use the slope map to get slope, bu i want to calculate it as the ratio between the difference of the elevation and the distance between two given points (pixels). To do that, I need to get the coordinates of the points as a input file for r.profile. Margherita 2010/6/2 Christian Schwartze christian.schwar...@uni-jena.de Why are you not using r.statistics, since it takes one base map (your path as a raster) and another map containing data you want to analyze (your slope). With the average option/method you will get the desired result, if I understand you correctly... Christian. *From:* Margherita Di Leo direg...@gmail.com *Sent:* Wednesday, June 02, 2010 6:17 PM *To:* grass-user@lists.osgeo.org *Subject:* [GRASS-user] get coords from a raster Hi List, I'm trying to make a script to calculate the slope along a path. I want to calculate the slope as the average of cell per cell slope. For my purpose I found r.profile to produce the input file for my script, but I have to give it the coordinates of the points. As I have a raster and not a vector, I was wondering if is there a non interactive way like a d.where or something like that, that i can use for my purpose. I mean, i have a raster in which there is the path i'm interested in, and the other cells are null. Thank you in advance Margherita -- ___ grass-user mailing list grass-user@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/grass-user Emoticon3.gif___ grass-user mailing list grass-user@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/grass-user
[GRASS-user] get coords from a raster
Hi List, I'm trying to make a script to calculate the slope along a path. I want to calculate the slope as the average of cell per cell slope. For my purpose I found r.profile to produce the input file for my script, but I have to give it the coordinates of the points. As I have a raster and not a vector, I was wondering if is there a non interactive way like a d.where or something like that, that i can use for my purpose. I mean, i have a raster in which there is the path i'm interested in, and the other cells are null. Thank you in advance Margherita ___ grass-user mailing list grass-user@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/grass-user
Re: [GRASS-user] get coords from a raster
Christian, thank you for answering. My problem is that I don't want to use the slope map to get slope, bu i want to calculate it as the ratio between the difference of the elevation and the distance between two given points (pixels). To do that, I need to get the coordinates of the points as a input file for r.profile. Margherita 2010/6/2 Christian Schwartze christian.schwar...@uni-jena.de Why are you not using r.statistics, since it takes one base map (your path as a raster) and another map containing data you want to analyze (your slope). With the average option/method you will get the desired result, if I understand you correctly... Christian. *From:* Margherita Di Leo direg...@gmail.com *Sent:* Wednesday, June 02, 2010 6:17 PM *To:* grass-user@lists.osgeo.org *Subject:* [GRASS-user] get coords from a raster Hi List, I'm trying to make a script to calculate the slope along a path. I want to calculate the slope as the average of cell per cell slope. For my purpose I found r.profile to produce the input file for my script, but I have to give it the coordinates of the points. As I have a raster and not a vector, I was wondering if is there a non interactive way like a d.where or something like that, that i can use for my purpose. I mean, i have a raster in which there is the path i'm interested in, and the other cells are null. Thank you in advance Margherita -- ___ grass-user mailing list grass-user@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/grass-user ___ grass-user mailing list grass-user@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/grass-user
Re: [GRASS-user] get coords from a raster
On Wed, Jun 2, 2010 at 6:50 PM, Margherita Di Leo direg...@gmail.com wrote: Christian, thank you for answering. My problem is that I don't want to use the slope map to get slope, bu i want to calculate it as the ratio between the difference of the elevation and the distance between two given points (pixels). If you treat them as vectors, perhaps this could help? v.to.db ... slope: slope steepness of vector line or boundary ? Markus ___ grass-user mailing list grass-user@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/grass-user
Re: [GRASS-user] get coords from a raster
Markus, Thank you. I'm pretty sure this is the way. So I run: r.to.vect input=mainchannel output=points feature=point --o v.to.db map=points option=coor col=x,y (like the man page suggests) but I get a number of errors like: Column 'x' not found Error in db_execute_immediate() where am I wrong now? 2010/6/2 Markus Neteler nete...@osgeo.org If you treat them as vectors, perhaps this could help? v.to.db ... slope: slope steepness of vector line or boundary I calculate slope as S = (z2-z1)/(sqrt((x2-x1)^2+(y2-y1)^2))*100 where x1,y1 are the coords of point 1, x2,y2 are the coords of point 2, and z1, z2 are the elevations in the raster map associate at the points 1 and 2 respectively. Margherita ? Markus ___ grass-user mailing list grass-user@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/grass-user
Re: [GRASS-user] get coords from a raster
On Wed, Jun 2, 2010 at 10:07 PM, Margherita Di Leo direg...@gmail.com wrote: Markus, Thank you. I'm pretty sure this is the way. So I run: r.to.vect input=mainchannel output=points feature=point --o v.to.db map=points option=coor col=x,y (like the man page suggests) but I get a number of errors like: Column 'x' not found Error in db_execute_immediate() where am I wrong now? Two times v.db.addcol is missing for the x and y columns (before v.to.db). Markus ___ grass-user mailing list grass-user@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/grass-user