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
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 | |
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
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 | |
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
|
Source code in workflow/scripts/build_province_shapes.py
101 102 103 104 105 106 107 108 109 110 111 112 113 114 | |