aisdb.discretize.h3 module

class aisdb.discretize.h3.Discretizer(resolution)[source]

Bases: object

describe(plot=True)[source]

Generate and display the relationship between latitude and hexagon area, and resolution and hexagon edge length, with plots and printed output.

Return type:

None

get_h3_index(lat, lon)[source]

Get the H3 index for a single latitude and longitude point.

Parameters:
  • lat – Latitude of the point

  • lon – Longitude of the point

Returns:

H3 index as a string

get_hexagon_area_at_latitude(lat)[source]

Generate a single hexagon at a specific latitude and calculate its area.

get_polygon_from_cells(cells, tight=True)[source]

Get the polygon for a list of H3 cells.

Parameters:
  • cells – List of H3 cell indices

  • tight – If True, return a tightly fitting polygon around the cells, otherwise return the cell boundary

Returns:

Polygon as a Shapely geometry object

yield_tracks_discretized_by_indexes(tracks)[source]

Get H3 indices for a generator of tracks and yield updated tracks.

Parameters:

tracks – Generator yielding dictionaries with ‘lat’ and ‘lon’ arrays

Yield:

Each track dictionary with an added ‘h3_index’ list of H3 indices