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
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
|
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
91 92 93 94 95 96 97 98 99 100 101 102 |
|
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
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
|
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. |
Source code in back/iarbre_data/utils/database.py
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
|