I would like to calculate the general aspect for stream segments in R. The stream network has been derived from the DEM and is in 2D. I have split the stream segments into equal parts of 100m (or less) and I have the DEM (1m resolution). (It is possible thatWhile the aspect may change (slightly) along each segment but, I am interested in the overall or dominant aspect for that segment) based on the hill slope from start to finish. [I can see it might possible to use the DEM to create a 3D linestring but I don't know how]
When I use a basic tool to calculate aspect for each cell/pixel of a DEM raster, it shows opposite facing-slopes on either side of the stream (logically). Here, I want the aspect of the stream, i.e. of the general slope/aspect of the hill along which the stream flows. If the stream is flowing along a hill that is north-facing, the aspect that I am hoping to obtain is North (or 0). I don't want the direction of flow of the stream (from x1,x2 to y1,y2) although it may overlap given that the stream will probably flow in the most direct route downhill.
I am aware of tools in QGIS and ArcGIS but I would like to make as many of my steps within R as possible (Calculate slope of line segments with QGIS ; Workflow for determining stream gradient?)
I had initially asked a question about slope and aspect but only got an answer for slope so I'm asking it specifically about aspect here.