tracktable.info.borders module

Module contents

class tracktable.info.borders.Border(resolution='low', level='L1')[source]

Bases: object

Information about a single border

resolution

Fidelity of the given shape

Type:

str

level

Hierarchical level that contains specific information, see the build_border_dict() docstring for more information

Type:

str

polygon

Shapely polygon generated from the points of the given shape

Type:

Shapely Polygon

global_bbox

Lower left and upper right coordinates for the bounding box that encompasses all shapes from the loaded shapefile

Type:

list

shape_bbox

Lower left and upper right coordinates for the bounding box of the given shape in [lon,lat,lon,lat] format

Type:

list

shape_centroid

Center point or centroid for the given shape

Type:

tuple

geojson

GeoJSON formated point information for the given shape

Type:

dict

points

Non-GeoJSON formated point information for the given shape

Type:

list(tuple)

tracktable.info.borders.all_borders(resolution='low', level='L1')[source]

Return all the river records at the given level and resolution.

Keyword Arguments:
  • resolution (string) – Resolution of the shapes to pull from the shapefile. (Default: “low”)

  • level (string) – See the docstring for build_river_dict() for more information about levels. (Default: “L1”)

Returns:

List of river objects.

Raises:

ValueError – Unknown resolution or level

tracktable.info.borders.all_borders_within_bounding_box(bounding_box, resolution='low', level='L1')[source]

Return all the river records that exist in the given given bounding box.

Parameters:

bounding_box (Bounding Box) – Bounding box to return all river from.

Keyword Arguments:
  • resolution (string) – Resolution of the shapes to pull from the shapefile. (Default: “low”)

  • level (string) – See the docstring for build_river_dict() for more information about levels. (Default: “L1”)

Returns:

Dictionary of rivers from the given bounding box.

Raises:

ValueError – Unknown resolution or level

tracktable.info.borders.border_information(index, resolution='low', level='L1')[source]

Retrieve a specific river shape’s information. Shapes are sorted from largest to smallest.

Parameters:

index (int) – Index of the desired river to retrieve information for.

Keyword Arguments:
  • resolution (string) – Resolution of the shapes to pull from the shapefile. (Default: “low”)

  • level (string) – See the docstring for build_river_dict() for more information about levels. (Default: “L1”)

Returns:

River object at the specified index, resolution and level.

Raises:
tracktable.info.borders.buffer(points, buffer=10)[source]

Return a buffered polygon for the given set of points.

Parameters:

points (Shapely Points) – Bounding box to return all river from.

Keyword Arguments:

buffer (int) – Distance to buffer in km. (Default: 10)

Returns:

Buffered polygon.

tracktable.info.borders.build_border_dict(resolution='low', level='L1')[source]

Assemble the border dictionary on first access

This function is called whenever the user tries to look up an border. It checks to make sure the table has been populated and, if not, loads it from disk.

The geography data come in five resolutions: - full resolution: Original (full) data resolution. - high resolution: About 80 % reduction in size and quality. - intermediate resolution: Another ~80 % reduction. - low resolution: Another ~80 % reduction. - crude resolution: Another ~80 % reduction.

Note that because GIS software confusingly seem to assume a Cartesian geometry, any polygon straddling the Dateline is broken into an east and west component. The most obvious example is Antarctica.

The political boundary data comes in 3 levels:

  • L1: National boundaries.

  • L2: Internal (state) boundaries for the 8 largest countries only.

  • L3: Maritime boundaries.

Returns:

None

Side Effects:

Shapefile data will be loaded if not already in memory