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 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.
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…
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.
On Wed, Jun 2, 2010 at 6:50 PM, Margherita Di Leo <diregola@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
?
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,
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…
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.
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…
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.
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…
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.
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…
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.