0

I'm currently using an OSM dataset of San Francisco and I want to calculate the angle of elevation of each road segment using x and y coordinates given by this dataset. I used this formula and I get wrong data. the formula:

dLon = (long2 - long1);
y = Math.sin(dLon) * Math.cos(lat2);
x = Math.cos(lat1) * Math.sin(lat2) - Math.sin(lat1)
        * Math.cos(lat2) * Math.cos(dLon);

angle = Math.atan2(y, x);

angle_degree = Math.toDegrees(angle);
rt = (angle_degree + 360) % 360;
ang = 360 - rt;

Ps: I converted longitude and altitude coordinates to radians to use this formula.

Have you any other suggestions please?

enter image description here

0

1 Answer 1

1

Where is the z data?

the angle would be asin(z/(x^2+y^2)) with x^2+y^2 == (x1-x2)^2+(y1-y2)^2 expressed in Cartesian co-ordinates. In "Vector geometry" with Add_geometry one can convert and add x,y co-ordinates to the table.

For the z-data you need a raster/vector layer (LIDAR,SRTM) which you can also convert to have x,y co-ordinate pairs.

And there is the elevation/slope/degrees plugin tool
Slope tool QGIS

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.