Beispiel #1
0
def edge_length(wed, half=False):
    """
    Compute the cartesian length of all edges.  This is a helper
        function to allow for ratio data with spatial autocorrelation
        analysis.

    Parameters
    ----------
    wed: PySAL Winged Edged Data structure
    half: Double edge length by default, flag to set to single

    Returns
    -------
    length : dict {tuple(edge): float(length)}
        The length of each edge.
    """

    lengths = {}
    for edge in wed.edge_list:
        if half:
            if (edge[1], edge[0]) not in lengths.keys():
                lengths[edge] = get_points_dist(wed.node_coords[edge[0]],
                                                wed.node_coords[edge[1]])
        else:
            lengths[edge] = get_points_dist(wed.node_coords[edge[0]],
                                            wed.node_coords[edge[1]])
    return lengths
Beispiel #2
0
def edge_length(wed, half=False):
    """
    Compute the cartesian length of all edges.  This is a helper
        function to allow for ratio data with spatial autocorrelation
        analysis.

    Parameters
    ----------
    wed: PySAL Winged Edged Data structure
    half: Double edge length by default, flag to set to single

    Returns
    -------
    length : dict {tuple(edge): float(length)}
        The length of each edge.
    """

    lengths = {}
    for edge in wed.edge_list:
        if half:
            if (edge[1], edge[0]) not in lengths.keys():
                lengths[edge] = get_points_dist(wed.node_coords[edge[0]],
                                                wed.node_coords[edge[1]])
        else:
            lengths[edge] = get_points_dist(wed.node_coords[edge[0]],
                                            wed.node_coords[edge[1]])
    return lengths
Beispiel #3
0
def edge_length(wed):
    """
    Compute the cartesian length of all edges.  This is a helper
        function to allow for ratio data with spatial autocorrelation
        analysis.

    Parameters
    ----------
    None

    Returns
    -------
    length : dict {tuple(edge): float(length)}
        The length of each edge.
    """

    lengths = {}
    for edge in wed.edge_list:
        lengths[edge] = get_points_dist(wed.node_coords[edge[0]],
                                        wed.node_coords[edge[1]])
    return lengths
Beispiel #4
0
def edge_length(wed):
    """
    Compute the cartesian length of all edges.  This is a helper
        function to allow for ratio data with spatial autocorrelation
        analysis.

    Parameters
    ----------
    None

    Returns
    -------
    length : dict {tuple(edge): float(length)}
        The length of each edge.
    """

    lengths = {}
    for edge in wed.edge_list:
        lengths[edge] = get_points_dist(wed.node_coords[edge[0]],
                                        wed.node_coords[edge[1]])
    return lengths