In [1]:
from snapista import Graph
from snapista import Operator
from snapista import TargetBand
from snapista import TargetBandDescriptors
In [5]:
r = Operator("Read", file='/data/S2B_MSIL2A_20210608T112119_N0300_R037_T29SMC_20210608T131325.SAFE/MTD_MSIL2A.xml')
In [3]:
r
Out[3]:
Operator('Read', file='None', formatName='None', bandNames='None', maskNames='None', pixelRegion='None', geometryRegion='None', copyMetadata='true')
In [ ]:
 

Operator

Instantiate a SNAP operator by providing its name:

In [2]:
calibration = Operator('Calibration')

calibration
Out[2]:
Operator('Calibration', sourceBandNames='None', auxFile='Latest Auxiliary File', externalAuxFile='None', outputImageInComplex='false', outputImageScaleInDb='false', createGammaBand='false', createBetaBand='false', selectedPolarisations='None', outputSigmaBand='true', outputGammaBand='false', outputBetaBand='false')

Get the SNAP Operator description:

In [3]:
calibration.describe()
Operator name: Calibration

Description: Calibration of products
Authors: Jun Lu, Luis Veci

org.esa.s1tbx.calibration.gpf.CalibrationOp
Version: 1.0

Parameters:

	sourceBandNames: The list of source bands.
		Default Value: None

		Possible values: []

	auxFile: The auxiliary file
		Default Value: Latest Auxiliary File

		Possible values: ['Latest Auxiliary File', 'Product Auxiliary File', 'External Auxiliary File']

	externalAuxFile: The antenna elevation pattern gain auxiliary data file.
		Default Value: None

		Possible values: []

	outputImageInComplex: Output image in complex
		Default Value: false

		Possible values: []

	outputImageScaleInDb: Output image scale
		Default Value: false

		Possible values: []

	createGammaBand: Create gamma0 virtual band
		Default Value: false

		Possible values: []

	createBetaBand: Create beta0 virtual band
		Default Value: false

		Possible values: []

	selectedPolarisations: The list of polarisations
		Default Value: None

		Possible values: []

	outputSigmaBand: Output sigma0 band
		Default Value: true

		Possible values: []

	outputGammaBand: Output gamma0 band
		Default Value: false

		Possible values: []

	outputBetaBand: Output beta0 band
		Default Value: false

		Possible values: []

Instantiate a SNAP operator by providing its name and update a parameter value

In [4]:
calibration = Operator('Calibration')
In [5]:
dir(calibration)
Out[5]:
['__class__',
 '__delattr__',
 '__dict__',
 '__dir__',
 '__doc__',
 '__eq__',
 '__format__',
 '__ge__',
 '__getattribute__',
 '__gt__',
 '__hash__',
 '__init__',
 '__init_subclass__',
 '__le__',
 '__lt__',
 '__module__',
 '__ne__',
 '__new__',
 '__reduce__',
 '__reduce_ex__',
 '__repr__',
 '__setattr__',
 '__sizeof__',
 '__str__',
 '__subclasshook__',
 '__weakref__',
 '_get_formats',
 '_params',
 'auxFile',
 'createBetaBand',
 'createGammaBand',
 'describe',
 'externalAuxFile',
 'operator',
 'outputBetaBand',
 'outputGammaBand',
 'outputImageInComplex',
 'outputImageScaleInDb',
 'outputSigmaBand',
 'selectedPolarisations',
 'sourceBandNames',
 'to_dict']
In [6]:
calibration.createBetaBand = 'true'

calibration
Out[6]:
Operator('Calibration', sourceBandNames='None', auxFile='Latest Auxiliary File', externalAuxFile='None', outputImageInComplex='false', outputImageScaleInDb='false', createGammaBand='false', createBetaBand='true', selectedPolarisations='None', outputSigmaBand='true', outputGammaBand='false', outputBetaBand='false')

Instantiate a SNAP operator by providing its name and setting the values in the constructor

In [7]:
calibration = Operator('Calibration', 
                       createBetaBand='true', 
                       createGammaBand='true')

calibration
Out[7]:
Operator('Calibration', sourceBandNames='None', auxFile='Latest Auxiliary File', externalAuxFile='None', outputImageInComplex='false', outputImageScaleInDb='false', createGammaBand='true', createBetaBand='true', selectedPolarisations='None', outputSigmaBand='true', outputGammaBand='false', outputBetaBand='false')
In [8]:
print(calibration)
Calibration:
	sourceBandNames='None'
	auxFile='Latest Auxiliary File'
	externalAuxFile='None'
	outputImageInComplex='false'
	outputImageScaleInDb='false'
	createGammaBand='true'
	createBetaBand='true'
	selectedPolarisations='None'
	outputSigmaBand='true'
	outputGammaBand='false'
	outputBetaBand='false'

Graph

Create a graph:

In [9]:
g = Graph()

g
Out[9]:
Graph(wdir='.')
In [10]:
print(g)
gpt binary: /srv/conda/envs/notebook/snap/bin/gpt
working dir: .

<graph>
  <version>1.0</version>
</graph>

Add two nodes:

In [11]:
g.add_node(operator=Operator('Read'), 
           node_id='read_1')

calibration = Operator('Calibration')

calibration.createBetaBand = 'false'

g.add_node(operator=calibration, 
           node_id='calibration', 
           source='read_1')
In [12]:
g.view()
<graph>
  <version>1.0</version>
  <node id="read_1">
    <operator>Read</operator>
    <sources/>
    <parameters class="com.bc.ceres.binding.dom.XppDomElement">
      <bandNames/>
      <copyMetadata>true</copyMetadata>
      <file/>
      <formatName/>
      <geometryRegion/>
      <maskNames/>
      <pixelRegion/>
    </parameters>
  </node>
  <node id="calibration">
    <operator>Calibration</operator>
    <sources>
      <sourceProduct refid="read_1"/>
    </sources>
    <parameters class="com.bc.ceres.binding.dom.XppDomElement">
      <auxFile>Latest Auxiliary File</auxFile>
      <createBetaBand>false</createBetaBand>
      <createGammaBand>false</createGammaBand>
      <externalAuxFile/>
      <outputBetaBand>false</outputBetaBand>
      <outputGammaBand>false</outputGammaBand>
      <outputImageInComplex>false</outputImageInComplex>
      <outputImageScaleInDb>false</outputImageScaleInDb>
      <outputSigmaBand>true</outputSigmaBand>
      <selectedPolarisations/>
      <sourceBandNames/>
    </parameters>
  </node>
