Build province shapes
Functions to get the province shapes.
fetch_natural_earth_records(country_iso2_code='CN')
Fetch the province/state level (1st admin level) from the NATURAL_EARTH data store and make a file
Parameters:
Name | Type | Description | Default |
---|---|---|---|
country_iso2_code
|
str
|
the country code (iso_a2) for which provincial records will be extracted. None will not filter (untestetd) Defaults to 'CN' |
'CN'
|
Returns: Records: the natural earth records
Source code in workflow/scripts/build_province_shapes.py
records_to_data_frame(records)
Dump irrelevant info and make records into a GeoDataFrame that matches the PROV_NAMES
Parameters:
Name | Type | Description | Default |
---|---|---|---|
records
|
object
|
the cartopy shpread records from natural earth |
required |
Returns:
Type | Description |
---|---|
GeoDataFrame
|
gpd.GeoDataFrame: the cleaned up & sorted data in a format that can be saved |
Source code in workflow/scripts/build_province_shapes.py
save_province_data(provinces_gdf, crs=CRS, output_file=DEFAULT_SHAPE_OUTPATH)
Save to file
Parameters:
Name | Type | Description | Default |
---|---|---|---|
provinces_gdf
|
GeoDataFrame
|
the cleaned up province records |
required |
crs
|
int
|
the crs in epsg format. Defaults to CRS. |
CRS
|
output_file
|
pathlike
|
the output path. defaults to DEFAULT_SHAPE_OUTPATH |
DEFAULT_SHAPE_OUTPATH
|