GeoTIFFο
- static read_file.GeoTIFF(path_or_dataset, crs_key=None, data_crs=None, sel=None, isel=None, set_data=None, mask_and_scale=False)ο
Read all relevant information necessary to add a GeoTIFF to the map.
- Parameters
path_or_dataset (str, pathlib.Path or xar.Dataset) β
If str or pathlib.Path: The path to the file.
If xar.Dataset: The xarray.Dataset instance to use
crs_key (str, optional) β
The variable-name that holds the crs-information.
By default the following options are tried: - <crs_key> = βspatial_refβ, βcrsβ
crs = file.<crs_key>.attrs[βcrs_wktβ]
crs = file.<crs_key>.attrs[βwktβ]
data_crs (None, optional) β Optional way to specify the crs of the data explicitly. (βcrs_keyβ will be ignored if βcrsβ is provided!)
sel (dict, optional) β A dictionary of keyword-arguments passed to xarray.Dataset.sel() (see https://xarray.pydata.org/en/stable/generated/xarray.Dataset.sel.html) The default is None.
isel (dict, optional) β A dictionary of keyword-arguments passed to xarray.Dataset.isel(). (see https://xarray.pydata.org/en/stable/generated/xarray.Dataset.isel.html) The default is {βbandβ : 0} (if sel is None).
set_data (None or eomaps.Maps) β Indicator if the dataset should be returned None or assigned to the provided Maps-object (e.g. by using m.set_data(β¦)). The default is None.
mask_and_scale (bool) β
Indicator if the data should be masked and scaled with respect to the file-attributes _FillValue, scale_factor and add_offset.
If False: the data will only be scaled βon demandβ, avoiding costly initialization of very large float-arrays. Masking will still be applied in case a _FillValue attribute has been found. (a masked-array is returned to avoid dtype conversions) The encoding is accessible via m.data_specs.encoding
If True: all data will be masked and scaled after reading. For more details see xarray.open_dataset.
NOTE: using mask_and_scale=True results in a conversion of the data-values to floats!! For very large datasets this can cause a huge increase in memory-usage! EOmaps handles the scaling internally to show correct values for callbacks and colorbars, even if mask_and_scale=False!
The default is False.
- Returns
A dict that contains the data required for plotting.
- Return type
dict (if set_data is False) or None (if set_data is True)
Examples
# to just read the data use one of the following:
>>> path = r"C:/folder/file.tiff" >>> data = m.read_file.GeoTIFF(path)
>>> file = xar.open_dataset(path) >>> data = m.read_file.GeoTIFF(file)
>>> with xar.open_dataset(path) as file: >>> data = m.read_file.GeoTIFF(file)
# to assign the data directly to the Maps-object, use set_data=<Maps object>:
>>> m.read_file.GeoTIFF(path, set_data=m)