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.
Package Contents#
Functions#
|
Return the requested administrative boundaries using the name or the administrative code. |
|
Return the requested administrative boundaries using the name or the administrative code. |
|
Return the list of names available in a administrative layer using the name or the administrative code. |
Attributes#
- pygadm._items(name='', admin='', content_level=-1)[source]#
Return the requested administrative boundaries using the name or the administrative code.
Same method as get_items but only accept single requests in str format.
- 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
- pygadm.get_items(name='', admin='', content_level=-1)[source]#
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).
- Returns:
The GeoDataFrame of the requested area with all the GADM attributes.
- 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.
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.
- Returns:
The list of all the available names.
- Return type:
pandas.DataFrame