Surveyors will traditionaly only calculate the reduce level and plot the result in the for of a profile drawing.
I this exercise, I will take the calculation further by making some useful statistical calculations and analysis.
Am going to use three main packages called numpy, pandas and matplotlib.
The Data (in .csv format) used is available for download here. Download it and save it at thesame location with this notebook.
Author: Umar Yusuf
http://umar-yusuf.blogspot.com.ng/2016/08/Analyzing-Surveyors-Level-Field-Table-Book-with-Python.html
In [433]:
# Lets import the packages
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
# Lets enable our plot to display inline within notebook
%matplotlib inline
In [434]:
level_table = pd.read_csv("Level_Book.csv")
level_table.round(3)
Out[434]:
In [435]:
# lets replace the NaN with 0.000. But first let see the titles of the colums
level_table.columns
Out[435]:
In [436]:
# Replace NaN with empty space for all columns
level_table_cleaned = level_table.fillna('')
# level_table_cleaned = level_table.replace(np.nan, '')
level_table_cleaned
Out[436]:
Now the table looks cleaner an just as it looks in the original csv file.
However, this will not allow numerical analysis performed on any colum with white space or NaN value. So instead, I will replace that with 0.000
In [437]:
# Replace white space with 0.000 for all columns
level_table_zeros = level_table.fillna(0.000)
level_table_zeros
Out[437]:
In [438]:
level_table_zeros.describe()
Out[438]:
The result above may only be meaningfull to the "Reduce Level" column. But never mind this is just for sake of demonstration.
Remember that in other to check a level table computation for errors, we have to compare the defference in the sum of "Back-sight and Fore-sight", Rise and Fall and Last and First reduce level. And if the defferences are thesame, then we say our table arithmetics and observations are correct.
Let do that...
Lets redefine the columns of interest to give then shorter name as follow;-
$Back Sight = BS$
$Fore Sight = FS$
$Rise = Rise$
$Fall = Fall$
$First Reduce Level = FRL$
$Last Reduce Level = LRL$
In [439]:
# Sum each column and save it in redefine column name as variable
BS = level_table["Back Sight"].sum()
FS = level_table["Fore Sight"].sum()
Rise = level_table["Rise"].sum()
Fall = level_table["Fall"].sum()
# Use round() method to round Rise to 3 decimals
Rise = round(Rise, 3)
# Getting the values of the FRL and LRL
FRL = level_table["Reduce Level"][0]
LRL = level_table["Reduce Level"][18]
BS, FS, Rise, Fall, FRL, LRL
Out[439]:
In [440]:
# Checking the arithmetic for error
# the result should be turple of thesame number.
BS - FS, Rise - Fall, LRL - FRL
Out[440]:
This is probably the common use of a levelling data table (plotting of profile).
Let Visualise the relationship that exist between these two columns - Reduce level and Distance using the matplotlib package.
x-axis will be Distance column while y-axis will be the Reduce level column.
In [441]:
x = level_table["Distance"]
y = level_table["Reduce Level"]
plt.figure(figsize=(20, 7), facecolor='orange')
plt.plot(x, y, linestyle="dashed", marker="o", color="blue")
plt.title("Profile Drawing", size=30, color="white")
plt.xlabel("Distance (m)", size=20, color="white")
plt.ylabel("Reduce Level (m)", size=20, color="white")
plt.xticks([5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115, 125, 135, 145, 155, 165, 175], size=15)
plt.yticks([10, 10.5, 11], size=15)
plt.grid()
plt.show()
That is it! Now you got some analysis to perform on your level observations.
Author: Umar Yusuf
http://umar-yusuf.blogspot.com.ng/2016/08/Analyzing-Surveyors-Level-Field-Table-Book-with-Python.html