aisdb.ports.api module

class aisdb.ports.api.WorldPortIndexClient[source]

Bases: object

A client to query the World Port Index (WPI) FeatureServer and extract port data by bounding box or other filters.

fetch_ports(lat_min, lat_max, lon_min, lon_max, save=False, out_path=None)[source]

Fetches ports within the given bounding box.

Parameters:
  • lat_min – float

  • lat_max – float

  • lon_min – float

  • lon_max – float

  • save – bool, whether to save to CSV

  • out_path – optional, required if save=True

Returns:

pd.DataFrame of port records

filter_by_cargo_depth(df, valid_depths=('A', 'B', 'C', 'D', 'E', 'F'))[source]

Filters DataFrame to only include ports with valid cargo depth codes.

Parameters:
  • df – DataFrame

  • valid_depths – Tuple of allowed CARGODEPTH codes

Returns:

Filtered DataFrame