Closed Traverse Calculations and Adjustments
Purpose.
I have been working on a small “R” program that will define adjustments and computations to a closed traverse for surveying applications. The traverse adjustments used are the Compass (Bowditch) Rule, which adjusts departures and latitudes of traverse courses in proportion to their lengths. Not as rigorous as the least squares method, still it logically distributes misclosures according to the following formulas:
\[Departure \: correction = \frac{total \: departure \: misclosure}{traverse \: perimeter} \: length\: \: of \: AB\]
\[Latitude \: correction = \frac{total \: latitude \: misclosure}{traverse \: perimeter} \: length \: of \: AB\]
First, we determine the latitude and departure of each line of the traverse. This is done with the following:
\[departure = L \: sin(azimuth)\] \[latitude = L \: cos(azimuth)\]
If we make an assumption the start of the first course X/Y coordinates are 0/0, we can then determine the following X/Y coordinate pairs by adding the adjusted departures and latitudes to \(X_a\) and \(Y_a\) per the following formula:
\[X_b = X_a + departure \: AB\] \[Y_b = Y_a + latitude \: AB\]
This continues around the traverse until the starting point coordinates are recalculated. If the recalculated coordinates of the first point agree with point A, a check is obtained. Usually there is some small error in observations or azimuths that need to be adjusted out. This can also provide a check to identify gross blunders.
If a departure and latitude are known the azimuth or bearing can be determined by \(\tan^{-1}(\frac{departure \: AB}{latitude \: AB})\).
By adjusting departures and latitudes, the azimuths and lengths will also change. So final adjusted azimuths and lengths must be calculated using the balanced departures and latitudes. The above formula for azimuth, and the following formula for length are used to compute those final adjusted azimuths and distances: \[Length \: AB = \sqrt{(departure \: AB)^2 + (latitude \: AB)^2}\]
For correct azimuth values, the following rules apply in the given order:
1: If Balanced Latitude is negative, add 180 to Azimuth.
2: If Balanced Departure is negative, add 360 to Azimuth.
Do one or the other, but not both.
The Program
Even though I am a NOOB at the “R” programming language, I continully find it fun and useful for all kinds of projects. So much that I rarely consider Python, Perl or C++ anymore. I want to see if I can do something using “R” instead. It is a challenge for me as I am not well versed in the finer aspects of the language. So I have to do a great deal of surfing, looking for clues as how to do a particular thing, or some idea I can adapt to my needs. In fact, this whole website is developed using rmarkdown, blogdown, bookdown, and many other “R” libraries, and displayed using Hugo.
The script is designed to accept almost any combination of inputs. For example, dimensional lengths can be feet, chains (66 ft.) or meters, and is user selectable. The azimuth inputs can be in decimal degrees; degrees, minutes, seconds; bearings; or deflection angles. One restriction is a deflection angle cannot be the first entry. Also, bearings (NSEW) must be entered in capitals, as must deflection angles (LR). For DMS inputs, commas are used between fields. Having said that, there is very little error catching built into the program, so any bad input will crash to the prompt, requiring the program to be restarted. All of the below input formats can be entered and will be processed correctly:
- 123,45,09.12
- 123,45,06
- 123,32
- 123
- 123.8476
- N47,15,21E
- S89,12W
- S1,13,45E
- N45W
- 122,17,12R
- 45L
- 329,39,59.5R
- 0
- 360, etc.
Functions are used where they are useful to help eliminate repetitious conversions. The five main functions defined are to convert decimal degrees to DMS; convert DMS to decimal degrees; determine azimuth entry format; convert bearings to azimuths; and, a function for deflection angle processing. At the end of the program is the option to print the generated values to a text file for printing.
Once the azimuth and distance data is entered, and before any calculations are performed, the entered data is saved to a csv file in the current directory. This permits bringing up the last entered data at a later time to regenerate the calculations. The csv file can also be loaded into other pragrams like Excel, OpenOffice or LibreOffice to edit the data, save to disk, and then recalculate using “R” to examine the corrected values.
The only external library that needs to be loaded is the ‘stringr’ library as numerous conversions are performed and input strings manipulated during the process of determining the azimuth data entered. As the ‘sin’ and ‘cos’ functions are used, the data has to be converted from degrees to radians to calculate initial latitude and departure, and for final azimuth calculations. Also determined is error of closure and precision, as a check to assist in identifying gross errors or mistakes in data.
Next, the adjusted Latitude and Departure, X, Y coordinates, and final adjusted azimuths and lengths are calculated and tabulated. Once the area is computed, the columns containing degree data are converted to DMS format for easier reading. Then the final tabulated data is presented and the option to save to a file is presented. The program grew a bit longer than I intended as I continued to add functionality. Even still, it is less than 250 lines long.
Click Here to see the program.
Again, we acknowledge that God is the provider of all we have and all we are, and we thank Him for His Grace through Jesus Christ. Have a great day and enjoy the script, feel free to modify and make it better. I still am struggling to adapt something to the least squares method. That is another ball of wax, as the saying goes. Bye for now.