示例#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()
示例#2
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)
示例#3
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)
示例#4
0
def grid2geoio():
    """
    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, UTM Zone, Easting (m), Northing (m) with
    no header line.

    No Output:
    Uses the function grid2geo to convert each row in the csv file into a
    latitude and longitude in Degrees, Minutes and Seconds. This data is
    written to a new file with the name <inputfile>_out.csv
    """
    # Enter Filename
    print('Enter co-ordinate file (\.csv)\:')
    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', 'Latitude', 'Longitude', 'Point Scale Factor', 'Grid Convergence'])
    for row in csvreader:
        pt_num = row[0]
        zone = float(row[1])
        east = float(row[2])
        north = float(row[3])
        # Calculate Conversion
        lat, long, psf, grid_conv = grid2geo(zone, east, north)
        lat = dd2dms(lat)
        long = dd2dms(long)
        grid_conv = dd2dms(grid_conv)
        output = [pt_num, lat, long, psf, grid_conv]
        outfilewriter.writerow(output)
    # Close Files
    outfile.close()
    csvfile.close()
示例#5
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()
示例#6
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
示例#7
0
 def test_dd2dms(self):
     self.assertEqual(hp_ex, dd2dms(dec_ex))
     self.assertEqual(-hp_ex, dd2dms(-dec_ex))
示例#8
0
            outfilewriter.writerow(
                ['pt', 'Latitude', 'Longitude', 'Point Scale Factor', 'Grid Convergence'])

        for row in csvreader:
            pt_num = row[0]
            zone = float(row[1])
            east = float(row[2])
            north = float(row[3])
            # Calculate Conversion
            lat, long, psf, grid_conv = grid2geo(zone, east, north)
            # Selects output format of Lat and Long
            if geotypeout.get() == 'DD':
                lat = lat
                long = long
            elif geotypeout.get() == 'DMS':
                lat = dd2dms(lat)
                long = dd2dms(long)
            elif geotypeout.get() == 'HP':
                lat = dec2hp(lat)
                long = dec2hp(long)

            grid_conv = dd2dms(grid_conv)
            output = [pt_num, lat, long, psf, grid_conv]
            outfilewriter.writerow(output)
=======
    outfilewriter = csv.writer(outfile)
    # Optional Header Row
    # outfilewriter.writerow(['Pt', 'Latitude', 'Longitude', 'Point Scale Factor', 'Grid Convergence'])
    for row in csvreader:
        pt_num = row[0]
        zone = float(row[1])