Raster Plantability To Geometries¶
get_administrative_attachment(polygon, previous, model)
¶
Determine the administrative attachment (e.g., city or IRIS) for a given polygon.
Parameters:¶
polygon : shapely.geometry.base.BaseGeometry The polygon for which to determine the administrative attachment. previous : Optional[Model] The previous administrative unit (e.g., city or IRIS). If provided, the function first checks if the polygon intersects with this unit. model : Type[Model] The Django model to query for administrative units (e.g., City or Iris).
Returns:¶
Tuple[Optional[int], Optional[Model]] A tuple containing: - The ID of the administrative unit that intersects with the polygon, or None if no match is found. - The administrative unit (e.g., city or IRIS) that intersects with the polygon, or None if no match is found.
Source code in back/plantability/management/commands/raster_plantability_to_geom.py
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 49 50 51 52 53 54 55 |
|
raster_to_db_tiles(raster_path, batch_size=BATCH_SIZE)
¶
Convert a raster file to Tile objects in the database. Each pixel becomes a square polygon with plantability indices based on the pixel value.
Parameters:¶
raster_path : str Path to the input raster file. batch_size : int, optional Number of tiles to create before committing to the database. Default is BATCH_SIZE.
Source code in back/plantability/management/commands/raster_plantability_to_geom.py
58 59 60 61 62 63 64 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 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 |
|