ochanticipy.datasources.codab package

Submodules

ochanticipy.datasources.codab.codab module

Download and manipulate COD administrative boundaries.

class ochanticipy.datasources.codab.codab.CodAB(country_config: CountryConfig)[source]

Bases: DataSource

Work with COD AB (administrative boundaries).

Parameters:

country_config (CountryConfig) – Country configuration

download(clobber: bool = False) Path | List[Path][source]

Download COD AB file from HDX.

Parameters:

clobber (bool, default = False) – If True, overwrites existing COD AB files

Return type:

The downloaded filepath(s)

Examples

>>> from ochanticipy import create_country_config, CodAB
>>> # Download COD administrative boundaries for Nepal
>>> country_config = create_country_config(iso3="npl")
>>> codab = CodAB(country_config=country_config)
>>> npl_cod_shapefile = codab.download()
load(admin_level: int = 0) GeoDataFrame[source]

Get the COD AB data by admin level.

Parameters:

admin_level (int, default = 0) – The administrative level

Return type:

COD AB geodataframe with specified admin level

Raises:
  • AttributeError – If the requested admin level is higher than what is available

  • FileNotFoundError – If the requested filename or layer name are not found

Examples

>>> from ochanticipy import create_country_config, CodAB
>>>
>>> # Retrieve admin 2 boundaries for Nepal
>>> country_config = create_country_config(iso3="npl")
>>> codab = CodAB(country_config=country_config)
>>> npl_admin2 = codab.load(admin_level=2)
load_custom(custom_layer_number: int = 0) GeoDataFrame[source]

Get the COD AB data from a custom (non-level) layer.

Parameters:

custom_layer_number (int) – The 0-indexed number of the layer listed in the custom_layer_names parameter of the country’s config file

Return type:

COD AB geodataframe with custom admin level

Raises:
  • AttributeError – If the requested custom layer number is not available

  • FileNotFoundError – If the requested filename or layer name are not found

Examples

>>> from ochanticipy import create_country_config, CodAB
>>>
>>> # Retrieve district boundaries for Nepal
>>> country_config = create_country_config(iso3="npl")
>>> codab = CodAB(country_config=country_config)
>>> npl_district = codab.load_custom(custom_layer_number=0)
process(*args, **kwargs)[source]

Process COD AB data.

Method not implemented.

Module contents

Methods pertaining to the COD administrative boundaries.