</graph>

In [13]:
print(g)
gpt binary: /srv/conda/envs/notebook/snap/bin/gpt
working dir: .

<graph>
  <version>1.0</version>
  <node id="read_1">
    <operator>Read</operator>
    <sources/>
    <parameters class="com.bc.ceres.binding.dom.XppDomElement">
      <bandNames/>
      <copyMetadata>true</copyMetadata>
      <file/>
      <formatName/>
      <geometryRegion/>
      <maskNames/>
      <pixelRegion/>
    </parameters>
  </node>
  <node id="calibration">
    <operator>Calibration</operator>
    <sources>
      <sourceProduct refid="read_1"/>
    </sources>
    <parameters class="com.bc.ceres.binding.dom.XppDomElement">
      <auxFile>Latest Auxiliary File</auxFile>
      <createBetaBand>false</createBetaBand>
      <createGammaBand>false</createGammaBand>
      <externalAuxFile/>
      <outputBetaBand>false</outputBetaBand>
      <outputGammaBand>false</outputGammaBand>
      <outputImageInComplex>false</outputImageInComplex>
      <outputImageScaleInDb>false</outputImageScaleInDb>
      <outputSigmaBand>true</outputSigmaBand>
      <selectedPolarisations/>
      <sourceBandNames/>
    </parameters>
  </node>
</graph>

Get a list of the SNAP operators

In [14]:
Graph.list_operators()
Out[14]:
['CloudProb',
 'LandWaterMask',
 'Resample',
 'S2Resampling',
 'ReplaceMetadata',
 'Polarimetric-Decomposition',
 'Meris.LandClassification',
 'Terrain-Flattening',
 'TsaviOp',
 'McariOp',
 'Three-passDInSAR',
 'OlciO2aHarmonisation',
 'Polarimetric-Speckle-Filter',
 'SnaphuImport',
 'Meris.Mod08Aerosol',
 'CP-Simulation',
 'Maximum-Likelihood-Classifier',
 'ForestCoverChangeOp',
 'BandMaths',
 'Meris.AerosolMerger',
 'AATSR.Ungrid',
 'FUB.Water',
 'SmacOp',
 'Image-Filter',
 'Terrain-Correction',
 'AdaptiveThresholding',
 'LinearToFromdB',
 'PixEx',
 'RangeFilter',
 'Back-Geocoding',
 'c2rcc.olci',
 'Meris.CloudShadow',
 'SetNoDataValue',
 'Polarimetric-Matrices',
 'PhaseToHeight',
 'TestPattern',
 'TemporalPercentile',
 'DeburstWSS',
 'IEM-Multi-Angle-Inversion',
 'Minimum-Distance-Classifier',
 'PduStitching',
 'Mosaic',
 'DecisionTree',
 'Meris.Brr',
 'ReflectanceToRadianceOp',
 'CiOp',
 'Oil-Spill-Clustering',
 'Stack-Split',
 'ToolAdapterOp',
 'PhaseToDisplacement',
 'Random-Forest-Classifier',
 'RemoteExecutionOp',
 'BandMerge',
 'PCA',
 'c2rcc.meris',
 'Wind-Field-Estimation',
 'Read',
 'KNN-Classifier',
 'S2tbx-Reproject',
 'SRGR',
 'MtciOp',
 'SAR-Mosaic',
 'L3ToL1',
 'Oil-Spill-Detection',
 'ArviOp',
 'Meris.SmileCorrection',
 'SnaphuExport',
 'Double-Difference-Interferogram',
 'Mci.s2',
 'Multi-size Mosaic',
 'TndviOp',
 'Remodulate',
 'NdviOp',
 'WriteRGB',
 'FillAerosol',
 'MultiMasterStackGenerator',
 'Ndi45Op',
 'StoredGraph',
 'TOPSAR-Merge',
 'GaborFilter',
 'SM-Dielectric-Modeling',
 'Convert-Datatype',
 'BandsDifferenceOp',
 'c2rcc.seawifs',
 'IreciOp',
 'Offset-Tracking',
 'IpviOp',
 'SimulateAmplitude',
 'Warp',
 'SmileCorrection.Olci',
 'Azimuth-Shift-Estimation-ESD',
 'OWTClassification',
 'Object-Discrimination',
 'TOPSAR-Split',
 'MoreThenAnIntegerOp',
 'Update-Geo-Reference',
 'Flood-Detection',
 'Polarimetric-Classification',
 'Meris.CloudTopPressureOp',
 'Demodulate',
 'CreateStack',
 'Reproject',
 'Rad2Refl',
 'Principle-Components',
 'SliceAssembly',
 'ALOS-Deskewing',
 'Ellipsoid-Correction-RD',
 'SubGraph',
 'S2repOp',
 'ThermalNoiseRemoval',
 'Find-Image-Pair',
 'Orientation-Angle-Correction',
 'Enhanced-Spectral-Diversity',
 'GemiOp',
 'Msavi2Op',
 'BiophysicalOp',
 'TileWriter',
 'Apply-Orbit-File',
 'c2rcc.viirs',
 'Calibration',
 'Supervised-Wishart-Classification',
 'Coherence',
 'FuClassification',
 'PassThrough',
 'BandSelect',
 'MphChl',
 'Undersample',
 'PviOp',
 'Binning',
 'AddLandCover',
 'AzimuthFilter',
 'MphChlMeris',
 'RRToFRS',
 'c2rcc',
 'BandsExtractorOp',
 'Multilook',
 'PyOp',
 'Ellipsoid-Correction-GG',
 'IEM-Multi-Pol-Inversion',
 'FlhMci',
 'EAP-Phase-Correction',
 'TopoPhaseRemoval',
 'MphChlBasis',
 'Forest-Area-Classification',
 'SARSim-Terrain-Correction',
 'Oversample',
 'Subset',
 'MsaviOp',
 'Collocate',
 'c2rcc.meris4',
 'Change-Detection',
 'RayleighCorrection',
 'Polarimetric-Parameters',
 'BiOp',
 'GenericRegionMergingOp',
 'RviOp',
 'GndviOp',
 'IntegerInterferogram',
 'PhaseToElevation',
 'DEM-Assisted-Coregistration',
 'PpeFiltering',
 'Write',
 'PssraOp',
 'KMeansClusterAnalysis',
 'Meris.Sdr',
 'Import-Vector',
 'NdpiOp',
 'SpectralAngleMapperOp',
 'c2rcc.landsat8',
 'ProductSet-Reader',
 'Meris.GaseousCorrection',
 'Multi-Temporal-Speckle-Filter',
 'CoregistrationOp',
 'Bi2Op',
 'DviOp',
 'c2rcc.landsat7',
 'Stack-Averaging',
 'Fill-DEM-Hole',
 'CP-Stokes-Parameters',
 'TileCache',
 'NdtiOp',
 'Speckle-Filter',
 'StatisticsOp',
 'RiOp',
 'WdviOp',
 'SAR-Simulation',
 'EMClusterAnalysis',
 'Speckle-Divergence',
 'SaviOp',
 'c2rcc.msi',
 'BiophysicalLandsat8Op',
 'IEM-Hybrid-Inversion',
 'KDTree-KNN-Classifier',
 'FillBand',
 'Land-Sea-Mask',
 'Data-Analysis',
 'Interferogram',
 'TOPSAR-Deburst',
 'Arc.SST',
 'Ndwi2Op',
 'RemoveAntennaPattern',
 'Merge',
 'CP-Decomposition',
 'Forest-Area-Detection',
 'Aatsr.SST',
 'Meris.CloudProbability',
 'Land-Cover-Mask',
 'Biophysical10mOp',
 'MphChlOlci',
 'Meris.N1Patcher',
 'Meris.RayleighCorrection',
 'Meris.GapLessSdr',
 'ReipOp',
 'GRD-Post',
 'Meris.CombinedCloud',
 'Meris.BlueBand',
 'GLCM',
 'GoldsteinPhaseFiltering',
 'Terrain-Mask',
 'AddElevation',
 'Unmix',
 'CrossResampling',
 'GaseousAbsorption',
 'Compute-Slope-Aspect',
 'StampsExport',
 'Cross-Correlation',
 'Remove-GRD-Border-Noise',
 'Flip',
 'Meris.CorrectRadiometry',
 'Cross-Channel-SNR-Correction',
 'c2rcc.modis',
 'Meris.CloudClassification',
 'TOPSAR-DerampDemod',
 'MndwiOp',
 'NdwiOp']
