You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In Section 6.3: Raster Extraction, the code provided in the text - using st_distance() - computes the distance from the first point to every other point using the crow’s flight (Euclidean) distance. While this works for straight-line transects, it does not account for non-linear paths commonly encountered in real-world scenarios such as hiking trails. This results in inaccurate distance values when generating elevation profiles.
A more accurate approach involves computing the cumulative distance along the path itself. In the proposed code below, we extract the coordinates of each point and then compute the Euclidean distance between consecutive points. Taking the cumulative sum of these segment distances gives the total distance from the starting point along the actual path, whether it is straight or winding. This results in a more realistic and useful elevation profile.
My Proposed Code (Cumulative Distance Along Path):
# Obtain coordinates of each pointzion_transect_coordinates<-zion_transect|>
group_by(id) |>
st_coordinates()
# Compute the cumulative distance from the starting point along the pathpoint_distances<- c(
0,
cumsum(sqrt(rowSums(diff(zion_transect_coordinates)^2)))
)
zion_transect<-zion_transect|>
mutate(dist=point_distances)
This enhancement ensures that the distance reflects the true travel path and thus improves the elevation profiling workflow. A real-life example of this approach is on my webpage Getting Elevation Profile of the UTMB Ultra-marathon.
The text was updated successfully, but these errors were encountered:
In Section 6.3: Raster Extraction, the code provided in the text - using
st_distance()
- computes the distance from the first point to every other point using the crow’s flight (Euclidean) distance. While this works for straight-line transects, it does not account for non-linear paths commonly encountered in real-world scenarios such as hiking trails. This results in inaccurate distance values when generating elevation profiles.A more accurate approach involves computing the cumulative distance along the path itself. In the proposed code below, we extract the coordinates of each point and then compute the Euclidean distance between consecutive points. Taking the cumulative sum of these segment distances gives the total distance from the starting point along the actual path, whether it is straight or winding. This results in a more realistic and useful elevation profile.
Original Code (Straight-Line Assumption):
My Proposed Code (Cumulative Distance Along Path):
This enhancement ensures that the distance reflects the true travel path and thus improves the elevation profiling workflow. A real-life example of this approach is on my webpage Getting Elevation Profile of the UTMB Ultra-marathon.
The text was updated successfully, but these errors were encountered: