Last active
August 29, 2015 14:15
-
-
Save seumasmorrison/5e3ab6b90e187e076151 to your computer and use it in GitHub Desktop.
Improved version of previous script ( https://gist.github.com/seumasmorrison/d3f3afa96b350163909b ) for importing and converting post processed data reliably
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import LatLon | |
import pandas as pd | |
import re | |
# Function for importing Leica Geo Office created comma separated variables | |
# files from post processed data, decimal seconds coordinates are converted | |
# to decimal degrees. | |
def read_lgo_csv_decimal_seconds_to_decimal_degrees(input_file, output_file): | |
cols = ['id','type','timestamp', 'Latitude', 'Longtitude', 'Height', | |
'Ortho.Hgt.','Geoid Sep.', 'Code', 'Attributes','[Sd. X]', | |
'[Sd. Y]', '[Sd. Z]', 'Posn. + Hgt. Qlty','Code Information'] | |
leica_points = pd.read_csv(input_file, names=cols) | |
coords = [] | |
chars = '[\xb0\'"]' | |
for index, row in leica_points.iterrows(): | |
lat_dmds = re.sub(chars,'',row.Latitude) | |
long_dmds = re.sub(chars,'',row.Longtitude) | |
coord = LatLon.string2latlon(lat_dmds,long_dmds,'d% %m% %S% %H') | |
coords.append([coord.lat.decimal_degree, coord.lon.decimal_degree]) | |
coords_df = pd.DataFrame(coords, columns=['Latitude', 'Longtitude']) | |
leica_points.Latitude = coords_df.Latitude | |
leica_points.Longtitude = coords_df.Longtitude | |
leica_points.to_csv(output_file) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment