Beispiel #1
0
def reverse_proj_from_dll(outdir, condor_path, landscape, nx, ny, flag_show):
    navicon_dll = init_navicon_dll(condor_path, landscape)
    max_x, max_y = navicon_dll.GetMaxX(), navicon_dll.GetMaxY()

    P = {}
    P[0] = (0, 0)
    P[1] = (max_x, 0)
    P[2] = (0, max_y)
    P[3] = (max_x, max_y)

    d_df = {}

    s = "ref"

    d_df[s] = pd.DataFrame(index=np.arange(4),
                           columns=["PosX", "PosY", "Lat", "Lon"])

    for i in d_df[s].index:
        x, y = P[i][0], P[i][1]
        d_df[s]["PosX"][i] = x
        d_df[s]["PosY"][i] = y
        d_df[s]["Lat"][i] = navicon_dll.XYToLat(x, y)
        d_df[s]["Lon"][i] = navicon_dll.XYToLon(x, y)

    a_x = np.linspace(0, max_x, nx)
    a_y = np.linspace(0, max_y, ny)
    values = cartesian([a_x, a_y])

    s = "measures"
    d_df[s] = pd.DataFrame(values, columns=["PosX", "PosY"])
    d_df[s]["Lat"] = np.nan
    d_df[s]["Lon"] = np.nan

    for i in d_df[s].index:
        x = d_df[s]["PosX"][i]
        y = d_df[s]["PosY"][i]
        d_df[s]["Lat"][i] = navicon_dll.XYToLat(x, y)
        d_df[s]["Lon"][i] = navicon_dll.XYToLon(x, y)

    #print(d_df["ref"])
    #print(d_df["measures"])

    print("""ref:
%s

measures:
%s""" % (d_df["ref"], d_df["measures"]))

    filename_out = os.path.join(outdir, "geodesic_%s.xlsx" % landscape)
    print("Output '%s'" % filename_out)
    with pd.ExcelWriter(filename_out) as writer:
        key = "ref"
        d_df[key].to_excel(writer, sheet_name=key)
        key = "measures"
        d_df[key].to_excel(writer, sheet_name=key)

    plot_geodesic(outdir, landscape, d_df["measures"])
    if flag_show:
        plt.show()
def reverse_proj_from_dll(outdir, condor_path, landscape, nx, ny, flag_show):
    navicon_dll = init_navicon_dll(condor_path, landscape)
    max_x, max_y = navicon_dll.GetMaxX(), navicon_dll.GetMaxY()

    P = {}
    P[0] = (0, 0)
    P[1] = (max_x, 0)
    P[2] = (0, max_y)
    P[3] = (max_x, max_y)
    
    d_df = {}

    s = "ref"
    
    d_df[s] = pd.DataFrame(index=np.arange(4), columns=["PosX", "PosY", "Lat", "Lon"])
    
    for i in d_df[s].index:
        x,y = P[i][0], P[i][1]
        d_df[s]["PosX"][i] = x
        d_df[s]["PosY"][i] = y
        d_df[s]["Lat"][i] = navicon_dll.XYToLat(x, y)
        d_df[s]["Lon"][i] = navicon_dll.XYToLon(x, y)
    
    a_x = np.linspace(0, max_x, nx)
    a_y = np.linspace(0, max_y, ny)
    values = cartesian([a_x, a_y])
    
    s = "measures"
    d_df[s] = pd.DataFrame(values, columns=["PosX", "PosY"])
    d_df[s]["Lat"] = np.nan
    d_df[s]["Lon"] = np.nan
    
    for i in d_df[s].index:
        x = d_df[s]["PosX"][i]
        y = d_df[s]["PosY"][i]
        d_df[s]["Lat"][i] = navicon_dll.XYToLat(x, y)
        d_df[s]["Lon"][i] = navicon_dll.XYToLon(x, y)

    #print(d_df["ref"])
    #print(d_df["measures"])

    print("""ref:
%s

measures:
%s""" % (d_df["ref"], d_df["measures"]))
    
    filename_out = os.path.join(outdir, "geodesic_%s.xlsx" % landscape)
    print("Output '%s'" % filename_out)
    with pd.ExcelWriter(filename_out) as writer:
        key = "ref"
        d_df[key].to_excel(writer, sheet_name=key)
        key = "measures"
        d_df[key].to_excel(writer, sheet_name=key)
        
    plot_geodesic(outdir, landscape, d_df["measures"])
    if flag_show:
        plt.show()
def main(xls_filename, outdir):
    basepath = os.path.dirname(__file__)
    #basepath = os.path.dirname(os.path.abspath(__file__))
    if outdir=='':
        outdir = os.path.join(basepath, 'out')
    
    #xls_filename = os.path.join(outdir, "Provence-Oisans2.xlsx")

    filename_base, filename_ext = os.path.splitext(os.path.basename(xls_filename))

    d_df = {}
    d_df = pd.read_excel(xls_filename, sheetname=None)

    max_x, max_y = d_df['ref']['PosX'].max(), d_df['ref']['PosY'].max()
    print "max_x=%s, max_y=%s" % (max_x, max_y)

    p = pyproj.Proj(
        proj='utm',
        zone=32,
        ellps='WGS84'
    )

    d_df['measures']['PosX2'] = np.nan
    d_df['measures']['PosY2'] = np.nan

    for i, point in d_df['measures'].iterrows():
        xy2 = p(point['Lat'], point['Lon'])
        d_df['measures']['PosX2'][i] = xy2[0]
        d_df['measures']['PosY2'][i] = xy2[1]
        #print(xy2)

    d_df['measures']['Eps'] = np.sqrt(
        (d_df['measures']['PosX2'] - d_df['measures']['PosX'])**2 + \
        (d_df['measures']['PosY2'] - d_df['measures']['PosY'])**2
    )

    print(d_df)
    print(d_df['measures']['Eps'].mean())

    plot_geodesic(outdir, filename_base, d_df['measures'])
    plt.show()
Beispiel #4
0
def main(xls_filename, outdir):
    basepath = os.path.dirname(__file__)
    #basepath = os.path.dirname(os.path.abspath(__file__))
    if outdir == '':
        outdir = os.path.join(basepath, 'out')

    #xls_filename = os.path.join(outdir, "Provence-Oisans2.xlsx")

    filename_base, filename_ext = os.path.splitext(
        os.path.basename(xls_filename))

    d_df = {}
    d_df = pd.read_excel(xls_filename, sheetname=None)

    max_x, max_y = d_df['ref']['PosX'].max(), d_df['ref']['PosY'].max()
    print "max_x=%s, max_y=%s" % (max_x, max_y)

    p = pyproj.Proj(proj='utm', zone=32, ellps='WGS84')

    d_df['measures']['PosX2'] = np.nan
    d_df['measures']['PosY2'] = np.nan

    for i, point in d_df['measures'].iterrows():
        xy2 = p(point['Lat'], point['Lon'])
        d_df['measures']['PosX2'][i] = xy2[0]
        d_df['measures']['PosY2'][i] = xy2[1]
        #print(xy2)

    d_df['measures']['Eps'] = np.sqrt(
        (d_df['measures']['PosX2'] - d_df['measures']['PosX'])**2 + \
        (d_df['measures']['PosY2'] - d_df['measures']['PosY'])**2
    )

    print(d_df)
    print(d_df['measures']['Eps'].mean())

    plot_geodesic(outdir, filename_base, d_df['measures'])
    plt.show()