Functions¶
Table of the available datasets: name, description, source and whether it comes with the package or is downloaded the first time it is used.
Load a dataset by its name in popmex (R).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dataset
|
str
|
|
required |
cve_edo
|
(str, int or list)
|
INEGI state key(s) to keep only the municipalities of those states (municipal tables only). |
None
|
Returns:
| Type | Description |
|---|---|
DataFrame or GeoDataFrame
|
The municipal tables have the municipality key ( |
Population of one or several localities in 400 m H3 hexagons.
Selects the hexagons of the Kontur/HDX population dataset of the year that
intersect the localities. The boundaries of the localities (INEGI 2019)
come from rgeomex <https://fdzul.github.io/rgeomex-py/>_, which must be
installed (pip install git+https://github.com/fdzul/rgeomex-py).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
year
|
(2021, 2022, 2023)
|
|
2021
|
cve_edo
|
str or int
|
INEGI state key, e.g. |
None
|
locality
|
str or list of str
|
Name or names of the localities; the names do not need to be exact
( |
None
|
Returns:
| Type | Description |
|---|---|
GeoDataFrame
|
The hexagons (EPSG:4326) that intersect the localities, with their
|
Examples:
Rate per per inhabitants (100,000 by default): cases / population * per.
Works with numbers or with pandas columns (aligned by index); a population of 0 gives NaN instead of infinity.
Download (only the first time) the LandScan population raster of Mexico.
The GeoTIFF (about 41 MB, 1 km, EPSG:4326) is the same file used by
popmex (R): one band per year (pop_2000 ... pop_2024,
pop_2026) with the estimated population of each cell. It is
downloaded from the data-v1 release, verified with its SHA-256 and
kept in the local cache, so later calls read it from disk.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
refresh
|
bool
|
Download the file again even if it is in the cache. |
False
|
Returns:
| Type | Description |
|---|---|
Path
|
Path of the GeoTIFF, to open with rasterio or rioxarray, e.g.
|
Notes
Cite the LandScan edition you use, e.g. Sims K, et al. (2023). LandScan Global 2022 [Data set]. Oak Ridge National Laboratory. https://doi.org/10.48690/1529167
Population of LandScan inside each polygon (sum of its 1 km cells).
A cell is counted in a polygon when its centre falls inside it, so small polygons (an AGEB, a block) can get 0; LandScan is meant for municipalities, localities or larger areas.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
gdf
|
GeoDataFrame
|
Polygons, e.g. the municipalities of rgeomex. |
required |
year
|
int
|
Year of the band (see :func: |
required |
id_col
|
str
|
Column with the identifier of each polygon. |
required |
Returns:
| Type | Description |
|---|---|
DataFrame
|
|
Examples: