C04 Compute Factors¶
Command
¶
Bases: BaseCommand
Source code in back/iarbre_data/management/commands/c04_compute_factors.py
148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 |
|
handle(*args, **options)
¶
Compute and save factor data for the selected city.
Source code in back/iarbre_data/management/commands/c04_compute_factors.py
165 166 167 168 169 170 171 172 173 174 175 176 |
|
_compute_for_factor_partial_tiles(factor_df, tiles_df, std_area)
¶
Compute and store the proportion of standard tile area occupied by a geographic factor.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
factor_df | GeoDataFrame | GeoDataFrame containing factor geometries that will be intersected with tiles. | required |
tiles_df | GeoDataFrame | GeoDataFrame containing tile geometries. | required |
std_area | float | Standard tile area in square meters (m²). | required |
Returns:
Type | Description |
---|---|
list[TileFactor] | List of TileFactor objects to be created in the database |
Source code in back/iarbre_data/management/commands/c04_compute_factors.py
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 |
|
compute_for_factor(factor_name, tiles_df, std_area)
¶
Compute and store factor coverage proportions for the provided tiles.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
factor_name | str | Name of the geographic factor to process (e.g., 'Parking', 'Route') | required |
tiles_df | geodataframe | Geodataframe with tiles to process. | required |
std_area | float | Standard tile area in square meters (m²). | required |
Returns:
Type | Description |
---|---|
None | None |
Notes
- Standard area is calculated from the first Tile object in database (all tiles have the same area).
Source code in back/iarbre_data/management/commands/c04_compute_factors.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 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 |
|
has_intersection(geom, tiles_index)
¶
Check if a geometry intersects with any tile.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
geom | BaseGeometry | Geometry to check. | required |
tiles_index | sindex | R-tree spatial index of the tiles. | required |
Returns:
Type | Description |
---|---|
bool | True if the geometry intersects with any tile, False otherwise. |
Source code in back/iarbre_data/management/commands/c04_compute_factors.py
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
|
process_city(city, FACTORS, std_area, delete)
¶
Process a city to compute and store factor coverage proportions.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
city | Pandas DataFrame | DataFrame containing city information. | required |
FACTORS | dict | Dictionary containing the factors to process. | required |
std_area | float | Standard tile area in square meters (m²). | required |
delete | bool | If True, delete already computed Tiles. | required |
Returns:
Name | Type | Description |
---|---|---|
Completion | int | 0 if already computed, 1 otherwise. |
Source code in back/iarbre_data/management/commands/c04_compute_factors.py
114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 |
|