In [15]:
g.describe_operators()
SARSim-Terrain-Correction - Orthorectification with SAR simulation
AzimuthFilter - Azimuth Filter
TopoPhaseRemoval - Compute and subtract TOPO phase
Ellipsoid-Correction-RD - Ellipsoid correction with RD method and average scene height
Polarimetric-Classification - Perform Polarimetric classification of a given product
GaborFilter - Extract Texture Features
Terrain-Correction - RD method for orthorectification
FillBand - None
Meris.CloudProbability - None
DeburstWSS - Debursts an ASAR WSS product
IntegerInterferogram - Create integer interferogram
Undersample - Undersample the datset
OWTClassification - Performs an optical water type classification based on atmospherically corrected reflectances.
Demodulate - Demodulation and deramping of SLC data
RiOp - The Redness Index was developed to identify soil colour variations.
Image-Filter - Common Image Processing Filters
Back-Geocoding - Bursts co-registration using orbit and DEM
Read - Reads a data product from a given file location.
Meris.AerosolMerger - None
Write - Writes a data product to a file.
ReipOp - The red edge inflection point index
GndviOp - Green Normalized Difference Vegetation Index
Azimuth-Shift-Estimation-ESD - Estimate azimuth offset for the whole image
NdviOp - The retrieves the Normalized Difference Vegetation Index (NDVI).
TOPSAR-DerampDemod - Bursts co-registration using orbit and DEM
TOPSAR-Deburst - Debursts a Sentinel-1 TOPSAR product
GRD-Post - Applies GRD post-processing
RviOp - Ratio Vegetation Index retrieves the Isovegetation lines converge at origin
Change-Detection - Change Detection.
Calibration - Calibration of products
WdviOp - Weighted Difference Vegetation Index retrieves the Isovegetation lines parallel to soil line. Soil line has an arbitrary slope and passes through origin
SM-Dielectric-Modeling - Performs SM inversion using dielectric model
Meris.Sdr - None
ThermalNoiseRemoval - Removes thermal noise from products
SnaphuImport - Ingest SNAPHU results into InSAR product.
PhaseToDisplacement - Phase To Displacement Conversion along LOS
Meris.Mod08Aerosol - None
Flood-Detection - Detect flooded area.
Oil-Spill-Detection - Detect oil spill.
Collocate - Collocates two products based on their geo-codings.
Speckle-Divergence - Detect urban area.
DviOp - Difference Vegetation Index retrieves the Isovegetation lines parallel to soil line
SliceAssembly - Merges Sentinel-1 slice products
ReplaceMetadata - Replace the metadata of the first product with that of the second
MphChlMeris - Computes maximum peak height of chlorophyll for MERIS. Implements MERIS-specific parts.
TileWriter - Writes a data product to a tiles.
c2rcc.seawifs - Performs atmospheric correction and IOP retrieval on SeaWifs L1C data products.
PhaseToHeight - Phase to Height conversion
SRGR - Converts Slant Range to Ground Range
PCA - Performs a Principal Component Analysis.
ALOS-Deskewing - Deskewing ALOS product
PixEx - Extracts pixels from given locations and source products.
NdpiOp - The normalized differential pond index, combines the short-wave infrared band-I and the green band
SaviOp - This retrieves the Soil-Adjusted Vegetation Index (SAVI).
BandsExtractorOp - Creates a new product out of the source product containing only the indexes bands given
TileCache - Experimental Operator which provides a dedicated cache for its source product.
A guide on how this operator is used is provided at https://senbox.atlassian.net/wiki/x/VQCTLw.
L3ToL1 - None
Cross-Channel-SNR-Correction - Compute general polarimetric parameters
SimulateAmplitude - Simulate amplitude based on DEM
Supervised-Wishart-Classification - Perform supervised Wishart classification
BandMaths - Create a product with one or more bands using mathematical expressions.
BiophysicalLandsat8Op - The 'Biophysical Processor' operator retrieves LAI from atmospherically corrected Landsat8 products
Data-Analysis - Computes statistics
TOPSAR-Merge - Merge subswaths of a Sentinel-1 TOPSAR product
BandSelect - Creates a new product with only selected bands
MoreThenAnIntegerOp - just for testing
TndviOp - Transformed Normalized Difference Vegetation Index retrieves the Isovegetation lines parallel to soil line
StampsExport - Export data for StaMPS processing
Multilook - Averages the power across a number of lines in both the azimuth and range directions
c2rcc.meris - Performs atmospheric correction and IOP retrieval with uncertainties on MERIS L1b data products.
TsaviOp - This retrieves the Transformed Soil Adjusted Vegetation Index (TSAVI).
Terrain-Mask - Terrain Mask Generation
Meris.LandClassification - MERIS L2 land/water reclassification.
SmacOp - Applies the Simplified Method for Atmospheric Corrections of Envisat MERIS/(A)ATSR measurements.
GenericRegionMergingOp - The 'Generic Region Merging' operator computes the distinct regions from a product
PduStitching - Stitches multiple SLSTR L1B product dissemination units (PDUs) of the same orbit to a single product.
RayleighCorrection - Performs radiometric corrections on OLCI, MERIS L1B and S2 MSI L1C data products.
Meris.CloudShadow - None
Binning - Performs spatial and temporal aggregation of pixel values into cells ('bins') of a planetary grid
AddLandCover - Creates a land cover band
MphChlBasis - Computes maximum peak height of chlorophyll. Basis class, contains sensor-independent parts.
Mci.s2 - Computes maximum chlorophyll index (MCI) for Sentinel-2 MSI.
SmileCorrection.Olci - Performs radiometric corrections on OLCI L1b data products.
RemoveAntennaPattern - Remove Antenna Pattern
Wind-Field-Estimation - Estimate wind speed and direction
DEM-Assisted-Coregistration - Orbit and DEM based co-registration
SAR-Simulation - Rigorous SAR Simulation
Random-Forest-Classifier - Random Forest based classifier
AdaptiveThresholding - Detect ships using Constant False Alarm Rate detector.
Meris.RayleighCorrection - MERIS L2 rayleigh correction.
PpeFiltering - Performs Prompt Particle Event (PPE) filtering on OLCI L1B
Remove-GRD-Border-Noise - Mask no-value pixels for GRD product
Import-Vector - Imports a shape file into a product
MphChlOlci - Computes maximum peak height of chlorophyll for OLCI. Implements OLCI-specific parts.
Enhanced-Spectral-Diversity - Estimate constant range and azimuth offsets for a stack of images
Polarimetric-Parameters - Compute general polarimetric parameters
GemiOp - This retrieves the Global Environmental Monitoring Index (GEMI).
RRToFRS - None
RangeFilter - Range Filter
KNN-Classifier - K-Nearest Neighbour classifier
Polarimetric-Matrices - Generates covariance or coherency matrix for given product
Reproject - Reprojection of a source product to a target Coordinate Reference System.
Meris.GaseousCorrection - MERIS L2 gaseous absorbtion correction.
Object-Discrimination - Remove false alarms from the detected objects.
Oversample - Oversample the datset
CloudProb - Applies a clear sky conservative cloud detection algorithm.
MtciOp - The Meris Terrestrial Chlorophyll Index,  aims at estimating the Red Edge Position (REP).
This is the maximum slant point in the red and near-infrared region of the vegetal spectral reflectance.
It is useful for observing the chlorophyll contents, vegetation senescence, and stress for water and nutritional deficiencies, but it is less suitable for land classification
Land-Sea-Mask - Creates a bitmask defining land vs ocean.
FuClassification - Colour classification based on the discrete Forel-Ule scale.
Find-Image-Pair - DB query to find matching image pair
TemporalPercentile - Computes percentiles over a given time period.
Rad2Refl - Provides conversion from radiances to reflectances or backwards.
DecisionTree - Perform decision tree classification
c2rcc.msi - Performs atmospheric correction and IOP retrieval with uncertainties on Sentinel-2 MSI L1C data products.
Polarimetric-Decomposition - Perform Polarimetric decomposition of a given product
CP-Stokes-Parameters - Generates compact polarimetric Stokes child parameters
EAP-Phase-Correction - EAP Phase Correction
Resample - Resampling of a multi-size source product to a single-size target product.
Ellipsoid-Correction-GG - GG method for orthorectification
c2rcc.meris4 - Performs atmospheric correction and IOP retrieval with uncertainties on MERIS L1b data products from the 4th reprocessing.
TOPSAR-Split - Creates a new product with only the selected subswath
Meris.CloudTopPressureOp - Computes cloud top pressure with FUB NN.
NdtiOp - Normalized difference turbidity index, allowing for the measurement of water turbidity
c2rcc - Performs atmospheric correction and IOP retrieval on OLCI, MSI, MERIS, MODIS or SeaWiFS L1 product.
Principle-Components - Principle Component Analysis
ProductSet-Reader - Adds a list of sources
CreateStack - Collocates two or more products based on their geo-codings.
FillAerosol - None
StoredGraph - Encapsulates an stored graph into an operator.
LinearToFromdB - Converts bands to/from dB
Meris.CombinedCloud - None
CoregistrationOp - Coregisters two rasters, not considering their location
IEM-Multi-Pol-Inversion - Performs IEM inversion using Multi-polarization approach
IEM-Hybrid-Inversion - Performs IEM inversion using Hybrid approach
McariOp - Modified Chlorophyll Absorption Ratio Index, developed to be responsive to chlorophyll variation
NdwiOp - The Normalized Difference Water Index was developed for the extraction of water features
ToolAdapterOp - Tool Adapter Operator
Meris.SmileCorrection - None
c2rcc.landsat7 - Performs atmospheric correction and IOP retrieval with uncertainties on Landsat-7 L1 data products.
PviOp - Perpendicular Vegetation Index retrieves the Isovegetation lines parallel to soil line. Soil line has an arbitrary slope and passes through origin
LandWaterMask - Operator creating a target product with a single band containing a land/water-mask.
FlhMci - Computes fluorescence line height (FLH) or maximum chlorophyll index (MCI).
GaseousAbsorption - Correct the influence of atmospheric gas absorption for those OLCI channels.
CrossResampling - Estimate Resampling Polynomial using SAR Image Geometry, and Resample Input Images
Update-Geo-Reference - Update Geo Reference
Mosaic - Creates a mosaic out of a set of source products.
Three-passDInSAR - Differential Interferometry
GLCM - Extract Texture Features
S2Resampling - Specific S2 resample algorithm
Meris.N1Patcher - Copies an existing N1 file and replaces the data for the radiance bands
IreciOp - Inverted red-edge chlorophyll index
OlciO2aHarmonisation - Performs O2A band harmonisation on OLCI L1b product.
SAR-Mosaic - Mosaics two or more products based on their geo-codings.
CiOp - Colour Index  was developed to differentiate soils in the field.
In most cases the CI gives complementary information with the BI and the NDVI.
 Used for diachronic analyses, they help for a better understanding of the evolution of soil surfaces.
