spamlab-iee / os

An open source, cross-platform structural geology analysis software
GNU General Public License v3.0
25 stars 5 forks source link

azimuth/length from shapefile is wrong #20

Open SPAMLab opened 5 years ago

SPAMLab commented 5 years ago

Calculating azimuth and length from a lineament shapefile gives completely wrong results. I run a test on a shapefile with lines oriented NE-SW only, and the resulting azimuths are in the SE quadrant.. lengths are also wrong, instead of tens of meters (the shp is in UTM projection), I got thousands of kilometers! Plus, teh output could use just 2 decimal places for azimuth and 3 for length.

example of OS output:

160.55724750813;6898224.56940145
186.22119724964833;4631297.414248208
162.16323619148045;6677953.927241127
163.32972597763344;7907432.249358391
164.82943527784053;5636432.004645046

what it should be:

216.46,68.154
216.68,53.182
217.02,67.036
215.20,78.461
217.94,58.430
endarthur commented 5 years ago

Sorry for the long time to answer,

OS currently uses these formulas https://www.movable-type.co.uk/scripts/latlong.html To calculate length of segments and bearing from geographic coordinates, as a way of avoiding the distortions inherent to the UTM projection. When I first implemented the feature I tried to find a good way to detect the coordinate system of the input file, but it seemed at the time that the only way would be to add proj4 or something like that. A possible heuristic to detect would be to check the range of the input numbers, and complain if they are larger than what's possible for lat/lon. Either that or actually consider the projection of the input data and transform to geographical before the operation. Any other suggestion?

endarthur commented 5 years ago

https://www.movable-type.co.uk/scripts/latlong-vincenty.html Would probably be nice to add this as well, by the way.

endarthur commented 5 years ago

Added a new method for converting lineaments from UTM shapefiles on the tools menu, and made clearer that the one that was already available was for geographic. Could you test it with your data? From my tests it was off by about 2 degrees, probably because of grid convergence. Do you believe this would be enough for now or would it be better to just convert to geographic? Maybe using this https://www.movable-type.co.uk/scripts/latlong-utm-mgrs.html in the case of utm before calculating would be better. Still have to set the decimal places.