raster
This module contains functions that process or create raster/image data.
reproject_raster #
reproject_raster(
dataset_path: str | Path,
target_crs: str | int,
target_path: str | Path,
logger: Logger = LOGGER,
) -> Path | None
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dataset_path
|
str | Path
|
Path to the dataset to be reprojected. |
required |
target_crs
|
str | int
|
EPSG code in string or int format. Can be given in the following ways: 5070 | "5070" | "EPSG:5070" |
required |
target_path
|
str | Path
|
Path and filename for reprojected dataset. |
required |
logger
|
Logger
|
Logger instance |
LOGGER
|
Returns:
Source code in geospatial_tools/raster.py
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 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
|
clip_raster_with_polygon #
clip_raster_with_polygon(
raster_image: Path | str,
polygon_layer: Path | str | GeoDataFrame,
base_output_filename: str | None = None,
output_dir: str | Path = DATA_DIR,
num_of_workers: int | None = None,
logger: Logger = LOGGER,
) -> list[Path]
Parameters:
Name | Type | Description | Default |
---|---|---|---|
raster_image
|
Path | str
|
Path to raster image to be clipped. |
required |
polygon_layer
|
Path | str | GeoDataFrame
|
Polygon layer which polygons will be used to clip the raster image. |
required |
base_output_filename
|
str | None
|
Base filename for outputs. If |
None
|
output_dir
|
str | Path
|
Directory path where output will be written. |
DATA_DIR
|
num_of_workers
|
int | None
|
The number of processes to use for parallel execution. Defaults to |
None
|
logger
|
Logger
|
Logger instance |
LOGGER
|
Returns:
Source code in geospatial_tools/raster.py
129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 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 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 |
|
get_total_band_count #
get_total_band_count(
raster_file_list: list[Path | str], logger: Logger = LOGGER
) -> int
Parameters:
Name | Type | Description | Default |
---|---|---|---|
raster_file_list
|
list[Path | str]
|
List of raster files to be processed. |
required |
logger
|
Logger
|
Logger instance |
LOGGER
|
Returns:
Source code in geospatial_tools/raster.py
202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 |
|
create_merged_raster_bands_metadata #
create_merged_raster_bands_metadata(
raster_file_list: list[Path | str], logger: Logger = LOGGER
) -> dict
Parameters:
Name | Type | Description | Default |
---|---|---|---|
raster_file_list
|
list[Path | str]
|
|
required |
logger
|
Logger
|
|
LOGGER
|
Returns:
Source code in geospatial_tools/raster.py
221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 |
|
merge_raster_bands #
merge_raster_bands(
raster_file_list: list[Path | str],
merged_filename: Path | str,
merged_band_names: list[str] = None,
merged_metadata: dict = None,
logger: Logger = LOGGER,
) -> Path | None
This function aims to combine multiple overlapping raster bands into a single raster image.
Example use case: I have 3 bands, B0, B1 and B2, each as an independent raster file (like is the case with downloaded STAC data.
While it can probably be used to create spatial time series, and not just combine bands from a single image product, it has not yet been tested for that specific purpose.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
raster_file_list
|
list[Path | str]
|
List of raster files to be processed. |
required |
merged_filename
|
Path | str
|
Name of output raster file. |
required |
merged_metadata
|
dict
|
Dictionary of metadata to use if you prefer to great it independently. |
None
|
merged_band_names
|
list[str]
|
Names of final output raster bands. For example : I have 3 images representing each |
None
|
a single band; raster_file_list = ["image01_B0.tif", "image01_B1.tif", "image01_B2.tif"]. With, merged_band_names, individual band id can be assigned for the final output raster; ["B0", "B1", "B2"]. logger: Logger instance
Returns:
Source code in geospatial_tools/raster.py
242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 |
|