Compute Plantability Raster¶
Command
¶
Bases: BaseCommand
Source code in back/plantability/management/commands/compute_plantability_raster.py
handle(*args, **options)
¶
Compute and save factor data for the selected city.
Source code in back/plantability/management/commands/compute_plantability_raster.py
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
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
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. |