We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
these values are in meters
total elevation change is: 346781.89000000095 total distance is: 4171048.0624210313 average slope is: 0.08314022874114661
from math import sqrt from shapely.ops import linemerge import geom from data_source import Halfmile def main(): hm = Halfmile() gdf = hm.trail_full(False) # Reproject to meters gdf = geom.reproject_gdf(gdf, geom.WGS84, geom.CA_ALBERS) line = linemerge(gdf.geometry.values) # Calculate horizontal distance and vertical distance for each segment of # the data: dist_list, dz_list = calculate_dist_and_elev_change(line) total_elevation_change = sum([abs(x) for x in dz_list]) total_distance = sum(dist_list) average_slope = total_elevation_change / total_distance print(f'total elevation change is: {total_elevation_change}') print(f'total distance is: {total_distance}') print(f'average slope is: {average_slope}') def calculate_dist_and_elev_change(line): dist_list = [] dz_list = [] for coord, next_coord in zip(line.coords, line.coords[1:]): dx = next_coord[0] - coord[0] dy = next_coord[1] - coord[1] dz = next_coord[2] - coord[2] dist = sqrt(dx ** 2 + dy ** 2) dist_list.append(dist) dz_list.append(dz) return dist_list, dz_list if __name__ == '__main__': main()
The text was updated successfully, but these errors were encountered:
No branches or pull requests
these values are in meters
The text was updated successfully, but these errors were encountered: