yatsm.io.readers module¶
Helper functions for reading various types of imagery data
-
yatsm.io.readers.
get_image_attribute
(image_filename)[source]¶ Use GDAL to open image and return some attributes
Parameters: image_filename (str) – image filename Returns: nrow (int), ncol (int), nband (int), NumPy datatype (type) Return type: tuple
-
yatsm.io.readers.
read_image
(image_filename, bands=None, dtype=None)[source]¶ Return raster image bands as a sequence of NumPy arrays
Parameters: - image_filename (str) – Image filename
- bands (iterable, optional) – A sequence of bands to read from image. If bands is None, function returns all bands in raster. Note that bands are indexed on 1 (default: None)
- dtype (np.dtype) – NumPy datatype to use for image bands. If dtype is None, arrays are kept as the image datatype (default: None)
Returns: list of NumPy arrays for each band specified
Return type: Raises: IOError
– raise IOError if bands specified are not contained within rasterRuntimeError
– raised if GDAL encounters errors
-
yatsm.io.readers.
read_line
(line, images, image_IDs, dataset_config, ncol, nband, dtype, read_cache=False, write_cache=False, validate_cache=False)[source]¶ Reads in dataset from cache or images if required
Parameters: - line (int) – line to read in from images
- images (list) – list of image filenames to read from
- image_IDs (iterable) – list image identifying strings
- dataset_config (dict) – dictionary of dataset configuration options
- ncol (int) – number of columns
- nband (int) – number of bands
- dtype (type) – NumPy datatype
- read_cache (bool, optional) – try to read from cache directory (default: False)
- write_cache (bool, optional) – try to to write to cache directory (default: False)
- validate_cache (bool, optional) – validate that cache data come from same images specified in images (default: False)
Returns: 3D array of image data (nband, n_image, n_cols)
Return type: np.ndarray