Skip to content

hdx.api.locations

module hdx.api.locations

Locations in HDX

Classes

  • Locations Methods to help with countries and continents

class Locations()

Methods to help with countries and continents

Methods

classmethod Locations.validlocations(configuration=None)list[dict]

Read valid locations from HDX

Parameters

  • configuration HDX configuration. Defaults to global configuration.

Returns

  • list[dict] A list of valid locations

classmethod Locations.set_validlocations(locations: Sequence[dict])None

Set valid locations using list of dictionaries of form {'name': 'zmb', 'title', 'Zambia'}

Parameters

  • locations : Sequence[dict] List of dictionaries of form {'name': 'zmb', 'title', 'Zambia'}

Returns

  • None None

classmethod Locations.get_location_from_HDX_code(code: str, locations: Sequence[dict] | None = None, configuration: Configuration | None = None)str | None

Get location from HDX location code

Parameters

  • code : str code for which to get location name

  • locations : Sequence[dict] | None Valid locations list. Defaults to list downloaded from HDX.

  • configuration : Configuration | None HDX configuration. Defaults to global configuration.

Returns

  • str | None location name or None

classmethod Locations.get_HDX_code_from_location(location: str, locations: Sequence[dict] | None = None, configuration: Configuration | None = None)str | None

Get HDX code for location

Parameters

  • location : str Location for which to get HDX code

  • locations : Sequence[dict] | None Valid locations list. Defaults to list downloaded from HDX.

  • configuration : Configuration | None HDX configuration. Defaults to global configuration.

Returns

  • str | None HDX code or None

classmethod Locations.get_HDX_code_from_location_partial(location: str, locations: Sequence[dict] | None = None, configuration: Configuration | None = None)tuple[str | None, bool]

Get HDX code for location

Parameters

  • location : str Location for which to get HDX code

  • locations : Sequence[dict] | None Valid locations list. Defaults to list downloaded from HDX.

  • configuration : Configuration | None HDX configuration. Defaults to global configuration.

Returns

  • tuple[str | None, bool] HDX code and if the match is exact or (None, False) for no match