Ndwi2Op - The Normalized Difference Water Index, allowing for the measurement of surface water extent
Terrain-Flattening - Terrain Flattening
SpectralAngleMapperOp - Classifies a product using the spectral angle mapper algorithm
Merge - Allows merging of several source products by using specified 'master' as reference product.
PssraOp - Pigment Specific Simple Ratio, chlorophyll index
Meris.Brr - Performs the Rayleigh correction on a MERIS L1b product.
Flip - flips a product horizontal/vertical
BiophysicalOp - The 'Biophysical Processor' operator retrieves LAI from atmospherically corrected Sentinel-2 products
Meris.CloudClassification - MERIS L2 cloud classification.
Msavi2Op - This retrieves the second Modified Soil Adjusted Vegetation Index (MSAVI2).
PyOp - Uses Python code to process data products
Convert-Datatype - Convert product data type
Stack-Split - Writes all bands to files.
MphChl - This operator computes maximum peak height of chlorophyll (MPH/CHL).
Polarimetric-Speckle-Filter - Polarimetric Speckle Reduction
KMeansClusterAnalysis - Performs a K-Means cluster analysis.
Coherence - Estimate coherence from stack of coregistered images
Arc.SST - Computes sea surface temperature (SST) from (A)ATSR and SLSTR products.
Subset - Create a spatial and/or spectral subset of a data product.
MultiMasterStackGenerator - Generates a set of master-slave pairs from a coregistered stack for use in SBAS processing
GoldsteinPhaseFiltering - Phase Filtering
Interferogram - Compute interferograms from stack of coregistered S-1 images
RemoteExecutionOp - The Remote Execution Processor executes on the remote machines a slave graph and then on the host machine it executes a master graph using the products created by the remote machines.
c2rcc.olci - Performs atmospheric correction and IOP retrieval with uncertainties on SENTINEL-3 OLCI L1B data products.
Fill-DEM-Hole - Fill holes in given DEM product file.
Apply-Orbit-File - Apply orbit file
Offset-Tracking - Create velocity vectors from offset tracking
FUB.Water - FUB/WeW WATER Processor to retrieve case II water properties and atmospheric properties
S2repOp - Sentinel-2 red-edge position index
Cross-Correlation - Automatic Selection of Ground Control Points
EMClusterAnalysis - Performs an expectation-maximization (EM) cluster analysis.
Double-Difference-Interferogram - Compute double difference interferogram
Forest-Area-Detection - Detect forest area.
Minimum-Distance-Classifier - Minimum Distance classifier
c2rcc.landsat8 - Performs atmospheric correction and IOP retrieval with uncertainties on Landsat-8 L1 data products.
AATSR.Ungrid - Ungrids (A)ATSR L1B products and extracts geolocation and pixel field of view data.
CP-Simulation - Simulation of Compact Pol data from Quad Pol data
S2tbx-Reproject - Reprojection of a source product to a target Coordinate Reference System.
TestPattern - For testing only
SetNoDataValue - Set NoDataValueUsed flag and NoDataValue for all bands
PhaseToElevation - DEM Generation
Land-Cover-Mask - Perform decision tree classification
Meris.CorrectRadiometry - Performs radiometric corrections on MERIS L1b data products.
AddElevation - Creates a DEM band
Remodulate - Remodulation and reramping of SLC data
Meris.GapLessSdr - None
MndwiOp - Modified Normalized Difference Water Index, allowing for the measurement of surface water extent
Multi-size Mosaic - Creates a multi-size mosaic out of a set of source products.
Multi-Temporal-Speckle-Filter - Speckle Reduction using Multitemporal Filtering
CP-Decomposition - Perform Compact Polarimetric decomposition of a given product
Warp - Create Warp Function And Get Co-registrated Images
PassThrough - Sets target product to source product.
c2rcc.viirs - Performs atmospheric correction and IOP retrieval on Viirs L1C data products.
Ndi45Op - Normalized Difference Index using bands 4 and 5
BandsDifferenceOp - None
Orientation-Angle-Correction - Perform polarization orientation angle correction for given coherency matrix
Speckle-Filter - Speckle Reduction
WriteRGB - Creates an RGB image from three source bands.
MsaviOp - This retrieves the Modified Soil Adjusted Vegetation Index (MSAVI).
Meris.BlueBand - None
ArviOp - Atmospherically Resistant Vegetation Index belongs to a family of indices with built-in atmospheric corrections.
SnaphuExport - Export data and prepare conf file for SNAPHU processing
StatisticsOp - Computes statistics for an arbitrary number of source products.
SubGraph - Encapsulates a graph within a graph.
Oil-Spill-Clustering - Remove small clusters from detected area.
ReflectanceToRadianceOp - The 'Reflectance To Radiance Processor' operator retrieves the radiance from reflectance using Sentinel-2 products
IEM-Multi-Angle-Inversion - Performs IEM inversion using Multi-angle approach
Forest-Area-Classification - Detect forest area
Stack-Averaging - Averaging multi-temporal images
Aatsr.SST - Computes sea surface temperature (SST) from (A)ATSR products.
Bi2Op - The Brightness index represents the average of the brightness of a satellite image.
This index is sensitive to the brightness of soils which is highly correlated with the humidity and the presence of salts in surface
KDTree-KNN-Classifier - KDTree KNN classifier
IpviOp - Infrared Percentage Vegetation Index retrieves the Isovegetation lines converge at origin
BiOp - The Brightness index represents the average of the brightness of a satellite image.
Maximum-Likelihood-Classifier - Maximum Likelihood classifier
Unmix - Performs a linear spectral unmixing.
ForestCoverChangeOp - Creates forest change masks out of two source products
c2rcc.modis - Performs atmospheric correction and IOP retrieval on MODIS L1C_LAC data products.
Compute-Slope-Aspect - Compute Slope and Aspect from DEM
Biophysical10mOp - The 'Biophysical Processor' operator retrieves LAI from atmospherically corrected Sentinel-2 products
BandMerge - Allows copying raster data from any number of source products to a specified 'master' product.

