Handlers API¶
obia.handlers.geotif¶
obia.handlers.geotif
¶
Image
¶
Image A class for handling geographic raster image data, providing utilities to manage its properties and to convert it into visualization formats.
Attributes¶
img_data : numpy.ndarray The image data array. crs : str or dict Coordinate reference system of the image. transform : affine.Affine Affine transformation matrix. affine_transformation : affine.Affine Deprecated attribute for affine transformation. rasterio_obj : rasterio.io.DatasetReader Rasterio dataset object for the image.
Methods¶
init(self, img_data, crs, affine_transformation, transform, rasterio_obj) Constructs all the necessary attributes for the Image object. to_image(self, bands) Converts specified bands of the image into an RGB image.
Source code in obia/handlers/geotif.py
8 9 10 11 12 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 49 50 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 | |
to_image(bands, p_min=2, p_max=98, stretch_type=None)
¶
always applies a linear stretch :param bands: A list or tuple of three integers representing the indices of the bands to use for the RGB image. :param p_min: Minimum percentile for rescaling. :param p_max: Maximum percentile for rescaling. :param stretch_type: Type of contrast stretching to apply ("linear", "histogram_equalization", "clahe"). :return: A rescaled and contrast-stretched RGB image.
Source code in obia/handlers/geotif.py
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 71 72 73 74 75 | |
open_binary_geotiff_as_mask(mask_path)
¶
:param mask_path: Path to the binary GeoTIFF file to be opened. :return: A tuple containing the binary mask array, bounding box, affine transform, and profile of the raster.
Source code in obia/handlers/geotif.py
154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 | |
open_geotiff(image_path, bands=None)
¶
:param image_path: Path to the GeoTIFF file to be opened. :type image_path: str :param bands: List of band indices to be read from the GeoTIFF file. If None, all bands are read. :type bands: list of int, optional :return: An Image object containing the raster data, coordinate reference system, affine transformation matrix, and the original rasterio object. :rtype: Image
Source code in obia/handlers/geotif.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 | |