Database utils¶
Utils to interact with the DB using Django.
load_geodataframe_from_db(queryset, fields)
¶
Load a GeoDataFrame from a Django model queryset.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
queryset | QuerySet | Django queryset to load data from. | required |
fields | list[str] | List of fields to include in the GeoDataFrame. | required |
Returns:
Name | Type | Description |
---|---|---|
df | GeoDataFrame | GeoDataFrame with data from the queryset. |
Source code in back/iarbre_data/utils/database.py
log_progress(step, star=False)
¶
Log the progress of a step with a timestamp.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
step | str | The description of the step being logged. | required |
star | bool | Print or not a line of stars | False |
Source code in back/iarbre_data/utils/database.py
remove_duplicates(Model)
¶
Deletes duplicates in the instance model based on geometry. Args: Model (class): iarbre_data.models in which duplicates are removed
Source code in back/iarbre_data/utils/database.py
select_city(insee_code_city)
¶
Select a list of cities based on INSEE_CODE.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
insee_code_city | str | INSEE code of the city or cities to select. | required |
Returns:
Name | Type | Description |
---|---|---|
selected_city | GeoDataFrame | GeoDataFrame containing the selected city or cities. |