Module nemo.polygons

Support code for the 43 polygons of the AEMO study.

Functions

def dist(poly1, poly2)
Expand source code
def dist(poly1, poly2):
    """Return the distance between two polygon centroids.

    >>> dist(1,1)
    0
    >>> dist(1,43)
    2910
    >>> assert dist(1,43) == distances[1,43]
    """
    # Code adapted from Chris Veness
    # pylint: disable=invalid-name
    radius = 6371  # km
    point1 = centroids[poly1]
    point2 = centroids[poly2]
    dlat = radians(point1[0] - point2[0])
    dlon = radians(point1[1] - point2[1])
    lat1 = radians(point1[0])
    lat2 = radians(point2[0])
    a = sin(dlat / 2) ** 2 + \
        sin(dlon / 2) ** 2 * cos(lat1) * cos(lat2)
    c = 2 * atan2(sqrt(a), sqrt(1 - a))
    return int(radius * c)

Return the distance between two polygon centroids.

>>> dist(1,1)
0
>>> dist(1,43)
2910
>>> assert dist(1,43) == distances[1,43]
def region(polygon)
Expand source code
def region(polygon):
    """Return the region a polygon resides in.

    >>> region(1)
    QLD1
    >>> region(40)
    TAS1
    """
    return _region_table[polygon]

Return the region a polygon resides in.

>>> region(1)
QLD1
>>> region(40)
TAS1