Select to view content in your preferred language

Transforming slope raster with relative direction to produce negative/positive slope values representing increase and decrease in slope, respectively.

4116
19
Jump to solution
07-27-2018 12:43 PM
GavinSchag
Emerging Contributor

I have two 'base' line features that are somewhat parallel to each other, which are connected by vectors (also line features) [Check attached photo - underlying raster layer is not the DEM].

I want to use the vectors connecting the two 'base' lines to extract slope values calculated from a DEM. In other words, the vectors connecting the two 'base' lines are spatial sampling units, which will be used to extract topographic information to describe the movement from one base line to the next.  This is obviously problematic, since ArcGIS's slope tool only calculates slope directionality in terms of a convolution 3x3 kernel, which in turn, gives an output in degrees or percent rise....So. When I use the vectors to extract the slope values along each one (individual vectors),  there are obviously no negative values, when in reality, these vectors all have some sort of mixture of negative and positive slopes ( because many of the vectors from base line 1 to base line 2, go up and then down slope, or vice-versa).

My question - What algorithms can I use to transform the slope values based on some relative starting point of each vector, so that once I extract the slope values from each vector line - it will illustrate whether that vector was going predominantly downhill (negative slope) or uphill ( positive slope)?

Thank you for your time. Any thoughts, comments, or recommendations are greatly appreciated.

0 Kudos
1 Solution

Accepted Solutions
DanPatterson_Retired
MVP Emeritus

Attached is the script and the sample results.

Here is an example

Basically all you need to do is modify these 3 lines of code if you want to use a new text file.

And on that point... fix your column names and save as a *.csv file to make things easier to read.

You should test the code for readability.

if __name__ == "__main__":
    """make your changes to this section then `run` the script
    """
    f = r"C:\Temp\elevation_profiles\elevation_profiles_dan.csv"
    f_names = ['profile', 'z_st_end', 'first_dist']
    f_types = ['int', 'float', 'float']
    #
    # ---- don't modify this
    a, a_s, a_f, deltas, dz_dxs = process(f, f_names, f_types)  # Neil A.  magic section

Here are two examples... as you can see, ID=29 is all downhill, ID=30, less so

ID    29
Xs    [ 0.000  8.705  17.409  26.114  34.818]
Zs    [ 902.513  900.543  896.635  891.272  883.877]
dX    [ 8.705  8.705  8.705  8.705]
dZ    [-1.969 -3.908 -5.364 -7.394]    
dX/dZ [-0.226 -0.449 -0.616 -0.849]
down slopes [1 1 1 1]
down slope ratio  1.0000

ID    30
Xs    [ 0.000  9.445  18.891  28.336  37.781  47.226  56.672  66.117  75.562  85.007]
Zs    [ 871.432  878.691  885.234  892.904  902.854  907.207  905.885  900.993  893.996  886.938]
dX    [ 9.445  9.445  9.445  9.445  9.445  9.445  9.445  9.445  9.445]
dZ    [ 7.259  6.543  7.670  9.950  4.353 -1.321 -4.892 -6.996 -7.058]    
dX/dZ [ 0.769  0.693  0.812  1.053  0.461 -0.140 -0.518 -0.741 -0.747]
down slopes [0 0 0 0 0 1 1 1 1]
down slope ratio  0.4444

you can also do the change in the change and whatever, all the data are easily processed

View solution in original post

19 Replies
DanPatterson_Retired
MVP Emeritus

You say you don't have the DEM? Can you not get the one used to produce the slope raster? or a surrogate for the area?  The solution would be to find that data to extract the elevation values.  

Do you have a curvature raster? Curvature—Help | ArcGIS Desktop which would at least provide some information on slope directionality

GavinSchag
Emerging Contributor

Hi Dan,

Thanks for your response. I do have a DEM with the associated Aspect, Slope (both degree & %-rise versions), and Curvature outputs. Yet, when I use the vectors to extract such values, its misrepresented. Am I making sense here?

e.g.- one of the vectors travels predominantly downhill between baselines 1 and 2 - I extract the the slope values directly from that particular vector, yet the extracted values are positive...when in reality, the vectors total slope from its start at baseline 1 moving to baseline 2 is actually a negative slope.

Thanks, Gav

