Build population gridcell map
build_gridded_population(prov_pop_path, pop_density_raster_path, cutout_path, province_shape_path, gridded_pop_out)
Build a gridded population DataFrame by matching population density to the cutout grid cells. This DataFrame is a sparse matrix of the population and shape BusesxCutout_gridcells where buses are the provinces
Parameters:
Name | Type | Description | Default |
---|---|---|---|
prov_pop_path
|
PathLike
|
Path to the province population count file (hdf5). |
required |
pop_density_raster_path
|
PathLike
|
Path to the population density raster file. |
required |
cutout_path
|
PathLike
|
Path to the cutout file containing the grid. |
required |
province_shape_path
|
PathLike
|
Path to the province shape file. |
required |
gridded_pop_out
|
PathLike
|
output file path. |
required |
Source code in workflow/scripts/build_population_gridcell_map.py
build_population_map(prov_pop_path, pop_density_raster_path, cutout_path, province_shape_path, gridded_pop_out)
Build a gridded population DataFrame by matching population density to the cutout grid cells. This DataFrame is a sparse matrix of the population and shape BusesxCutout_gridcells where buses are the provinces
Parameters:
Name | Type | Description | Default |
---|---|---|---|
prov_pop_path
|
PathLike
|
Path to the province population count file (hdf5). |
required |
pop_density_raster_path
|
PathLike
|
Path to the population density raster file. |
required |
cutout_path
|
PathLike
|
Path to the cutout file containing the grid. |
required |
province_shape_path
|
PathLike
|
Path to the province shape file. |
required |
gridded_pop_out
|
PathLike
|
output file path. |
required |
Source code in workflow/scripts/build_population_gridcell_map.py
load_cfrs_data(target)
Load CFRS_grid.nc type files into a geodatafram
Parameters:
Name | Type | Description | Default |
---|---|---|---|
target
|
PathLike
|
the abs path |
required |
Returns:
Type | Description |
---|---|
GeoDataFrame
|
gpd.GeoDataFrame: the data in gdf |
Source code in workflow/scripts/build_population_gridcell_map.py
xarr_to_gdf(xarr, var_name, x_var='x', y_var='y', crs=CRS)
Convert an xarray to GDF
Parameters:
Name | Type | Description | Default |
---|---|---|---|
xarr
|
DataArray
|
the input array |
required |
var_name
|
str
|
the array variable to be converted. |
required |
x_var
|
str
|
the x dimension. Defaults to "x". |
'x'
|
y_var
|
str
|
the y dimension. Defaults to "y". |
'y'
|
crs
|
_type_
|
the crs. Defaults to CRS. |
CRS
|
Returns:
Type | Description |
---|---|
GeoDataFrame
|
gpd.GeoDataFrame: geodata frame in chosen CRS |