Exemple #1
0
def vincinvio():
    # Enter Filename
    print('Enter co-ordinate file:')
    fn = input()
    # Open Filename
    csvfile = open(fn)
    csvreader = csv.reader(csvfile)
    # Create Output File
    fn_part = (os.path.splitext(fn))
    fn_out = fn_part[0] + '_out' + fn_part[1]
    outfile = open(fn_out, 'w')
    # Write Output
    outfilewriter = csv.writer(outfile)
    outfilewriter.writerow(['Ell_Dist', 'Azimuth1to2', 'Azimuth2to1'])
    for row in csvreader:
        lat1 = dms2dd(float(row[0]))
        long1 = dms2dd(float(row[1]))
        lat2 = dms2dd(float(row[2]))
        long2 = dms2dd(float(row[3]))
        ell_dist, azimuth1to2, azimuth2to1 = vincinv(lat1, long1, lat2, long2)
        azimuth1to2 = dd2dms(azimuth1to2)
        azimuth2to1 = dd2dms(azimuth2to1)
        output = (ell_dist, azimuth1to2, azimuth2to1)
        outfilewriter.writerow(output)
    # Close Files
    outfile.close()
    csvfile.close()
Exemple #2
0
def conform7(x, y, z, trans):
    """
    Performs a Helmert 7 Parameter Conformal Transformation using Cartesian point co-ordinates
    and a predefined transformation object.
    :param x: Cartesian X (m)
    :param y: Cartesian Y (m)
    :param z: Cartesian Z (m)
    :param trans: Transformation Object
    :return: Transformed X, Y, Z Cartesian Co-ordinates
    """
    if type(trans) != Transformation:
        raise ValueError('trans must be a Transformation Object')
    # Create XYZ Vector
    xyz_before = np.array([[x], [y], [z]])
    # Convert Units for Transformation Parameters
    scale = trans.sc / 1000000
    rx = radians(dms2dd(trans.rx / 10000))
    ry = radians(dms2dd(trans.ry / 10000))
    rz = radians(dms2dd(trans.rz / 10000))
    # Create Translation Vector
    translation = np.array([[trans.tx], [trans.ty], [trans.tz]])
    # Create Rotation Matrix
    rotation = np.array([[1., rz, -ry], [-rz, 1., rx], [ry, -rx, 1.]])
    # Conformal Transform Eq
    xyz_after = translation + (1 + scale) * np.dot(rotation, xyz_before)
    # Convert Vector to Separate Variables
    xtrans = float(xyz_after[0])
    ytrans = float(xyz_after[1])
    ztrans = float(xyz_after[2])
    return xtrans, ytrans, ztrans
Exemple #3
0
 def test_vincinv(self):
     # Flinders Peak
     lat1 = dms2dd(-37.57037203)
     long1 = dms2dd(144.25295244)
     # Buninyong
     lat2 = dms2dd(-37.39101561)
     long2 = dms2dd(143.55353839)
     ell_dist, azimuth1to2, azimuth2to1 = vincinv(lat1, long1, lat2, long2)
     self.assertEqual(round(ell_dist, 3), 54972.271)
     self.assertEqual(round(dd2dms(azimuth1to2), 6), 306.520537)
     self.assertEqual(round(dd2dms(azimuth2to1), 6), 127.102507)
Exemple #4
0
 def test_vincdir(self):
     # Flinders Peak
     lat1 = dms2dd(-37.57037203)
     long1 = dms2dd(144.25295244)
     # To Buninyong
     azimuth1to2 = dms2dd(306.520537)
     ell_dist = 54972.271
     lat2, long2, azimuth2to1 = vincdir(lat1, long1, azimuth1to2, ell_dist)
     self.assertEqual(round(dd2dms(lat2), 8), -37.39101561)
     self.assertEqual(round(dd2dms(long2), 8), 143.55353839)
     self.assertEqual(round(dd2dms(azimuth2to1), 6), 127.102507)
Exemple #5
0
def va_conv(verta_hp, slope_dist, height_inst=0, height_tgt=0):
    """
    Function to convert vertical angles (zenith distances) and slope distances
    into horizontal distances and changes in height. Instrument and Target
    heights can be entered to allow computation of zenith and slope distances
    between ground points.

    :param verta_hp:        Vertical Angle from Instrument to Target, expressed
                            in HP Format (DDD.MMSSSSSS)
    :param slope_dist:      Slope Distance from Instrument to Target in metres
    :param height_inst:     Height of Instrument. Optional - Default Value of 0m
    :param height_tgt:      Height of Target. Optional - Default Value of 0m

    :return: verta_pt_hp:   Vertical Angle between Ground Points, expressed
                            in HP Format (DDD.MMSSSSSS)
    :return: slope_dist_pt: Slope Distance between Ground Points in metres
    :return: hz_dist:       Horizontal Distance
    :return: delta_ht:      Change in height between Ground Points in metres
    """
    # Convert Zenith Angle to Vertical Angle
    try:
        if verta_hp == 0 or verta_hp == 180:
            raise ValueError
        elif 0 < verta_hp < 180:
            verta = radians(90 - dms2dd(verta_hp))
        elif 180 < verta_hp < 360:
            verta = radians(270 - dms2dd(verta_hp))
        else:
            raise ValueError
    except ValueError:
        print('ValueError: Vertical Angle Invalid')
        return
    # Calculate Horizontal Dist and Delta Height
    hz_dist = slope_dist * cos(verta)
    delta_ht = slope_dist * sin(verta)
    # Account for Target and Instrument Heights
    if height_inst == 0 and height_tgt == 0:
        verta_pt_hp = verta_hp
        slope_dist_pt = slope_dist
    else:
        delta_ht = height_inst + delta_ht - height_tgt
        slope_dist_pt = sqrt(delta_ht**2 + hz_dist**2)
        verta_pt = asin(delta_ht / slope_dist)
        verta_pt_hp = dd2dms(degrees(verta_pt) + 90)
    return verta_pt_hp, slope_dist_pt, hz_dist, delta_ht
Exemple #6
0
def vincdirio():
    """
    No Input:
    Prompts the user for the name of a file in csv format. Data in the file
    must be in the form Latitude, Longitude of Point 1 in Degrees Minutes
    Seconds, Geodetic Azimuth from Point 1 to 2 in Degrees Minutes Seconds and
    Distance in metres with no header line.

    No Output:
    Uses the function vincdir to calculate for each row in the csv file the
    geographic coordinate (lat, long) of Point 2 and the Azimuth from Point 2
    to Point 1, all in Degrees Minutes Seconds. This data is written to a new
    file with the name <inputfile>_out.csv
    """
    # Enter Filename
    fn = input('Enter co-ordinate file:\n')
    # Open Filename
    csvfile = open(fn)
    csvreader = csv.reader(csvfile)
    # Create Output File
    fn_part = (os.path.splitext(fn))
    fn_out = fn_part[0] + '_out' + fn_part[1]
    outfile = open(fn_out, 'w')
    # Write Output
    outfilewriter = csv.writer(outfile)
    # outfilewriter.writerow(['Latitude2', 'Longitude2', 'azimuth2to1'])
    for row in csvreader:
        lat1 = dms2dd(float(row[0]))
        long1 = dms2dd(float(row[1]))
        azimuth1to2 = dms2dd(float(row[2]))
        ell_dist = float(row[3])
        lat2, long2, azimuth2to1 = vincdir(lat1, long1, azimuth1to2, ell_dist)
        lat2 = dd2dms(lat2)
        long2 = dd2dms(long2)
        azimuth2to1 = dd2dms(azimuth2to1)
        output = [lat2, long2, azimuth2to1]
        outfilewriter.writerow(output)
    # Close Files
    outfile.close()
    csvfile.close()
Exemple #7
0
def geo2gridio():
    """
    No Input:
    Prompts the user for the name of a file in csv format. Data in the file
    must be in the form Point ID, Latitude, Longitude in Decimal Degrees with
    no header line.

    No Output:
    Uses the function geo2grid to convert each row in the csv file into a
    coordinate with UTM Zone, Easting (m), Northing (m). This data is written
    to a new file with the name <inputfile>_out.csv
    """
    # Enter Filename
    print('Enter co-ordinate file:')
    fn = input()
    # Open Filename
    csvfile = open(fn)
    csvreader = csv.reader(csvfile)
    # Create Output File
    fn_part = (os.path.splitext(fn))
    fn_out = fn_part[0] + '_out' + fn_part[1]
    outfile = open(fn_out, 'w')
    # Write Output
    outfilewriter = csv.writer(outfile)
    # Optional Header Row
    # outfilewriter.writerow(['Pt', 'Zone', 'Easting', 'Northing', 'Point Scale Factor', 'Grid Convergence'])
    for row in csvreader:
        pt_num = row[0]
        lat = dms2dd(float(row[1]))
        long = dms2dd(float(row[2]))
        # Calculate Conversion
        hemisphere, zone, east, north, psf, grid_conv = geo2grid(lat, long)
        grid_conv = dms2dd(grid_conv)
        output = [pt_num] + [hemisphere, zone, east, north, psf, grid_conv]
        outfilewriter.writerow(output)
    # Close Files
    outfile.close()
    csvfile.close()
 def test_dms2dd(self):
     self.assertAlmostEqual(dec_ex, dms2dd(hp_ex), 9)
     self.assertAlmostEqual(-dec_ex, dms2dd(-hp_ex), 9)
Exemple #9
0
#!/usr/bin/env python3
"""
Geoscience Australia - Python Geodesy Package
Geoid Module

In Development
"""

import numpy as np
from scipy import interpolate
from geodepy.convert import dms2dd

# Define test grid points
nvals = np.array([(dms2dd(-31.51), dms2dd(133.48), -8.806),
                  (dms2dd(-31.51), dms2dd(133.49), -8.743),
                  (dms2dd(-31.52), dms2dd(133.48), -8.870),
                  (dms2dd(-31.52), dms2dd(133.49), -8.805)])

lat = dms2dd(-31.515996736)
long = dms2dd(133.483540489)
Exemple #10
0
        # Write Output
        with open(fn_out, 'w', newline='') as outfile:
            outfilewriter = csv.writer(outfile)

            #Header row will be written if 1 is passed to the headerout input variable
            if headerout == 1:
                outfilewriter.writerow(['Pt', 'Hemisphere', 'Zone', 'Easting', 'Northing', 'Point Scale Factor', 'Grid Convergence'])

            # Selects converstion to DD if required
            for row in csvreader:
                pt_num = row[0]
                if geotypein.get() == 'DD':
                    lat = (float(row[1]))
                    long = (float(row[2]))
                elif geotypein.get() == 'DMS':
                    lat = dms2dd(float(row[1]))
                    long = dms2dd(float(row[2]))
                elif geotypein.get() == 'HP':
                    lat = hp2dec(float(row[1]))
                    long = hp2dec(float(row[2]))

                # Calculate Conversion
                hemisphere, zone, east, north, psf, grid_conv = geo2grid(lat, long)
                grid_conv = dms2dd(grid_conv)
                output = [pt_num] + [hemisphere, zone, east, north, psf, grid_conv]
                outfilewriter.writerow(output)
=======
    # Enter Filename
    print('Enter co-ordinate file:')
    fn = input()
    # Open Filename