Data processing utils¶
Utils to process GEOJSON and GeoPackage to add them in the DB.
apply_actions(df, actions)
¶
Apply a sequence of actions to a Geometry.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
df | GeoDataFrame | GeoDataFrame to apply actions to. | required |
actions | dict | Actions to apply to the GeoDataFrame. | required |
Returns:
Name | Type | Description |
---|---|---|
df | GeoDataFrame | GeoDataFrame with actions applied. |
Source code in back/iarbre_data/utils/data_processing.py
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 70 71 72 73 74 |
|
batched(iterable, n)
¶
Batch data into tuples of length n. The last batch may be shorter.
Source code in back/iarbre_data/utils/data_processing.py
16 17 18 19 20 21 22 23 |
|
make_valid(geometry)
¶
Fix minor topology errors in a geometry, such as a Polygon not being closed. Args: geometry (shapely.geometry.base.BaseGeometry): The geometry to be validated. Returns: shapely.geometry.base.BaseGeometry: The validated geometry.
Source code in back/iarbre_data/utils/data_processing.py
130 131 132 133 134 135 136 137 138 139 140 141 142 |
|
process_data(df, data_config)
¶
Process geometries.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
df | GeoDataFrame | GeoDataFrame to apply actions on. | required |
data_config | dict | Configuration of the data. | required |
Returns:
Name | Type | Description |
---|---|---|
datas | list | Processed data. |
Source code in back/iarbre_data/utils/data_processing.py
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 |
|
save_geometries(datas, data_config)
¶
Save geometries to the database.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
datas | list[dict] | List of dictionaries containing geometries and metadata to save to the database. | required |
data_config | dict | Configuration of the data. | required |
Returns:
Type | Description |
---|---|
None | None |
Source code in back/iarbre_data/utils/data_processing.py
104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 |
|