Create a linear graph

In [16]:
g = Graph() 

read = Operator('Read')

read.formatName = 'SENTINEL-1'
read.file = 'some1'


operators = [read,
             'Resample',
             'Reproject',
             'Subset',
             'AddLandCover',
             'Write']

for index, operator in enumerate(operators):
    
    print('Adding Operator {} to graph'.format(operator.operator if isinstance(operator, Operator) else operator))
    if index == 0:            
        source_node_id = ''

    else:
        source_node_id = operators[index - 1].operator if isinstance(operators[index - 1], Operator) else operators[index - 1]
        
        
    g.add_node(operator if isinstance(operator, Operator) else Operator(operator),
               operator.operator if isinstance(operator, Operator) else operator,
               source_node_id)
      
Adding Operator Read to graph
Adding Operator Resample to graph
Adding Operator Reproject to graph
Adding Operator Subset to graph
Adding Operator AddLandCover to graph
Adding Operator Write to graph
In [17]:
g.view()
<graph>
  <version>1.0</version>
  <node id="Read">
    <operator>Read</operator>
    <sources>
      <sourceProduct refid=""/>
    </sources>
    <parameters class="com.bc.ceres.binding.dom.XppDomElement">
      <bandNames/>
      <copyMetadata>true</copyMetadata>
      <file>some1</file>
      <formatName>SENTINEL-1</formatName>
      <geometryRegion/>
      <maskNames/>
      <pixelRegion/>
    </parameters>
  </node>
  <node id="Resample">
    <operator>Resample</operator>
    <sources>
      <sourceProduct refid="Read"/>
    </sources>
    <parameters class="com.bc.ceres.binding.dom.XppDomElement">
      <bandResamplings/>
      <downsamplingMethod>First</downsamplingMethod>
      <flagDownsamplingMethod>First</flagDownsamplingMethod>
      <referenceBandName/>
      <resampleOnPyramidLevels>true</resampleOnPyramidLevels>
      <resamplingPreset/>
      <targetHeight/>
      <targetResolution/>
      <targetWidth/>
      <upsamplingMethod>Nearest</upsamplingMethod>
    </parameters>
  </node>
  <node id="Reproject">
    <operator>Reproject</operator>
    <sources>
      <sourceProduct refid="Resample"/>
    </sources>
    <parameters class="com.bc.ceres.binding.dom.XppDomElement">
      <addDeltaBands>false</addDeltaBands>
      <crs/>
      <easting/>
      <elevationModelName/>
      <height/>
      <includeTiePointGrids>true</includeTiePointGrids>
      <noDataValue/>
      <northing/>
      <orientation>0</orientation>
      <orthorectify>false</orthorectify>
      <pixelSizeX/>
      <pixelSizeY/>
      <referencePixelX/>
      <referencePixelY/>
      <resamplingName>Nearest</resamplingName>
      <tileSizeX/>
      <tileSizeY/>
      <width/>
      <wktFile/>
    </parameters>
  </node>
  <node id="Subset">
    <operator>Subset</operator>
    <sources>
      <sourceProduct refid="Reproject"/>
    </sources>
    <parameters class="com.bc.ceres.binding.dom.XppDomElement">
      <bandNames/>
      <copyMetadata>false</copyMetadata>
      <fullSwath>false</fullSwath>
      <geoRegion/>
      <referenceBand/>
      <region/>
      <subSamplingX>1</subSamplingX>
      <subSamplingY>1</subSamplingY>
      <tiePointGridNames/>
    </parameters>
  </node>
  <node id="AddLandCover">
    <operator>AddLandCover</operator>
    <sources>
      <sourceProduct refid="Subset"/>
    </sources>
    <parameters class="com.bc.ceres.binding.dom.XppDomElement">
      <externalFiles/>
      <landCoverNames>AAFC Canada Sand Pct</landCoverNames>
      <resamplingMethod>NEAREST_NEIGHBOUR</resamplingMethod>
    </parameters>
  </node>
  <node id="Write">
    <operator>Write</operator>
    <sources>
      <sourceProduct refid="AddLandCover"/>
    </sources>
    <parameters class="com.bc.ceres.binding.dom.XppDomElement">
      <clearCacheAfterRowWrite>false</clearCacheAfterRowWrite>
      <deleteOutputOnFailure>true</deleteOutputOnFailure>
      <file/>
      <formatName>BEAM-DIMAP</formatName>
      <writeEntireTileRows>false</writeEntireTileRows>
    </parameters>
  </node>
