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
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
geocode_address(address)
¶
Geocode address using OpenStreetMap Nominatim API.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
address | str | Address to geocode | required |
Returns:
Name | Type | Description |
---|---|---|
Point | Point | Point geometry in Lambert-93 (EPSG:2154) or None if geocoding fails |
Source code in back/iarbre_data/utils/data_processing.py
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
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
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 |