pygadm#

Easy access to administrative boundary defined by GADM from Python scripts.

This lib provides access to GADM datasets from a Python script without downloading the file from their server. We provide access to The current version (4.1.) which delimits 400,276 administrative areas.

The data are freely available for academic use and other non-commercial use. Redistribution, or commercial use is not allowed without prior permission. See the license of the GADM project for more details.

Attributes#

Classes#

AdmItems

Return the requested administrative boundaries using the name or the administrative code.

AdmNames

Set the list of names available in a administrative layer using the name or the administrative code.

Items

Return the requested administrative boundaries using the name or the administrative code.

Names

Set the list of names available in a administrative layer using the name or the administrative code.

Functions#

_df()

Get the parquet database.

get_items([name, admin, content_level])

Return the requested administrative boundaries using the name or the administrative code.

get_names([name, admin, content_level, complete])

Return the list of names available in a administrative layer using the name or the administrative code.

Package Contents#

class pygadm.AdmItems(name='', admin='', content_level=-1)[source]#

Bases: Items

Return the requested administrative boundaries using the name or the administrative code.

Return a Geopandas GeoDataFrame representing an administrative region. The region can be requested either by its “name” or its “admin”, the lib will identify the area level on the fly. The user can also request for a specific level for the GeoDataFrame features e.g. get all admin level 1 of a country. If nothing is set we will infer the level of the item and if the level is higher than the found item, it will be ignored. If Nothing is found the method will return an error.

Parameters:
  • name (Union[str, List[str]]) – The name of an administrative area. Cannot be set along with admin. it can be a list or a single name.

  • admin (Union[str, List[str]]) – The id of an administrative area in the GADM nomenclature. Cannot be set along with name. It can be a list or a single admin code.

  • content_level (int) – The level to use in the final dataset. Default to -1 (use level from the area).

class pygadm.AdmNames(name='', admin='', content_level=-1, complete=False)[source]#

Bases: Names

Set the list of names available in a administrative layer using the name or the administrative code.

Return a pandas DataFrame of the names ad GADM code of an administrative region. The region can be requested either by its “name” or its “admin”, the lib will identify the corresponding level on the fly. The user can also request for a specific level for its content e.g. get all admin level 1 of a country. If nothing is set we will infer the level of the item and if the level is higher than the found item, it will be ignored. If Nothing is found the method will return an error.

Parameters:
  • name (str) – The name of a administrative area. Cannot be set along with admin.

  • admin (str) – The id of an administrative area in the GADM nomenclature. Cannot be set along with name.

  • content_level (int) – The level to use in the final dataset. Default to -1 (use level of the selected area).

  • complete (bool) – If True, the method will return all the names of the higher administrative areas. Default to False.

class pygadm.Items(name='', admin='', content_level=-1)[source]#

Bases: geopandas.GeoDataFrame

Return the requested administrative boundaries using the name or the administrative code.

Return a Geopandas GeoDataFrame representing an administrative region. The region can be requested either by its “name” or its “admin”, the lib will identify the area level on the fly. The user can also request for a specific level for the GeoDataFrame features e.g. get all admin level 1 of a country. If nothing is set we will infer the level of the item and if the level is higher than the found item, it will be ignored. If Nothing is found the method will return an error.

Parameters:
  • name (Union[str, List[str]]) – The name of an administrative area. Cannot be set along with admin. it can be a list or a single name.

  • admin (Union[str, List[str]]) – The id of an administrative area in the GADM nomenclature. Cannot be set along with name. It can be a list or a single admin code.

  • content_level (int) – The level to use in the final dataset. Default to -1 (use level from the area).

_items(name='', admin='', content_level=-1)[source]#

Return the requested administrative boundaries from the single name or administrative code.

Parameters:
  • name (str) – The name of an administrative area. Cannot be set along with admin.

  • admin (str) – The id of an administrative area in the GADM nomenclature. Cannot be set along with name.

  • content_level (int) – The level to use in the final dataset. Default to -1 (use level from the area).

Returns:

The GeoDataFrame of the requested area with all the GADM attributes.

Return type:

geopandas.GeoDataFrame

class pygadm.Names(name='', admin='', content_level=-1, complete=False)[source]#

Bases: pandas.DataFrame

Set the list of names available in a administrative layer using the name or the administrative code.

Return a pandas DataFrame of the names ad GADM code of an administrative region. The region can be requested either by its “name” or its “admin”, the lib will identify the corresponding level on the fly. The user can also request for a specific level for its content e.g. get all admin level 1 of a country. If nothing is set we will infer the level of the item and if the level is higher than the found item, it will be ignored. If Nothing is found the method will return an error.

Parameters:
  • name (str) – The name of a administrative area. Cannot be set along with admin.

  • admin (str) – The id of an administrative area in the GADM nomenclature. Cannot be set along with name.

  • content_level (int) – The level to use in the final dataset. Default to -1 (use level of the selected area).

  • complete (bool) – If True, the method will return all the names of the higher administrative areas. Default to False.

pygadm._df()[source]#

Get the parquet database.

Return type:

pandas.DataFrame

pygadm.get_items(name='', admin='', content_level=-1)[source]#

Return the requested administrative boundaries using the name or the administrative code.

Parameters:
  • name (Union[str, List[str]]) –

  • admin (Union[str, List[str]]) –

  • content_level (int) –

Return type:

geopandas.GeoDataFrame

pygadm.get_names(name='', admin='', content_level=-1, complete=False)[source]#

Return the list of names available in a administrative layer using the name or the administrative code.

Parameters:
  • name (str) –

  • admin (str) –

  • content_level (int) –

  • complete (bool) –

Return type:

pandas.DataFrame

pygadm.__author__ = 'Pierrick Rambaud'[source]#
pygadm.__email__ = 'pierrick.rambaud49@gmail.com'[source]#
pygadm.__gadm_continent__[source]#
pygadm.__gadm_data__[source]#
pygadm.__gadm_url__ = 'https://geodata.ucdavis.edu/gadm/gadm4.1/json/gadm41_{}_{}.json'[source]#
pygadm.__gadm_version__ = '410'[source]#
pygadm.__version__ = '0.5.3'[source]#
pygadm.session[source]#