0 Kudos
DanPatterson_Retired
MVP Emeritus

When you extract using the vector, you should extract the elevation data to use it as a guide as to whether or not the elevation, hence slope, is increasing or decreasing.  However, since you have a direction of travel along a vector, you might be able to repurpose aspect to give you a guide.  For instance if your vector is travelling from west to east along a constant slope whose elevation is increasing, the aspect is 270, then the slope is pointinto the west and the vector is going uphill.  An incremental move to the east will show a decrease in slope but a fixed aspect.  At some point, if you begin to go downhill, the aspect will change eventually reaching  90 degrees, since the vector is going down hill and the slope will incrementally increase.

  More complicated calculations can be done in numpy, in fact, slope aspect and other terrain derivates can be assessed using it.  Consider this small DEM with D8 slope and aspect calculated using numpy.  Pay attention to the line

Slope....   [45.   26.57  0.    0.    0.   26.57 45.  ]              Row 15

Aspect...  [270.   270.   270.   270.   270.    90.    90.  ]   Row 23

Dem...
[[0 1 2 3 3 3 2 1 0]
 [1 2 3 4 4 4 3 2 1]
 [2 3 4 5 5 5 4 3 2]
 [3 4 5 5 5 5 5 4 3]
 [3 4 5 5 5 5 5 4 3]
 [3 4 5 5 5 5 5 4 3]
 [2 3 4 5 5 5 4 3 2]
 [1 2 3 4 4 4 3 2 1]
 [0 1 2 3 3 3 2 1 0]]
Slope...
[[54.74 54.74 48.19 45.   48.19 54.74 54.74]
 [54.74 51.06 36.09 26.57 36.09 51.06 54.74]
 [48.19 36.09 10.02  0.   10.02 36.09 48.19]
 [45.   26.57  0.    0.    0.   26.57 45.  ]
 [48.19 36.09 10.02  0.   10.02 36.09 48.19]
 [54.74 51.06 36.09 26.57 36.09 51.06 54.74]
 [54.74 54.74 48.19 45.   48.19 54.74 54.74]]
Aspect
[[315.   315.   333.43   0.    26.57  45.    45.  ]
 [315.   315.   333.43   0.    26.57  45.    45.  ]
 [296.57 296.57 315.   270.    45.    63.43  63.43]
 [270.   270.   270.   270.   270.    90.    90.  ]
 [243.43 243.43 225.   270.   135.   116.57 116.57]
 [225.   225.   206.57 180.   153.43 135.   135.  ]
 [225.   225.   206.57 180.   153.43 135.   135.  ]]
GavinSchag
Emerging Contributor

Hi Dan,

Thanks again for taking the time to help me out, I'm getting closer to finding a solution. You make some really valuable points about the relationship between aspect, elevation, and slope. The matrices you show also illustrate that well...Now I suppose I should just experiment to find the precise relationship relationship between the raster layers to transform them accordingly within raster calculator....I'm going to look into the "numpy" (?) software as well...

Gav

0 Kudos
DanPatterson_Retired
MVP Emeritus

numpy is built on python and is a separate package.  It is available with arcmap and ArcGIS Pro.

You could look at my somewhat disorganized blog 

 

I use numpy and other parts of the Scipy stack extensively in my work.  In fact those examples were produced using numpy, including the d8 slope calculations

GavinSchag
Emerging Contributor

Very cool. Just browsed through your blog for a few minutes, Dan. Some extremely useful info...

Gav

DanPatterson_Retired
MVP Emeritus

Gavin, why don't you extract some elevation profiles, I have some new stuff for detecting trend persistence that I would be interesting in testing.  they work pretty well with my artificial terrains... but it would be interesting to examine slope length influences as well

/blogs/dan_patterson/2017/12/28/terrain-creation-diamond-square-algorithm 

GavinSchag
Emerging Contributor

Hi Dan,

Apologies for the tardy response, I'm just getting settled back into work after a 5 day hiatus. I'll be sending you some elevation profiles within the next 24-48 hours so you may test-away. Is there any particular format you want the profiles? Text file? Excel spreadsheet?

Gav

0 Kudos
DanPatterson_Retired
MVP Emeritus

text is fine, or whatever is easiest Gavin

0 Kudos