Compute Plantability Raster¶
Command
¶
Bases: BaseCommand
Source code in back/plantability/management/commands/compute_plantability_raster.py
113 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 146 147 148 149 150 |
|
handle(*args, **options)
¶
Compute and save factor data for the selected city.
Source code in back/plantability/management/commands/compute_plantability_raster.py
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 146 147 148 149 150 |
|
compute_weighted_sum(raster_directory, output_file, meta, result, factor_name, weight)
¶
Compute the weighted sum of raster data and save the result to a file.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
raster_directory | str | The directory containing the raster files. | required |
output_file | str | The path to the output file where the result will be saved. | required |
meta | Dict[str, Any] | Metadata for the output raster file. | required |
result | ndarray | The array to store the computed weighted sum. | required |
factor_name | str | The name of the factor to process. | required |
weight | float | The weight to apply to the factor data. | required |
Returns:
Type | Description |
---|---|
None | None |
Source code in back/plantability/management/commands/compute_plantability_raster.py
13 14 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 45 46 47 48 |
|
cut_outside_cities(meta, result, all_cities_union)
¶
Cut everything outside the cities and set nodata values for areas outside the cities.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
meta | Dict[str, Any] | Metadata for the output raster file. | required |
result | ndarray | The array to store the computed weighted sum. | required |
all_cities_union | Any | The union of all city geometries. | required |
Returns:
Type | Description |
---|---|
ndarray | np.ndarray: The updated result array with nodata values outside the cities. |
Source code in back/plantability/management/commands/compute_plantability_raster.py
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
|
threshold_and_convert_to_colors(result, rgb_colors, colors)
¶
Apply thresholding to the result array and convert it to RGB colors.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
result | ndarray | The array containing the computed weighted sum. | required |
rgb_colors | Dict[float, ndarray] | A dictionary mapping threshold values to RGB color arrays. | required |
colors | Dict[float, str] | A dictionary mapping threshold values to color names. | required |
Returns:
Type | Description |
---|---|
ndarray | np.ndarray: The array with RGB color values. |
Source code in back/plantability/management/commands/compute_plantability_raster.py
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 |
|