remotior_sensus.core.bandset_catalog module
- class remotior_sensus.core.bandset_catalog.BandSet(bandset_uid, bands_list=None, name=None, date=None, root_directory=None, crs=None, box_coordinate_list=None, catalog=None)
Bases:
object
Manages band sets.
This module allows for managing bands in a BandSet.
- bands
BandSet of band tables.
- get
alias for get_band function.
Examples
- Create a BandSet
>>> import remotior_sensus >>> rs = remotior_sensus.Session() >>> file_list = ['file_1.tif', 'file_2.tif', 'file_3.tif'] >>> bandset = rs.bandset.create(file_list)
- Get the first band
>>> band_1 = bandset.get_band(1)
- __init__(bandset_uid, bands_list=None, name=None, date=None, root_directory=None, crs=None, box_coordinate_list=None, catalog=None)
Initializes a BandSet.
Initializes a BandSet defining a unique ID. One should use the create method for creating new BandSets.
- Parameters:
bandset_uid – unique BandSet ID.
bands_list – list of band tables.
name – optional BandSet name.
date – optional BandSet date.
root_directory – optional BandSet root directory for relative path.
crs – BandSet coordinate reference system.
box_coordinate_list – list of coordinates [left, top, right, bottom] to create a virtual subset.
catalog – BandSet Catalog
Examples
- Initialize a BandSet
>>> BandSet.create(name=name,box_coordinate_list=box_coordinate_list)
- add_new_band(path: str, band_number: int | None = None, raster_band=None, band_name=None, date=None, root_directory=None, multiplicative_factor=None, additive_factor=None, wavelength=None, unit=None)
Adds new band to a BandSet.
Adds a new band to a BandSet with the option to set the band number for the position in the BandSet order.
- Parameters:
path – file path.
band_number – sets the position of the band in BandSet order.
raster_band – number of band for multiband rasters.
band_name – name of raster used for band.
date – single date (as YYYY-MM-DD).
multiplicative_factor – multiplicative factor.
additive_factor – additive factor.
wavelength – center wavelength.
unit – wavelength unit.
root_directory – root directory for relative path.
Examples
- Add a new band
>>> import remotior_sensus >>> rs = remotior_sensus.Session() >>> bandset = BandSet() >>> bandset.add_new_band( ... path=path, band_number=band_number, raster_band=raster_band, ... band_name=band_name, date=date, root_directory=root_directory, ... multiplicative_factor=multiplicative_factor, ... additive_factor=additive_factor, wavelength=wavelength, unit=unit ... )
- property box_coordinate_list
Optional BandSet box coordinate list for virtual subset.
- Type:
list
- calc(*args, **kwargs)
Executes a calculation.
Executes a calculation directly from the BandSet, passing the argument input_bands. The arguments are related to the function. Bands in the BandSet can be reffered in the expressions such as “b1” or “b2”; also band alias such as “#RED#” and expression alias such as #NDVI# can be used.
- Parameters:
kwargs – See
band_calc()
.- Returns:
The output of the function.
Examples
- Given that a session was previously started
>>> import remotior_sensus >>> rs = remotior_sensus.Session() >>> bandset = rs.bandset.create( ... ['file1.tif', 'file2.tif'], wavelengths=['Sentinel-2'], ... )
- Calculation of sum of the first two bands and saving the output in temporary directory
>>> output_object = bandset.calc('"b1" + "b2"')
- Calculation of NDVI
>>> output_object = bandset.calc(output_path='output.tif', ... expression_string='("#NIR#" - "#RED#") / ("#NIR#" + "#RED#")' ... )
- classification(*args, **kwargs)
Executes a classification.
Executes a classification directly from the BandSet, passing the argument input_bands. The arguments are related to the function.
- Parameters:
kwargs – See
band_classification()
.- Returns:
The output of the function.
- combination(*args, **kwargs)
Band combination.
Combines classifications directly from the BandSet, in order to get a raster where each value corresponds to a combination of class values. The arguments are related to the function.
- Parameters:
kwargs – See
band_combination()
.- Returns:
The output of the function.
Examples
- Given that a session was previously started
>>> import remotior_sensus >>> rs = remotior_sensus.Session() >>> bandset = rs.bandset.create(['file1.tif', 'file2.tif'])
- Combination using two rasters having paths path_1 and path_2
>>> combination = bandset.combination(output_path='output_path')
- classmethod create(paths: str | list | None = None, band_names: list | None = None, wavelengths: list | None = None, unit: None | str = None, multiplicative_factors: list | None = None, additive_factors: list | None = None, dates: list | None = None, root_directory: None | str = None, box_coordinate_list: list | None = None, name: None | str = None, catalog=None)
Creates a BandSet.
This method creates a BandSet defined by input files. Raster properties are derived from files to populate the table of bands.
- Parameters:
catalog – BandSet Catalog object.
name – BandSet name.
paths – list of file paths or a string of directory path; also, a list of directory path and name filter is accepted.
band_names – list of raster names used for identifying the bands, if None then the names are automatically extracted from file names.
wavelengths – list of center wavelengths of bands or string of sensor names (also partial).
unit – wavelength unit.
multiplicative_factors – multiplicative factors for bands during calculations.
additive_factors – additive factors for bands during calculations.
dates – list of date strings, or single date string (format YYYY-MM-DD) or string defined in configurations date_auto to detect date from directory name.
root_directory – root directory for relative path.
box_coordinate_list – list of coordinates [left, top, right, bottom] to create a virtual subset.
- Returns:
returns BandSet.
Examples
- Given that a session was previously started
>>> import remotior_sensus >>> rs = remotior_sensus.Session() >>> # set lists of files, names and center wavelength >>> file = ['file_1.tif', 'file_2.tif', 'file_3.tif'] >>> names = ['name_1', 'name_2', 'name_3'] >>> wavelength = [0.6, 0.7, 0.8] >>> # create a BandSet >>> bandset = rs.bandset.create(file,band_names=names,wavelengths=wavelength)
- Passing a directory with file name filter and the wavelenght from satellite name.
>>> bandset = rs.bandset.create(['directory_path', 'tif'], wavelengths='Sentinel-2')
- property crs
crs.
- Type:
str
- property date
Optional date.
- dilation(*args, **kwargs)
Band dilation.
Band dilation directly from the BandSet, passing the argument input_bands. The arguments are related to the function.
- Parameters:
kwargs – See
band_dilation()
.- Returns:
The output of the function.
Examples
- Given that a session was previously started
>>> import remotior_sensus >>> rs = remotior_sensus.Session() >>> bandset = rs.bandset.create(['file1.tif', 'file2.tif'])
- Dilation
>>> dilation = bandset.dilation(output_path='directory_path', ... value_list=[1, 2], size=5)
- erosion(*args, **kwargs)
Band erosion.
Band erosion directly from the BandSet, passing the argument input_bands. The arguments are related to the function.
- Parameters:
kwargs – See
band_erosion()
.- Returns:
The output of the function.
Examples
- Given that a session was previously started
>>> import remotior_sensus >>> rs = remotior_sensus.Session() >>> bandset = rs.bandset.create(['file1.tif', 'file2.tif'])
- Erosion
>>> erosion = bandset.erosion(output_path='directory_path', ... value_list=[1, 2], size=1)
- execute(function, *args, **kwargs)
Executes a function.
Executes a functions directly from the BandSet, passing the argument input_bands. The arguments are related to the function.
- Parameters:
function – the function to be executed.
- Returns:
The output of the function.
Examples
- Given that a session was previously started
>>> import remotior_sensus >>> rs = remotior_sensus.Session() >>> bandset = rs.bandset.create( ... ['file1.tif', 'file2.tif'], wavelengths=['Sentinel-2'], ... )
- Calculation of sum of the first two bands
>>> output_object = bandset.execute( ... rs.band_calc, output_path='output.tif', expression_string='"b1" + "b2"' ... )
- Calculation of NDVI
>>> output_object = bandset.execute( ... rs.band_calc, output_path='output.tif', ... expression_string='("#NIR#" - "#RED#") / ("#NIR#" + "#RED#")' ... )
- Calculation of band combination
>>> output_object = bandset.execute(rs.band_combination, output_path='output.tif')
- export_as_xml(output_path=None)
Exports a BandSet as xml.
Exports a BandSet bands and attributes.
Examples
- Export a BandSet.
>>> bandset = BandSet() >>> # reset >>> bandset.export_as_xml()
- find_values_in_list(attribute, value_list, output_attribute=None) list
Adds new band to a BandSet.
Finds BandSet values in a list and return a band attribute or band numbers.
- Parameters:
attribute – attribute name for identification.
value_list – attribute value list for indentification.
output_attribute – attribute name of desired output; if None returns the band number.
- Returns:
returns list of band attributes.
Examples
- Find values from wavelength attribute
>>> import remotior_sensus >>> rs = remotior_sensus.Session() >>> bandset = BandSet() >>> bandset_values = bandset.find_values_in_list( ... attribute='wavelength', value_list=[0.6, 0.7], ... output_attribute='path' ... )
- static generate_uid() str
Generates unique ID for BandSet
- Returns:
returns table of bands.
- get_absolute_path(band_number) str
Gets the absolute path of band.
- get_absolute_paths() list
Gets the list of absolute paths.
- get_band(number=None) array
Gets a band.
Gets a band by number.
- Parameters:
number – band number.
- Returns:
the band table; if number is None returns all the bands; returns None if band number is not found.
Examples
- Get bands by number
>>> bandset = BandSet() >>> # get first band >>> band = bandset.get_band(1) >>> # band x size >>> band_x_size = band.x_size >>> # get band nodata directly >>> band_nodata = bandset.get_band(1).nodata
- get_band_alias() list
Gets bands alias (with band number) used in band_calc
- Returns:
the list of band aliases.
- get_band_attributes(attribute: str | None = None) list
Gets band attributes.
Gets an attribute of bands.
- Parameters:
attribute – attribute name.
- Returns:
returns list of attributes; if attribute is None returns the bands; if attribute is not found returns None.
Examples
- Get band names
>>> bandset = BandSet() >>> names = bandset.get_band_attributes('name')
- get_band_by_wavelength(wavelength: float, threshold: float | None = None, output_as_number=False) array
Gets band by wavelength.
Gets band by nearest wavelength.
- Parameters:
wavelength – value of wavelength.
threshold – threshold for wavelength identification, identifying bands within wavelength +- threshold; if None, the nearest value is returned.
output_as_number – if True returns the number of the band, if False returns the band table.
- Returns:
returns band table.
Examples
- Get band by wavelength
>>> import remotior_sensus >>> rs = remotior_sensus.Session() >>> bandset = BandSet() >>> # get band by nearest wavelength >>> band_x = bandset.get_band_by_wavelength( >>> wavelength=0.7, threshold=0.1 )
- get_band_count() int
Gets the count of bands.
- get_bands_by_attributes(attribute: str, attribute_value, output_as_number=False) array
Gets bands by attribute.
Gets bands identified by an attribute value (identified bands have the attribute value equal to the attribute_value).
- Parameters:
attribute – attribute name.
attribute_value – attribute value.
output_as_number – if True returns the number of the band, if False returns the band table.
- Returns:
if output_number is True, returns list of band number; if output_number is False, returns bands identified by attribute; returns None if no band has the attribute value.
Examples
- Get bands by attributes
>>> bandset = BandSet() >>> band_x = bandset.get_bands_by_attributes('wavelength',0.8)
- get_path(band_number) str | None
Gets the absolute path of band.
- get_paths() list
Gets the list of bands.
- get_raster_band_list() list
Gets the list of raster bands.
- get_wavelength_units() list
Gets the list of wavelength units.
- get_wavelengths() list
Gets the list of center wavelength.
- import_as_xml(xml_path)
Imports a BandSet as xml.
Imports a BandSet bands and attributes.
Examples
- Import a BandSet
>>> bandset = BandSet() >>> # reset >>> bandset.import_as_xml('xml_path')
- property name
Optional BandSet name.
- Type:
str
- neighbor_pixels(*args, **kwargs)
Band neighbor pixels.
Band neighbor pixels directly from the BandSet, passing the argument input_bands. The arguments are related to the function.
- Parameters:
kwargs – See
band_neighbor_pixels()
.- Returns:
The output of the function.
Examples
- Given that a session was previously started
>>> import remotior_sensus >>> rs = remotior_sensus.Session() >>> bandset = rs.bandset.create(['file1.tif', 'file2.tif'])
- Neighbor pixels
>>> neighbor = bandset.neighbor_pixels(output_path='directory_path', ... size=10, circular_structure=True, stat_name='Sum')
- pca(*args, **kwargs)
Band PCA.
Band PCA directly from the BandSet, passing the argument input_bands. The arguments are related to the function.
- Parameters:
kwargs – See
band_pca()
.- Returns:
The output of the function.
Examples
- Given that a session was previously started
>>> import remotior_sensus >>> rs = remotior_sensus.Session() >>> bandset = rs.bandset.create(['file1.tif', 'file2.tif'])
- PCA
>>> pca = bandset.pca(output_path='directory_path')
- print()
Prints a BandSet.
Prints a BandSet bands and attributes.
Examples
- Print a BandSet.
>>> bandset = BandSet() >>> # reset >>> bandset.print()
- reset()
Resets a BandSet.
Resets a BandSet destroyng bands and attributes.
Examples
- Reset a BandSet
>>> bandset = BandSet() >>> # reset >>> bandset.reset()
- property root_directory
Optional BandSet root directory for relative path.
- Type:
str
- sieve(*args, **kwargs)
Band sieve.
Band sieve directly from the BandSet, passing the argument input_bands. The arguments are related to the function.
- Parameters:
kwargs – See
band_sieve()
.- Returns:
The output of the function.
Examples
- Given that a session was previously started
>>> import remotior_sensus >>> rs = remotior_sensus.Session() >>> bandset = rs.bandset.create(['file1.tif', 'file2.tif'])
- Sieve
>>> sieve = bandset.sieve(output_path='directory_path', size=3)
- sort_bands_by_name(keep_wavelength_order=True)
Sorts band order by name
- sort_bands_by_wavelength()
Sorts band order by wavelength
- spectral_range_bands(output_as_number=True) list
Gets bands from spectral range.
Gets bands from spectral range blue, green, red, nir, swir_1, swir_2.
- Parameters:
output_as_number – if True returns the number of the band, if False returns the band table.
- Returns:
returns list of bands.
Examples
- Gets bands from spectral range
>>> import remotior_sensus >>> rs = remotior_sensus.Session() >>> bandset = BandSet() >>> # spectral range bands >>> (blue_band, green_band, red_band, nir_band, swir_1_band, ... swir_2_band) = bandset.spectral_range_bands( ... output_as_number=False)
- property uid
Unique BandSet ID.
- Type:
str
- class remotior_sensus.core.bandset_catalog.BandSetCatalog
Bases:
object
Manages BandSets.
This class manages BandSets through a catalog, defining attributes and properties of BandSets.
- bandsets
dictionary of the actual BandSets
- bandsets_table
table of BandSets containing the properties thereof
- get
alias for get_bandset
Examples
- Create a BandSet Catalog
>>> import remotior_sensus >>> rs = remotior_sensus.Session() >>> catalog = rs.bandset_catalog()
- __init__()
Initializes the catalog with an empty BandSet
- add_band_to_bandset(path: str, bandset_number: None | int = None, band_number: None | int = None, raster_band: None | int = None, band_name: None | str = None, date: None | str = None, unit: None | str = None, root_directory: None | str = None, multiplicative_factor: None | int = None, additive_factor: None | int = None, wavelength: None | float = None)
Adds a new band to BandSet.
This function creates a new band and adds it to a BandSet.
- Parameters:
path – file path.
band_name – raster name used for identifying the bands.
wavelength – center wavelengths of band.
unit – wavelength unit as string
multiplicative_factor – multiplicative factor for bands during calculations.
additive_factor – additive factors for band during calculations.
date – date string (format YYYY-MM-DD).
bandset_number – number of the BandSet; if None, the band is added to the current BandSet.
root_directory – root directory for relative path.
raster_band – raster band number.
band_number – number of band in BandSet.
Examples
- Add a band to BandSet 1.
>>> catalog = BandSetCatalog() >>> catalog.add_band_to_bandset( path='file1.tif', bandset_number=1, band_number=1, raster_band=1 ... )
- add_bandset(bandset: BandSet, bandset_number: None | int = None, insert=False, keep_uid=False)
Adds a BandSet to Catalog.
This function adds a previously created BandSet to BandSet Catalog.
- Parameters:
bandset – the BandSet to be added.
bandset_number – number of BandSet; if None, current BandSet is used.
insert – if True insert the BandSet at bandset_number (other BandSets are moved), if False replace the BandSet number.
keep_uid – if True, keeps uid from the original bandset to the added one.
Examples
- Insert a BandSet as BandSet 1.
>>> catalog = BandSetCatalog() >>> catalog.add_bandset(bandset_number=1, insert=True ... )
- build_bandset_band_overview(bandset_number: int | None = None) bool
Build bandset band overviews.
Build bandset band overviews as external files to faster the visualization.
- Parameters:
bandset_number – number of BandSet; if None, current BandSet is used.
- Returns:
True if successfull.
Examples
- Build BandSet 1 overview.
>>> catalog = BandSetCatalog() >>> catalog.build_bandset_band_overview(1)
- calculate_scatter_plot_histogram(bandset_number: int, band_x: int, band_y: int, vector_path: str) bool
Calculate scatter plot histogram.
Calculate scatter plot histogram from two bands and a vector, useful for scatter plot display.
- Parameters:
bandset_number – number of BandSet; if None, current BandSet is used.
band_x – number of band x.
band_y – number of band y.
vector_path – path to the vector used for histogram calculation.
- Returns:
NumPy histogram.
Examples
- Caculate BandSet 1 scatter plot.
>>> catalog = BandSetCatalog() >>> catalog.calculate_scatter_plot_histogram( ... bandset_number= 1, band_x=1, band_y=1, vector_path='path')
- clear_bandset(bandset_number=None)
Function to clear a BandSet.
- create_band_string_list(bandset_number: int | None = None) list
Creates band string list.
Creates band string list such as “bandset1b1” for all the bands in a BandSet. Used in tool
band_calc()
.- Parameters:
bandset_number – number of BandSet; if None, current BandSet is used.
- Returns:
List of band string such as [“bandset1b1”, “bandset1b2”].
Examples
- Get BandSet 1 band string list.
>>> catalog = BandSetCatalog() >>> catalog.create_band_string_list(1)
- create_bandset(paths: str | list | None = None, band_names: list | None = None, wavelengths: list | None = None, unit: None | str = None, multiplicative_factors: list | None = None, additive_factors: list | None = None, date: list | None = None, bandset_number: None | int = None, insert: bool | None = False, root_directory: None | str = None, bandset_name: None | str = None, box_coordinate_list: list | None = None) BandSet
Creates a BandSet adding it to the catalog.
This function creates a BandSet adding it to the catalog, by inserting or replacing the BandSet at specific BandSet number. Wavelength is defined by providing a list of values for each band, or a string of sensors names as defined in configurations sat_band_list such as:
Sentinel-2;
Landsat 8;
Landsat 5;
ASTER.
Wavelength unit is defined by a string such as:
band number unitless band order as defined in the BandSet;
µm (1 E-6m) micrometers;
nm (1 E-9m) nanometers.
- Parameters:
paths – list of file paths or a string of directory path; also, a list of directory path and name filter is accepted.
band_names – list of raster names used for identifying the bands, if None then the names are automatically extracted from file names.
wavelengths – list of center wavelengths of bands or string of sensor names (also partial).
unit – wavelength unit as string
multiplicative_factors – multiplicative factors for bands during calculations.
additive_factors – additive factors for bands during calculations.
date – list of date strings, or single date string (format YYYY-MM-DD) or string defined in configurations date_auto to detect date from directory name.
bandset_number – number of the BandSet, replacing an existing BandSet with the same number.
insert – if True insert the BandSet at bandset_number, if False replace the BandSet number.
root_directory – root directory for relative path.
bandset_name – name of the BandSet.
box_coordinate_list – list of coordinates [left, top, right, bottom] to create a virtual subset.
- Returns:
The created BandSet.
Examples
- Create a first BandSet from a file list with files inside a data directory, setting root_directory, defining the BandSet date, and the wavelenght from satellite name.
>>> catalog = BandSetCatalog() >>> file_list = ['file1.tif', 'file2.tif', 'file3.tif'] >>> bandset_date = '2021-01-01' >>> data_directory = 'data' >>> bandset = catalog.create_bandset( ... paths=file_list, wavelengths=['Sentinel-2'], date=bandset_date, ... root_directory=data_directory ... )
- Create a new BandSet from a file list with files inside a data directory (setting root_directory), defining the BandSet date, and explicitly defining the BandSet number.
>>> catalog = BandSetCatalog() >>> file_list = ['file1.tif', 'file2.tif', 'file3.tif'] >>> bandset_date = '2021-01-01' >>> data_directory = 'data' >>> bandset = catalog.create_bandset( ... paths=file_list, wavelengths=['Sentinel-2'], date=bandset_date, ... bandset_number=2, root_directory=data_directory ... )
- Passing a directory with file name filter and the wavelenght from satellite name.
>>> bandset = catalog.create_bandset(['directory_path', 'tif'], wavelengths='Sentinel-2')
- create_bandset_stack(bandset_number: int | None = None, output_path: str | None = None, nodata_value: int | None = None, intersection: bool = False) str
Creates a raster stack of a bandset.
Stacks the raster bands of a bandset in a multiband raster.
- Parameters:
output_path – output path of the raster; if None, use temporary path.
bandset_number – number of BandSet; if None, current BandSet is used.
nodata_value – nodata value.
intersection – if True get minimum extent from input intersection, if False get maximum extent from union.
- Returns:
Path of the output raster.
Examples
- Create BandSet 1 raster.
>>> catalog = BandSetCatalog() >>> catalog.create_bandset_stack(1)
- create_jpg(bandset_number: int | None = None, bands: list | None = None, output_path: str | None = None, quality: int = 90, nodata_value: int | None = None, intersection: bool = False) str
Creates a jpg raster of a bandset.
Createsa a jpg raster of a bandset.
- Parameters:
bandset_number – number of BandSet; if None, current BandSet is used.
bands – list of 3 band numbers (e.g., [3, 2, 1])
output_path – output path of the jpg raster; if None, use temporary path.
quality – jpg quality, default 85.
nodata_value – nodata value.
intersection – if True get minimum extent from input intersection, if False get maximum extent from union.
- Returns:
Path of the output jpg file.
Examples
- Create BandSet 1 jpg.
>>> catalog = BandSetCatalog() >>> catalog.create_jpg(1)
- create_virtual_raster(bandset_number: int | None = None, output_path: str | None = None, nodata_value: int | None = None, intersection: bool = False) str
Creates the virtual raster of a bandset.
Creates the virtual raster of a bandset.
- Parameters:
output_path – output path of the virtual raster; if None, use temporary path.
bandset_number – number of BandSet; if None, current BandSet is used.
nodata_value – nodata value.
intersection – if True get minimum extent from input intersection, if False get maximum extent from union.
- Returns:
Path of the output virtual raster.
Examples
- Create BandSet 1 virtual raster.
>>> catalog = BandSetCatalog() >>> catalog.create_virtual_raster(1)
- property current_bandset: int
Property that defines the current BandSet in the catalog.
This property identifies a BandSet number which is considered current (i.e. active) in several other tools when no BandSet is specified.
- Returns:
The integer number of current BandSet.
Examples
- Get current BandSet.
>>> catalog = BandSetCatalog() >>> bandset_number = catalog.current_bandset >>> print(bandset_number) 1
- Set current BandSet.
>>> catalog = BandSetCatalog() >>> print(catalog.current_bandset) 1 >>> catalog.current_bandset = 2 >>> print(catalog.current_bandset) 2
- export_bandset_as_xml(bandset_number, output_path=None)
Function to export a BandSet as xml.
- find_bandset_names_in_list(names: list, lower=True, output_number=True, exact_match=False) list
Finds BandSet names.
- This function finds BandSet names in a list and return BandSets
or BandSet numbers.
- Parameters:
names – list of string names.
lower – if True, finds by lowering all the names.
output_number – if True returns the number of the band, if False returns the BandSet.
exact_match – if True, names are compared by equality.
- Returns:
if output_number is True, returns list of band number; if output_number is False, returns list of BandSets.
Examples
- Find BandSet from name list.
>>> catalog = BandSetCatalog() >>> name_list = ['name1', 'name2'] >>> bandsets = catalog.find_bandset_names_in_list(names=name_list)
- get_band_count(bandset_number: None | int = None) None | int
Gets band count.
Gets band count of a BandSet.
- Parameters:
bandset_number – number of BandSet; if None, current BandSet is used.
- Returns:
Count of bands.
Examples
- Get BandSet 1 band count.
>>> catalog = BandSetCatalog() >>> catalog.get_band_count(1)
- static get_band_list(bandset: int | list | BandSet = None, bandset_catalog: Optional = None) list
Gets band list.
This function gets band list from several types of input.
- Parameters:
bandset – input of type BandSet or list of paths or integer number of BandSet.
bandset_catalog – optional type BandSetCatalog if bandset argument is a number.
- Returns:
- If argument bandset is a BandSet or a BandSet number,
returns list of bands in the BandSet; if argument bandset is already a list, returns the same list.
Examples
- Get band list of BandSet 1.
>>> # import Remotior Sensus and start the session >>> import remotior_sensus >>> rs = remotior_sensus.Session() >>> catalog = BandSetCatalog() >>> list_1 = rs.bandset_catalog.get_band_list(1, catalog) >>> # which is equivalent to >>> bandset_1 = bandset_catalog.get_bandset(1) >>> list_2 = bandset_1.get_absolute_paths()
- get_bandset(bandset_number: int | None = None, attribute: None | str = None) None | str | list | BandSet
Get BandSet or BandSet attributes by number of the BandSet.
- This function gets the BandSet or BandSet attributes by the number
of the BandSet.
- Parameters:
bandset_number – number of the BandSet
attribute – string of the attribute name, if None then the BandSet is returned
- Returns:
The BandSet band attributes or the BandSet.
Examples
- Get the ‘name’ attribute of bands of the BandSet 1.
>>> catalog = BandSetCatalog() >>> names = catalog.get_bandset(bandset_number=1, attribute='name') >>> print(names) ['file1', 'file2', 'file3']
- Get the BandSet 1.
>>> catalog = BandSetCatalog() >>> bandset_1 = catalog.get_bandset(bandset_number=1) >>> print(bandset_1) BandSet
- get_bandset_bands_by_attribute(bandset_number: int, attribute: str, attribute_value: float | int | str, output_number: bool | None = False) None | list | recarray
Get BandSet bands from the attributes thereof.
- This function gets BandSet bands or the band number of bands whose
attributes match an attribute value.
- Parameters:
bandset_number – number of the BandSet
attribute – string of the attribute name
attribute_value – value of the band attribute to find
output_number – if True then the output is the band number list, if False then the output is the band array
- Returns:
The band number list or the array of bands.
Examples
- Get the ‘name’ attribute of bands of the BandSet 1.
>>> catalog = BandSetCatalog() >>> band_number = catalog.get_bandset_bands_by_attribute(bandset_number=1,attribute='wavelength',attribute_value=0.443,output_number=True) >>> print(band_number) [2]
- Get the BandSet 1.
>>> catalog = BandSetCatalog() >>> band_x = catalog.get_bandset_bands_by_attribute(bandset_number=1,attribute='wavelength',attribute_value=0.443,output_number=True) >>> print(band_x) [(1, 1, '/data/file1.tif', '/data/file1.tif', 'file1', 0.443, 'µm (1 E-6m)', ...]
- get_bandset_by_name(bandset_name: str, output_number: bool | None = False) None | int | BandSet
Get BandSet by name thereof.
This function gets the BandSet by the name thereof.
- Parameters:
bandset_name – name of the BandSet
output_number – if True then the output is the BandSet number, if False then the output is the BandSet
- Returns:
The BandSet identified by the name.
Examples
- Get the number of the BandSet having the name ‘example’.
>>> catalog = BandSetCatalog() >>> bandset_number = catalog.get_bandset_by_name( bandset_name='example', output_number=True) >>> print(bandset_number) 3
- Get the BandSet having the name ‘example’.
>>> catalog = BandSetCatalog() >>> bandset = catalog.get_bandset_by_name( bandset_name='example', output_number=False) >>> print(bandset) BandSet object
- get_bandset_by_number(number: int) None | BandSet
Get BandSet by number thereof.
This function gets the BandSet by the number thereof.
- Parameters:
number – number of the BandSet
- Returns:
The BandSet identified by the number.
Examples
- Get the first BandSet.
>>> catalog = BandSetCatalog() >>> bandset_1 = catalog.get_bandset_by_number(1) >>> print(bandset_1) BandSet object
- get_bandset_catalog_attributes(bandset_number: int, attribute: None | str = None) None | str | list
Get BandSet Catalog attributes by number of the BandSet.
- This function gets the BandSet Catalog attributes by number of the
BandSet.
- Parameters:
bandset_number – number of the BandSet
attribute – string of the attribute name, if None then the list of attributes is returned
- Returns:
- The BandSet attribute or the list of attributes
(‘bandset_number’, ‘bandset_name’, ‘date’, ‘root_directory’, ‘uid’).
Examples
- Get the ‘date’ attribute of the BandSet 1.
>>> catalog = BandSetCatalog() >>> date = catalog.get_bandset_catalog_attributes(bandset_number=1, attribute='date') >>> print(date) 2000-12-31
- Get the list of attributes of the BandSet 1.
>>> catalog = BandSetCatalog() >>> attributes = catalog.get_bandset_catalog_attributes(bandset_number=1) >>> print(attributes) [(1, 'example', '2000-12-31', 'None', '20000101_1605495327_293')]
- get_bandset_count() int
Gets count of BandSets in the catalog.
This function gets the count of BandSets present in the catalog.
- Returns:
The integer number of BandSets.
Examples
- Count of BandSets present.
>>> catalog = BandSetCatalog() >>> count = catalog.get_bandset_count() >>> print(count) 1
- get_bandsets_by_date(date_list: list, output_number: bool | None = False) list
Get BandSets by date.
This function gets the BandSets by date.
- Parameters:
date_list – list of date strings, or single date string (format YYYY-MM-DD); it can also include ranges using > or <, multiple conditions including &
output_number – if True then the output is the BandSet number, if False then the output is the BandSet
- Returns:
The BandSet identified by the name.
Examples
- Get the number of the BandSet by date.
>>> catalog = BandSetCatalog() >>> bandset_number = catalog.get_bandsets_by_date(date_list=['2020-01-01'], output_number=True) >>> print(bandset_number) [1]
- Get the number of the BandSet by range of dates.
>>> catalog = BandSetCatalog() >>> bandset_number = catalog.get_bandsets_by_date(date_list=['2020-01-01', '>=2021-01-01 & <=2022-01-02'], output_number=True) >>> print(bandset_number) [1, 3]
- get_bandsets_by_list(bandset_list: list | None = None, output_number: bool | None = False) list
Gets BandSets by list.
This function gets all the BandSets in the Catalog or filtered using a list of BandSet numbers.
- Parameters:
bandset_list – list of integers BandSet numbers.
output_number – if True, returns the list of BandSet number; if False, returns the list of BandSet object.
- Returns:
List of BandSets, or list of BandSets numbers if output_number is True.
Examples
- Get BandSets.
>>> catalog = BandSetCatalog() >>> bandset_t = catalog.get_bandsets_by_list() >>> for bandset in bandset_t: >>> print(bandset)
- get_bbox(bandset_number: int | None = None) None | list
Get BandSet bounding box.
This function gets the bounding box coordinates of a BandSet.
- Parameters:
bandset_number – number of the BandSet
- Returns:
The bounding box coordinates [left, top, right, bottom].
Examples
- Get the bounding box of the BandSet 1.
>>> catalog = BandSetCatalog() >>> names = catalog.get_bandset(bandset_number=1) >>> print(names) ['file1', 'file2', 'file3']
- Get the BandSet 1.
>>> catalog = BandSetCatalog() >>> bandset_1 = catalog.get_bandset(bandset_number=1) >>> print(bandset_1) BandSet
- get_box_coordinate_list(bandset_number: int | None = None) None | list
Gets BandSet box coordinate list.
Gets BandSet box coordinate list.
- Parameters:
bandset_number – number of BandSet; if None, current BandSet is used.
- Returns:
List of box coordinates [left, top, right, bottom].
Examples
- Get BandSet 1 band count.
>>> catalog = BandSetCatalog() >>> catalog.get_box_coordinate_list(1)
- get_crs(bandset_number: None | int = None)
Gets BandSet crs.
Gets BandSet crs from Bandset information.
- Parameters:
bandset_number – number of BandSet; if None, current BandSet is used.
Examples
- Get BandSet 1 crs.
>>> catalog = BandSetCatalog() >>> catalog.get_crs(bandset_number=1)
- get_date(bandset_number: None | int = None) str
Gets BandSet date.
Gets BandSet date.
- Parameters:
bandset_number – number of BandSet; if None, current BandSet is used.
- Returns:
Date string.
Examples
- Get BandSet 1 date.
>>> catalog = BandSetCatalog() >>> catalog.get_date(1)
- get_name(bandset_number: None | int = None) str
Gets BandSet name.
Gets BandSet name.
- Parameters:
bandset_number – number of BandSet; if None, current BandSet is used.
- Returns:
BandSet name.
Examples
- Get BandSet 1 date.
>>> catalog = BandSetCatalog() >>> catalog.get_name(1)
- get_root_directory(bandset_number: None | int = None) str
Gets BandSet root directory.
Gets BandSet root directory.
- Parameters:
bandset_number – number of BandSet; if None, current BandSet is used.
- Returns:
Root directory string.
Examples
- Get BandSet 1 root directory.
>>> catalog = BandSetCatalog() >>> catalog.get_root_directory(1)
- import_bandset_from_xml(bandset_number, xml_path)
Function to import a BandSet from xml.
- iterate_bandset_bands(attribute: str) list
Iterates BandSet attributes.
- This function gets BandSet attributes iterating all the BandSets
in the Catalog.
- Parameters:
attribute – attribute name.
- Returns:
List of attributes
Examples
- Get BandSet names.
>>> catalog = BandSetCatalog() >>> names = catalog.iterate_bandset_bands('name')
- move_band_in_bandset(band_number_input: int, band_number_output: int, bandset_number: None | int = None, wavelength=True)
Moves band in Bandset.
This function reorders a band in a Bandset.
- Parameters:
band_number_input – number of band to be moved.
band_number_output – position of the moved band.
bandset_number – number of BandSet; if None, current BandSet is used.
wavelength – if True, keep the wavelength attributes of the band order.
Examples
- Move the second band of the BandSet 1 to position 5.
>>> catalog = BandSetCatalog() >>> catalog.move_band_in_bandset( ... bandset_number=1, band_number_input=2, band_number_output=5 ... )
- move_bandset(bandset_number_input: int, bandset_number_output: int)
Moves a BandSet.
This function reorders a BandSet in the BandSet Catalog.
- Parameters:
bandset_number_input – the BandSet number to be moved.
bandset_number_output – the new poistion of BandSet.
Examples
- Move BandSet 1 to position 3.
>>> catalog = BandSetCatalog() >>> catalog.move_bandset(bandset_number_input=1, bandset_number_output=3)
- print_bandset(bandset_number=None)
Function to print a BandSet bands and attributes.
- remove_band_in_bandset(band_number: int, bandset_number: None | int = None)
Removes band in Bandset.
This function removes a band in Bandset identified by a number. Automatically reorders other band numbers.
- Parameters:
band_number – number of band to be removed.
bandset_number – number of BandSet; if None, current BandSet is used.
Examples
- Remove the second band of the BandSet.
>>> catalog = BandSetCatalog() >>> catalog.remove_band_in_bandset( ... bandset_number=1, band_number=2 ... )
- remove_bandset(bandset_number: int)
Removes a BandSet.
This function removes a BandSet by the number thereof.
- Parameters:
bandset_number – the BandSet number to be removed.
Examples
- Remove BandSet 2.
>>> catalog = BandSetCatalog() >>> catalog.remove_bandset(2)
- reset()
Resets the BandSets Catalog.
- This function resets the BandSets Catalog removing all BandSets and
creating an empty one.
Examples
- Reset the BandSets catalog.
>>> catalog = BandSetCatalog() >>> catalog.reset()
- set_box_coordinate_list(box_coordinate_list: list, bandset_number: None | int = None)
Sets BandSet box coordinate list.
Sets BandSet box coordinate list for virtual subset.
- Parameters:
box_coordinate_list – list of coordinates [left, top, right, bottom] to create a virtual subset.
bandset_number – number of BandSet; if None, current BandSet is used.
Examples
- Set BandSet 1 coordinate list.
>>> catalog = BandSetCatalog() >>> catalog.set_box_coordinate_list( ... bandset_number=1, box_coordinate_list=[230000, 4680000, 232000, 4670000] ... )
- set_crs(crs: str, bandset_number: None | int = None)
Sets BandSet crs.
Sets BandSet crs from Bandset information.
- Parameters:
crs – crs string.
bandset_number – number of BandSet; if None, current BandSet is used.
Examples
- Set BandSet 1 crs.
>>> catalog = BandSetCatalog() >>> catalog.set_crs(bandset_number=1, crs='PROJCS["WGS 84 / UTM zone 33N"...')
- set_date(date: str, bandset_number: None | int = None)
Sets BandSet date.
Sets BandSet date.
- Parameters:
date – date string (format YYYY-MM-DD).
bandset_number – number of BandSet; if None, current BandSet is used.
Examples
- Set BandSet 1 date.
>>> catalog = BandSetCatalog() >>> catalog.set_date(bandset_number=1, date='2021-01-01')
- set_name(name: str, bandset_number: int | None = None)
Sets BandSet name.
Sets BandSet name.
- Parameters:
name – name.
bandset_number – number of BandSet; if None, current BandSet is used.
Examples
- Set BandSet 1 name.
>>> catalog = BandSetCatalog() >>> catalog.set_name(bandset_number=1, name='example')
- set_paths(path_list, bandset_number=None)
Sets BandSet band path.
Sets BandSet band path based on list of paths.
- Parameters:
path_list – list of string paths.
bandset_number – number of BandSet; if None, current BandSet is used.
Examples
- Set BandSet 1 satellite wavelengths.
>>> catalog = BandSetCatalog() >>> catalog.set_satellite_wavelength( ... bandset_number=1, path_list=['path_1', 'path_2'] ... )
- set_root_directory(root_directory: str, bandset_number: None | int = None)
Sets BandSet root directory.
Sets BandSet root directory for relative path.
- Parameters:
root_directory – root directory path.
bandset_number – number of BandSet; if None, current BandSet is used.
Examples
- Set BandSet 1 root directory.
>>> catalog = BandSetCatalog() >>> catalog.set_root_directory(bandset_number=1, root_directory='data_directory')
- set_satellite_wavelength(satellite_name, bandset_number=None)
Sets BandSet center wavelength based on satellite.
Sets BandSet center wavelength based on satellite name.
- Parameters:
satellite_name – name of satellite (e.g., Landsat 8)
bandset_number – number of BandSet; if None, current BandSet is used.
Examples
- Set BandSet 1 satellite wavelengths.
>>> catalog = BandSetCatalog() >>> catalog.set_satellite_wavelength( ... bandset_number=1, satellite_name='Sentinel-2' ... )
- set_wavelength(wavelength_list, unit, bandset_number=None)
Sets BandSet center wavelength based on list.
Sets BandSet center wavelength based on list.
- Parameters:
wavelength_list – list of wavelength values.
bandset_number – number of BandSet; if None, current BandSet is used.
unit – wavelength unit.
Examples
- Set BandSet 1 satellite wavelengths.
>>> catalog = BandSetCatalog() >>> catalog.set_satellite_wavelength( ... bandset_number=1, wavelength_list=[1, 2, 3], unit='µm (1 E-6m)' ... )
- sort_bands_by_name(bandset_number: None | int = None, keep_wavelength_order: bool | None = True)
Sorts bands by name.
This function numerically sorts bands in a BandSet by name.
- Parameters:
bandset_number – number of BandSet; if None, current BandSet is used.
keep_wavelength_order – if True, keep wavelength_order.
Examples
- Sort bands in BandSet 1.
>>> catalog = BandSetCatalog() >>> catalog.sort_bands_by_name(bandset_number=1)
- sort_bands_by_wavelength(bandset_number: None | int = None)
Sorts bands by wavelength.
This function numerically sorts bands in a BandSet by wavelength center.
- Parameters:
bandset_number – number of BandSet; if None, current BandSet is used.
Examples
- Sort bands in BandSet 1.
>>> catalog = BandSetCatalog() >>> catalog.sort_bands_by_wavelength(bandset_number=1)
- sort_bandsets_by_date()
Sort BandSets by BandSet date.
This function sorts BandSets in the BandSet Catalog based on the date.
Examples
- Sort BandSets.
>>> catalog = BandSetCatalog() >>> catalog.sort_bandsets_by_date()
- update_crs(bandset_number: None | int = None)
Updates BandSet crs.
Updates BandSet crs from Bandset first band.
- Parameters:
bandset_number – number of BandSet; if None, current BandSet is used.
Examples
- Update BandSet 1 crs.
>>> catalog = BandSetCatalog() >>> catalog.update_crs(bandset_number=1)