</graph>

In [ ]:
#g.run()

BandMaths

In [2]:
band_maths = Operator('BandMaths')
In [3]:
band_maths.describe()
Operator name: BandMaths

Description: Create a product with one or more bands using mathematical expressions.
Authors: Marco Zuehlke, Norman Fomferra, Marco Peters

org.esa.snap.core.gpf.common.BandMathsOp
Version: 1.1

Parameters:

	targetBandDescriptors: List of descriptors defining the target bands.
		Default Value: None

		Possible values: []

	variables: List of variables which can be used within the expressions.
		Default Value: None

		Possible values: []

active_fire_detected float32 S9_BT_in < 265 ? 0 : F1_BT_in > 315 and (F1_BT_in - F2_BT_in) > 15 ? 1 : 0 NaN
In [4]:
active_fire_band = TargetBand(name='active_fire_detected',
                              expression='S9_BT_in &lt; 265 ? 0 : F1_BT_in &gt; 315 and (F1_BT_in - F2_BT_in) &gt; 15 ? 1 : 0')
In [5]:
active_fire_band
Out[5]:
TargetBand(name='active_fire_detected', expression='S9_BT_in &lt; 265 ? 0 : F1_BT_in &gt; 315 and (F1_BT_in - F2_BT_in) &gt; 15 ? 1 : 0', band_type='float32', description=None, unit=None, no_data_value='NaN')
In [6]:
band_maths.targetBandDescriptors = TargetBandDescriptors([active_fire_band])
In [7]:
g = Graph()

g.add_node(operator=Operator('Read'), 
           node_id='read_1')
In [8]:
g.add_node(operator=band_maths, 
           node_id='band_maths', 
           source='read_1')
In [9]:
g.view()
<graph>
  <version>1.0</version>
  <node id="read_1">
    <operator>Read</operator>
    <sources/>
    <parameters class="com.bc.ceres.binding.dom.XppDomElement">
      <bandNames/>
      <copyMetadata>true</copyMetadata>
      <file/>
      <formatName/>
      <geometryRegion/>
      <maskNames/>
      <pixelRegion/>
    </parameters>
  </node>
  <node id="band_maths">
    <operator>BandMaths</operator>
    <sources>
      <sourceProduct refid="read_1"/>
    </sources>
    <parameters class="com.bc.ceres.binding.dom.XppDomElement">
      <targetBands>
        <targetBand>
          <name>active_fire_detected</name>
          <expression>S9_BT_in &amp;lt; 265 ? 0 : F1_BT_in &amp;gt; 315 and (F1_BT_in - F2_BT_in) &amp;gt; 15 ? 1 : 0</expression>
          <band_type>float32</band_type>
          <description/>
          <unit/>
          <no_data_value>NaN</no_data_value>
        </targetBand>
      </targetBands>
      <variables/>
    </parameters>
  </node>
</graph>

Binning

In [1]:
%load_ext autoreload
%autoreload 2

from snapista.binning import aggregators
from snapista.binning import BinningVariable, BinningOutputBands, BinningBand, Aggregators
from snapista import Graph
from snapista import Operator
import lxml.etree as etree
In [2]:
ag = aggregators.AggregatorAvg(var_name='pippo', target_name="target_name", output_counts='true')
In [3]:
ag.to_dict()
Out[3]:
{'type': 'AVG',
 'var_name': 'pippo',
 'target_name': 'target_name',
 'weight_coeff': 0.0,
 'description': None,
 'output_counts': 'true',
 'output_sums': 'true'}
In [ ]:
 
In [4]:
bv = BinningVariable(name='pippo', expression='aa', valid_expression='aa')
In [5]:
bv
Out[5]:
BinningVariable(name='pippo', expression='aa', valid_expression='aa')
In [6]:
bv.to_xml()
Out[6]:
<Element variable at 0x7fe6326ae180>
In [ ]:
 
In [7]:
etree.tostring(bv.to_xml())
Out[7]:
b'<variable><name>pippo</name><expr>aa</expr><validExpr>aa</validExpr></variable>'
In [8]:
bb = BinningBand(index="0", name='aa', min_value=0, max_value=100)
In [9]:
ob = BinningOutputBands([bb])
In [10]:
etree.tostring(ob.to_xml())
Out[10]:
b'<outputBands><band><index>0</index><name>aa</name><minValue>0</minValue><maxValue>100</maxValue></band></outputBands>'
In [11]:
[bv]
Out[11]:
[BinningVariable(name='pippo', expression='aa', valid_expression='aa')]
In [12]:
binning = Operator('Binning')
In [13]:
binning
Out[13]:
Operator('Binning', sourceProductPaths='None', sourceProductFormat='None', sourceGraphPaths='None', region='None', startDateTime='None', periodDuration='None', timeFilterMethod='NONE', minDataHour='None', numRows='2160', superSampling='1', maxDistanceOnEarth='-1', maskExpr='None', variableConfigs='None', aggregatorConfigs='None', postProcessorConfig='None', outputType='Product', outputFile='None', outputFormat='BEAM-DIMAP', bandConfigurations='None', productCustomizerConfig='None', outputBinnedData='false', outputTargetProduct='true', metadataPropertiesFile='./metadata.properties', metadataTemplateDir='.', metadataAggregatorName='NAME', planetaryGridClass='org.esa.snap.binning.support.SEAGrid')
In [14]:
binning.aggregatorConfigs = Aggregators([ag])
binning.bandConfigurations = BinningOutputBands([bb])
binning
Out[14]:
Operator('Binning', sourceProductPaths='None', sourceProductFormat='None', sourceGraphPaths='None', region='None', startDateTime='None', periodDuration='None', timeFilterMethod='NONE', minDataHour='None', numRows='2160', superSampling='1', maxDistanceOnEarth='-1', maskExpr='None', variableConfigs='None', aggregatorConfigs='<snapista.binning.aggregators.Aggregators object at 0x7fe632696dc0>', postProcessorConfig='None', outputType='Product', outputFile='None', outputFormat='BEAM-DIMAP', bandConfigurations='<snapista.binning.output_bands.BinningOutputBands object at 0x7fe632695700>', productCustomizerConfig='None', outputBinnedData='false', outputTargetProduct='true', metadataPropertiesFile='./metadata.properties', metadataTemplateDir='.', metadataAggregatorName='NAME', planetaryGridClass='org.esa.snap.binning.support.SEAGrid')
In [15]:
import os
os.environ['PATH'] = '/srv/conda/envs/env_snap/snap/bin:' +  os.environ['PATH']
In [16]:
g = Graph()

