eumap.raster.read_auth_rasters¶
- read_auth_rasters(raster_files, username, password, bands=None, dtype='float16', n_jobs=4, return_base_raster=False, nodata=None, verbose=False)[source]¶
Read raster files trough a authenticate HTTP service, aggregating them into a single array. For raster files without authentication it’s better to use read_rasters.
The
nodata
value is replaced bynp.nan
in case ofdtype=float*
, and fordtype=*int*
it’s replaced by the the lowest possible value inside the range (forint16
this value is-32768
).- Parameters
raster_files (
List
) – A list with the raster urls.username (
str
) – Username to provide to the basic access authentication.password (
str
) – Password to provide to the basic access authentication.bands – Which bands needs to be read. By default is
None
reading all the bands.dtype (
str
) – Convert the read data to specificdtype
. By default it reads infloat16
to save memory, however pay attention in the precision limitations for thisdtype
[1].n_jobs (
int
) – Number of parallel jobs used to read the raster files.return_base_raster (
bool
) – Return an empty raster with the same properties of the read rasters(height, width, n_bands, crs, dtype, transform)
.nodata – Use this value if the nodata property is not defined in the read rasters.
verbose (
bool
) – UseTrue
to print the reading progress.
- Returns
A 4D array, where the first dimension refers to the bands and the last dimension to read files. If
return_base_raster=True
the second value will be a base raster path.- Return type
Numpy.array or Tuple[Numpy.array, Path]
References
Examples
>>> from eumap.raster import read_auth_rasters >>> >>> # Do the registration in >>> # https://glad.umd.edu/ard/user-registration >>> username = '<YOUR_USERNAME>' >>> password = '<YOUR_PASSWORD>' >>> raster_files = [ >>> 'https://glad.umd.edu/dataset/landsat_v1.1/47N/092W_47N/850.tif', >>> 'https://glad.umd.edu/dataset/landsat_v1.1/47N/092W_47N/851.tif', >>> 'https://glad.umd.edu/dataset/landsat_v1.1/47N/092W_47N/852.tif', >>> 'https://glad.umd.edu/dataset/landsat_v1.1/47N/092W_47N/853.tif' >>> ] >>> >>> data, base_raster = read_auth_rasters(raster_files, username, password, >>> return_base_raster=True, verbose=True) >>> print(f'Data: shape={data.shape}, dtype={data.dtype} and base_raster={base_raster}')