コード例 #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 = hp2dec(float(row[0]))
        long1 = hp2dec(float(row[1]))
        lat2 = hp2dec(float(row[2]))
        long2 = hp2dec(float(row[3]))
        ell_dist, azimuth1to2, azimuth2to1 = vincinv(lat1, long1, lat2, long2)
        azimuth1to2 = dec2hp(azimuth1to2)
        azimuth2to1 = dec2hp(azimuth2to1)
        output = (ell_dist, azimuth1to2, azimuth2to1)
        outfilewriter.writerow(output)
    # Close Files
    outfile.close()
    csvfile.close()
コード例 #2
0
    def test_vincdir_utm(self):
        # Flinders Peak (UTM 55)
        zone1 = 55
        east1 = 273741.2966
        north1 = 5796489.7769
        # Grid Dimensions to Point 2 (Buninyong)
        grid_dist = 54992.279
        grid1to2 = hp2dec(305.17017259)
        grid1to2_DMS = DMSAngle(305, 17, 1.7259)

        # Test Decimal Degrees Input
        (zone2, east2, north2, grid2to1,
         lsf) = vincdir_utm(zone1, east1, north1, grid1to2, grid_dist)
        self.assertEqual(zone2, zone1)
        self.assertAlmostEqual(east2, 228854.0513, 3)
        self.assertAlmostEqual(north2, 5828259.0384, 3)
        self.assertAlmostEqual(dec2hp(grid2to1), 125.17418518, 7)
        self.assertAlmostEqual(lsf, 1.00036397, 8)

        # Test DMSAngle Input
        (zone2, east2, north2, grid2to1,
         lsf) = vincdir_utm(zone1, east1, north1, grid1to2_DMS, grid_dist)
        self.assertEqual(zone2, zone1)
        self.assertAlmostEqual(east2, 228854.0513, 3)
        self.assertAlmostEqual(north2, 5828259.0384, 3)
        self.assertAlmostEqual(dec2hp(grid2to1), 125.17418518, 7)
        self.assertAlmostEqual(lsf, 1.00036397, 8)
コード例 #3
0
    def test_vincinv_utm(self):
        # Flinders Peak (UTM 55)
        zone1 = 55
        east1 = 273741.2966
        north1 = 5796489.7769
        # Buninyong (UTM 55)
        zone2 = 55
        east2 = 228854.0513
        north2 = 5828259.0384
        # Buninyong (UTM 54)
        zone3 = 54
        east3 = 758173.7973
        north3 = 5828674.3402

        # Test Coordinates in Zone 55 only
        grid_dist, grid1to2, grid2to1, lsf = vincinv_utm(
            zone1, east1, north1, zone2, east2, north2)
        self.assertAlmostEqual(lsf, 1.00036397, 8)
        self.assertAlmostEqual(grid_dist, 54992.279, 3)
        self.assertAlmostEqual(dec2hp(grid1to2), 305.17017259, 7)
        self.assertAlmostEqual(dec2hp(grid2to1), 125.17418518, 7)

        # Test Coordinates in Different Zones (55 and 54)
        # (Point 2 Grid Bearing Different (Zone 54 Grid Bearing))
        grid_dist, grid1to2, grid2to1, lsf = vincinv_utm(
            zone1, east1, north1, zone3, east3, north3)
        self.assertAlmostEqual(lsf, 1.00036397, 8)
        self.assertAlmostEqual(grid_dist, 54992.279, 3)
        self.assertAlmostEqual(dec2hp(grid1to2), 305.17017259, 7)
        self.assertAlmostEqual(dec2hp(grid2to1), 128.57444307, 7)
コード例 #4
0
    def test_vincdir(self):
        # Flinders Peak
        lat1 = hp2dec(-37.57037203)
        lon1 = hp2dec(144.25295244)
        lat1_DMS = DMSAngle(-37, 57, 3.7203)
        lon1_DMS = DMSAngle(144, 25, 29.5244)

        # To Buninyong
        azimuth1to2 = hp2dec(306.520537)
        azimuth1to2_DMS = DMSAngle(306, 52, 5.37)
        ell_dist = 54972.271

        # Test Decimal Degrees Input
        lat2, lon2, azimuth2to1 = vincdir(lat1, lon1, azimuth1to2, ell_dist)
        self.assertEqual(round(dec2hp(lat2), 8), -37.39101561)
        self.assertEqual(round(dec2hp(lon2), 8), 143.55353839)
        self.assertEqual(round(dec2hp(azimuth2to1), 6), 127.102507)

        # Test DMSAngle Input
        lat2, long2, azimuth2to1 = vincdir(lat1_DMS, lon1_DMS, azimuth1to2_DMS,
                                           ell_dist)
        self.assertEqual(round(dec2hp(lat2), 8), -37.39101561)
        self.assertEqual(round(dec2hp(long2), 8), 143.55353839)
        self.assertEqual(round(dec2hp(azimuth2to1), 6), 127.102507)

        # Test DDMAngle Input
        lat2, long2, azimuth2to1 = vincdir(lat1_DMS.ddm(), lon1_DMS.ddm(),
                                           azimuth1to2_DMS.ddm(), ell_dist)
        self.assertEqual(round(dec2hp(lat2), 8), -37.39101561)
        self.assertEqual(round(dec2hp(long2), 8), 143.55353839)
        self.assertEqual(round(dec2hp(azimuth2to1), 6), 127.102507)
コード例 #5
0
ファイル: test_geodesy.py プロジェクト: SGV-Geodesy/GeodePy
 def test_vincdir(self):
     # Flinders Peak
     lat1 = hp2dec(-37.57037203)
     long1 = hp2dec(144.25295244)
     # To Buninyong
     azimuth1to2 = hp2dec(306.520537)
     ell_dist = 54972.271
     lat2, long2, azimuth2to1 = vincdir(lat1, long1, azimuth1to2, ell_dist)
     self.assertEqual(round(dec2hp(lat2), 8), -37.39101561)
     self.assertEqual(round(dec2hp(long2), 8), 143.55353839)
     self.assertEqual(round(dec2hp(azimuth2to1), 6), 127.102507)
コード例 #6
0
ファイル: test_geodesy.py プロジェクト: shresthasamir/GeodePy
 def test_vincinv(self):
     # Flinders Peak
     lat1 = hp2dec(-37.57037203)
     long1 = hp2dec(144.25295244)
     # Buninyong
     lat2 = hp2dec(-37.39101561)
     long2 = hp2dec(143.55353839)
     ell_dist, azimuth1to2, azimuth2to1 = vincinv(lat1, long1, lat2, long2)
     self.assertEqual(round(ell_dist, 3), 54972.271)
     self.assertEqual(round(dec2hp(azimuth1to2), 6), 306.520537)
     self.assertEqual(round(dec2hp(azimuth2to1), 6), 127.102507)
コード例 #7
0
ファイル: test_geodesy.py プロジェクト: j-pickford/GeodePy
 def test_vincinv_utm(self):
     # Flinders Peak (UTM)
     zone1 = 55
     east1 = 273741.2966
     north1 = 5796489.7769
     # Buninyong (UTM)
     zone2 = 54
     east2 = 758173.7973
     north2 = 5828674.3402
     ell_dist, azimuth1to2, azimuth2to1 = vincinv_utm(zone1, east1, north1, zone2, east2, north2)
     self.assertEqual(round(ell_dist, 3), 54972.271)
     self.assertEqual(round(dec2hp(azimuth1to2), 6), 306.520537)
     self.assertEqual(round(dec2hp(azimuth2to1), 6), 127.102507)
コード例 #8
0
ファイル: ski-ascii.py プロジェクト: tengkunuddin/PynAdjust
def stn2xml(skiasciifile):
    # Create dynaxml root object
    stnroot = dnaxmlroot('stn')
    # Read ski-ascii text, list stations and separate variables by ':'
    stnlines = []
    with open(skiasciifile) as myfile:
        for line in myfile.readlines():
            stnlines.append(line)
    for num, i in enumerate(stnlines):
        stnlines[num] = i.split(' ')
        stnlines[num] = list(filter(None, stnlines[num]))
    # Write station list components to xml
    linebatchdict = {}
    linebatch = 0
    namelist = []
    # Station constants
    constraint = 'FFF'
    coordtype = 'LLH'
    for line in stnlines:
        linetype = line[0][0:2]
        if line[0] == "@%Coordinate":
            outputformat = line[2].rstrip()
        if linetype == '@#':
            # Start of data & station coordinates
            name = line[0][2:]
            llh = xyz2llh(float(line[1]), float(line[2]), float(line[3]))
            xaxis = str(dec2hp(float(llh[0])))
            yaxis = str(dec2hp(float(llh[1])))
            height = str(round(llh[2], 4))
            gridcoords = geo2grid(llh[0], llh[1])
            zone = gridcoords[0][0] + str(gridcoords[1])
            desc = line[0][2:] + ', ?, ?'
            linebatch += 1
            # Add station coordinates, takes only one approximate coordinate
            # Code will only take if output format is Cartesian
            if linebatch >= 1:
                if outputformat == 'Cartesian' and name not in namelist:
                    stnroot = addstnrecord(stnroot, name, constraint,
                                           coordtype, xaxis, yaxis, height,
                                           zone, desc)
                    namelist.append(line[0][2:])
        if linebatch in linebatchdict:
            linebatchdict[linebatch].append(line)
        else:
            linebatchdict[linebatch] = [line]

    return stnroot
コード例 #9
0
def dd2hms(dd_ang, ds):
    #Input: DD.ddddd used by Geolab
    #Output: HH MM SS.sssss used by DynAdjust
    hp_ang = dec2hp(dd_ang)
    h = int(hp_ang)
    dec_m = (hp_ang - h) * 100
    m = int(dec_m)
    s = (dec_m - m) * 100
    return '{:} {:>2} {:>3}'.format(h, m, round(s, ds))
コード例 #10
0
    def test_vincinv(self):
        # Flinders Peak
        lat1 = hp2dec(-37.57037203)
        lon1 = hp2dec(144.25295244)
        lat1_DMS = DMSAngle(-37, 57, 3.7203)
        lon1_DMS = DMSAngle(144, 25, 29.5244)

        # Buninyong
        lat2 = hp2dec(-37.39101561)
        lon2 = hp2dec(143.55353839)
        lat2_DMS = DMSAngle(-37, 39, 10.1561)
        lon2_DMS = DMSAngle(143, 55, 35.3839)

        # Test Decimal Degrees Input
        ell_dist, azimuth1to2, azimuth2to1 = vincinv(lat1, lon1, lat2, lon2)
        self.assertEqual(round(ell_dist, 3), 54972.271)
        self.assertEqual(round(dec2hp(azimuth1to2), 6), 306.520537)
        self.assertEqual(round(dec2hp(azimuth2to1), 6), 127.102507)

        # additional test case:
        pl1 = (-29.85, 140.71666666666667)
        pl2 = (-29.85, 140.76666666666667)
        ell_dist, azimuth1to2, azimuth2to1 = vincinv(pl1[0], pl1[1], pl2[0],
                                                     pl2[1])
        self.assertEqual(round(ell_dist, 3), 4831.553)
        self.assertEqual(round(dec2hp(azimuth1to2), 6), 90.004480)
        self.assertEqual(round(dec2hp(azimuth2to1), 6), 269.591520)

        test2 = vincinv(lat1, lon1, lat1, lon1)
        self.assertEqual(test2, (0, 0, 0))

        # Test DMSAngle Input
        ell_dist, azimuth1to2, azimuth2to1 = vincinv(lat1_DMS, lon1_DMS,
                                                     lat2_DMS, lon2_DMS)
        self.assertEqual(round(ell_dist, 3), 54972.271)
        self.assertEqual(round(dec2hp(azimuth1to2), 6), 306.520537)
        self.assertEqual(round(dec2hp(azimuth2to1), 6), 127.102507)

        test2 = vincinv(lat1_DMS, lon1_DMS, lat1_DMS, lon1_DMS)
        self.assertEqual(test2, (0, 0, 0))

        # Test DDMAngle Input
        (ell_dist, azimuth1to2, azimuth2to1) = vincinv(lat1_DMS.ddm(),
                                                       lon1_DMS.ddm(),
                                                       lat2_DMS.ddm(),
                                                       lon2_DMS.ddm())
        self.assertEqual(round(ell_dist, 3), 54972.271)
        self.assertEqual(round(dec2hp(azimuth1to2), 6), 306.520537)
        self.assertEqual(round(dec2hp(azimuth2to1), 6), 127.102507)

        test2 = vincinv(lat1_DMS.ddm(), lon1_DMS.ddm(), lat1_DMS.ddm(),
                        lon1_DMS.ddm())
        self.assertEqual(test2, (0, 0, 0))
コード例 #11
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 = dec2hp(lat)
        long = dec2hp(long)
        grid_conv = dec2hp(grid_conv)
        output = [pt_num, lat, long, psf, grid_conv]
        outfilewriter.writerow(output)
    # Close Files
    outfile.close()
    csvfile.close()
コード例 #12
0
ファイル: test_geodesy.py プロジェクト: j-pickford/GeodePy
    def test_vincdir_utm(self):
        # Flinders Peak (UTM)
        zone1 = 55
        east1 = 273741.2966
        north1 = 5796489.7769
        # To Buninyong
        azimuth1to2 = hp2dec(306.520537)
        azimuth1to2_DMS = DMSAngle(306, 52, 5.37)

        ell_dist = 54972.271

        # Test Decimal Degrees Input
        (hemisphere2, zone2, east2,
         north2, azimuth2to1) = vincdir_utm(zone1, east1, north1,
                                            azimuth1to2, ell_dist)
        self.assertEqual(hemisphere2, 'South')
        self.assertEqual(zone2, 54)
        self.assertEqual(round(east2, 4), 758173.7968)
        self.assertEqual(round(north2, 4), 5828674.3395)
        self.assertEqual(round(dec2hp(azimuth2to1), 6), 127.102507)

        # Test DMSAngle Input
        (hemisphere2, zone2, east2,
         north2, azimuth2to1) = vincdir_utm(zone1, east1, north1,
                                            azimuth1to2_DMS, ell_dist)
        self.assertEqual(hemisphere2, 'South')
        self.assertEqual(zone2, 54)
        self.assertEqual(round(east2, 4), 758173.7968)
        self.assertEqual(round(north2, 4), 5828674.3395)
        self.assertEqual(round(dec2hp(azimuth2to1), 6), 127.102507)

        # Test DDMAngle Input
        (hemisphere2, zone2, east2,
         north2, azimuth2to1) = vincdir_utm(zone1, east1, north1,
                                            azimuth1to2_DMS.ddm(), ell_dist)
        self.assertEqual(hemisphere2, 'South')
        self.assertEqual(zone2, 54)
        self.assertEqual(round(east2, 4), 758173.7968)
        self.assertEqual(round(north2, 4), 5828674.3395)
        self.assertEqual(round(dec2hp(azimuth2to1), 6), 127.102507)
コード例 #13
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 = hp2dec(float(row[0]))
        long1 = hp2dec(float(row[1]))
        azimuth1to2 = hp2dec(float(row[2]))
        ell_dist = float(row[3])
        lat2, long2, azimuth2to1 = vincdir(lat1, long1, azimuth1to2, ell_dist)
        lat2 = dec2hp(lat2)
        long2 = dec2hp(long2)
        azimuth2to1 = dec2hp(azimuth2to1)
        output = [lat2, long2, azimuth2to1]
        outfilewriter.writerow(output)
    # Close Files
    outfile.close()
    csvfile.close()
コード例 #14
0
ファイル: tdef.py プロジェクト: tengkunuddin/PynAdjust
def stn2xml(tdeffile):
    # Read tdef Projection Zone
    with open(tdeffile) as myfile:
        for line in myfile.readlines():
            if line.startswith('ProjCoordinateZone'):
                zone = line[-3:-1]
    # Create dynaxml root object
    stnroot = dnaxmlroot('stn')
    # Read tdef text, list stations and separate variables by ':'
    stnlines = []
    with open(tdeffile) as myfile:
        for line in myfile.readlines():
            if line.startswith('Station'):
                stnlines.append(line)
    for num, i in enumerate(stnlines):
        stnlines[num] = i.split(':')
    # Write station list components to xml
    for stn in stnlines:
        name = stn[2]
        constraint = 'FFF'
        coordtype = 'LLH'
        # Convert Lats and Lons based on last character
        # convert to ddd.mmssss notation
        if stn[3][-1:] == 'S':
            xaxis = '-' + str(dec2hp(float(stn[3][:-1])))
            hemi = 'S'
        elif stn[3][-1:] == 'N':
            xaxis = str(dec2hp(float(stn[3][:-1])))
            hemi = 'N'
        if stn[4][-1:] == 'W':
            yaxis = '-' + str(dec2hp(float(stn[4][:-1])))
        elif stn[4][-1:] == 'E':
            yaxis = str(dec2hp(float(stn[4][:-1])))
        height = stn[5]
        desc = stn[2] + ', ?, ?'
        stnroot = addstnrecord(stnroot, name, constraint, coordtype,
                               xaxis, yaxis, height, hemi + zone, desc)

    return stnroot
コード例 #15
0
ファイル: test_geodesy.py プロジェクト: nich0lasbr0wn/GeodePy
 def test_vincdir_utm(self):
     # Flinders Peak (UTM)
     zone1 = 55
     east1 = 273741.2966
     north1 = 5796489.7769
     # To Buninyong
     azimuth1to2 = hp2dec(306.520537)
     ell_dist = 54972.271
     hemisphere2, zone2, east2, north2, azimuth2to1 = vincdir_utm(zone1, east1, north1, azimuth1to2, ell_dist)
     self.assertEqual(hemisphere2, 'South')
     self.assertEqual(zone2, 54)
     self.assertEqual(round(east2, 4), 758173.7968)
     self.assertEqual(round(north2, 4), 5828674.3395)
     self.assertEqual(round(dec2hp(azimuth2to1), 6), 127.102507)
コード例 #16
0
ファイル: survey.py プロジェクト: shresthasamir/GeodePy
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 - hp2dec(verta_hp))
        elif 180 < verta_hp < 360:
            verta = radians(270 - hp2dec(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 = dec2hp(degrees(verta_pt) + 90)
    return verta_pt_hp, slope_dist_pt, hz_dist, delta_ht
コード例 #17
0
ファイル: test_convert.py プロジェクト: jmettes/GeodePy
 def test_dec2hp(self):
     self.assertAlmostEqual(hp_ex, dec2hp(dec_ex), 13)
     self.assertAlmostEqual(-hp_ex, dec2hp(-dec_ex), 13)
コード例 #18
0
        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])
        east = float(row[2])
        north = float(row[3])
        # Calculate Conversion