g.add_node(operator=binning, 
           node_id='binning_1')
aggregatorConfigs
here 2
maskExpr
maxDistanceOnEarth
metadataAggregatorName
metadataPropertiesFile
metadataTemplateDir
minDataHour
numRows
outputBinnedData
outputFile
outputFormat
outputTargetProduct
outputType
periodDuration
planetaryGridClass
postProcessorConfig
productCustomizerConfig
region
sourceGraphPaths
sourceProductFormat
sourceProductPaths
startDateTime
superSampling
timeFilterMethod
variableConfigs
In [17]:
g.view()
<graph>
  <version>1.0</version>
  <node id="binning_1">
    <operator>Binning</operator>
    <sources/>
    <parameters class="com.bc.ceres.binding.dom.XppDomElement">
      <aggregators>
        <aggregator>
          <type>AVG</type>
          <var_name>pippo</var_name>
          <target_name>target_name</target_name>
          <weight_coeff>0.0</weight_coeff>
          <description>None</description>
          <output_counts>true</output_counts>
          <output_sums>true</output_sums>
        </aggregator>
      </aggregators>
      <maskExpr/>
      <maxDistanceOnEarth>-1</maxDistanceOnEarth>
      <metadataAggregatorName>NAME</metadataAggregatorName>
      <metadataPropertiesFile>./metadata.properties</metadataPropertiesFile>
      <metadataTemplateDir>.</metadataTemplateDir>
      <minDataHour/>
      <numRows>2160</numRows>
      <outputBinnedData>false</outputBinnedData>
      <outputFile/>
      <outputFormat>BEAM-DIMAP</outputFormat>
      <outputTargetProduct>true</outputTargetProduct>
      <outputType>Product</outputType>
      <periodDuration/>
      <planetaryGridClass>org.esa.snap.binning.support.SEAGrid</planetaryGridClass>
      <postProcessorConfig/>
      <productCustomizerConfig/>
      <region/>
      <sourceGraphPaths/>
      <sourceProductFormat/>
      <sourceProductPaths/>
      <startDateTime/>
      <superSampling>1</superSampling>
      <timeFilterMethod>NONE</timeFilterMethod>
      <variableConfigs/>
    </parameters>
  </node>
</graph>

In [ ]:
 
In [1]:
%load_ext autoreload
%autoreload 2

from snapista.binning import aggregators
from snapista.binning import BinningVariable, BinningOutputBands, BinningBand, Aggregators, BinningVariables
from snapista import Graph
from snapista import Operator
import lxml.etree as etree
import os

os.environ['PATH'] = '/srv/conda/envs/env_snap/snap/bin:' +  os.environ['PATH']

ag = aggregators.AggregatorAvg(var_name='pippo', target_name="target_name", output_counts='true')
bv = BinningVariable(name='pippo', expression='aa', valid_expression='aa')
bb = BinningBand(index="0", name='aa', min_value=0, max_value=100)

binning = Operator('Binning')

binning.aggregatorConfigs = Aggregators([ag])
binning.bandConfigurations = BinningOutputBands([bb])
binning.variableConfigs = BinningVariables([bv])
g = Graph()

g.add_node(operator=binning, 
           node_id='binning_1')
In [2]:
g.view()
<graph>
  <version>1.0</version>
  <node id="binning_1">
    <operator>Binning</operator>
    <sources/>
    <parameters class="com.bc.ceres.binding.dom.XppDomElement">
      <aggregators>
        <aggregator>
          <type>AVG</type>
          <var_name>pippo</var_name>
          <target_name>target_name</target_name>
          <weight_coeff>0.0</weight_coeff>
          <description>None</description>
          <output_counts>true</output_counts>
          <output_sums>true</output_sums>
        </aggregator>
      </aggregators>
      <outputBands>
        <band>
          <index>0</index>
          <name>aa</name>
          <minValue>0</minValue>
          <maxValue>100</maxValue>
        </band>
      </outputBands>
      <maskExpr/>
      <maxDistanceOnEarth>-1</maxDistanceOnEarth>
      <metadataAggregatorName>NAME</metadataAggregatorName>
      <metadataPropertiesFile>./metadata.properties</metadataPropertiesFile>
      <metadataTemplateDir>.</metadataTemplateDir>
      <minDataHour/>
      <numRows>2160</numRows>
      <outputBinnedData>false</outputBinnedData>
      <outputFile/>
      <outputFormat>BEAM-DIMAP</outputFormat>
      <outputTargetProduct>true</outputTargetProduct>
      <outputType>Product</outputType>
      <periodDuration/>
      <planetaryGridClass>org.esa.snap.binning.support.SEAGrid</planetaryGridClass>
      <postProcessorConfig/>
      <productCustomizerConfig/>
      <region/>
      <sourceGraphPaths/>
      <sourceProductFormat/>
      <sourceProductPaths/>
      <startDateTime/>
      <superSampling>1</superSampling>
      <timeFilterMethod>NONE</timeFilterMethod>
      <variables>
        <variable>
          <name>pippo</name>
          <expr>aa</expr>
          <validExpr>aa</validExpr>
        </variable>
      </variables>
    </parameters>
  </node>
</graph>

In [ ]:
 
In [ ]: