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¶ – 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¶ – Image filename
- bands¶ – 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¶ – 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¶ – line to read in from images
- images¶ – list of image filenames to read from
- image_IDs¶ – list image identifying strings
- dataset_config¶ – dictionary of dataset configuration options
- ncol¶ – number of columns
- nband¶ – number of bands
- dtype¶ – NumPy datatype
- read_cache¶ – try to read from cache directory (default: False)
- write_cache¶ – try to to write to cache directory (default: False)
- validate_cache¶ – 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