Create Stack operator fails to write slave bands (java)

Hello all,

I am trying to coregister RS2 images from the same orbit and track. I have succeeded in the GUI, but cannot get the following code to work in my java code. I think perhaps there is something I don’t understand in how the parameters and sourceProducts must be passed to the operator.

  1. Even though I specify to only use two bands (the first of each product), the operator tries to write all of them. How can I coregister only selected bands from each product ?

  2. The operator can successfully write the master bands to disk, but fails when trying to write the slave bands :

Exception in thread “main” org.esa.snap.core.gpf.OperatorException: java.lang.NullPointerException
at org.esa.snap.engine_utilities.gpf.OperatorUtils.catchOperatorException(OperatorUtils.java:421)
at org.esa.s1tbx.insar.gpf.coregistration.CreateStackOp.computeTile(CreateStackOp.java:911)

Any advice would be greatly appreciated.

SDB

    /* Load products */
    Product[] products = new Product[2];
    products[0] =   ProductIO.readProduct(inFile1);        
    products[1] =   ProductIO.readProduct(inFile2);        
    GPF.getDefaultInstance().getOperatorSpiRegistry().loadOperatorSpis();
    
    /* Operator parameters */
    HashMap parameters = new HashMap();
    HashMap productMap = new HashMap();
    parameters.put("extent","Master");
    parameters.put("initialOffsetMethod","Product Geolocation");        
    parameters.put("masterBands",products[0].getBandAt(0).getName());
    parameters.put("resamplingType","Nearest-Neighbor");
    parameters.put("sourceBands",products[1].getBandAt(0).getName());
    
    System.out.println("Creating stack...");
    Product outProduct = GPF.createProduct("CreateStack", parameters, products);        
    System.out.println("Done.");
    ProductIO.writeProduct(outProduct, outFile, "BEAM-DIMAP", true);

The resampling should be “NEAREST_NEIGHBOUR”
If your input is complex, you need to specify both i and q bands.

Note that CreateStrack is NOT coregistration. It only does the initial offset or if a resampling method is selected, it will resample according to the geocoding. This is sufficient for amplitude change detection but, If you need something more precise for InSAR then you need the cross correlation and warp or the dem assisted coregistration.

2 Likes

Hi Luis,

Great, thank you for spotting this silly mistake ! It works fine now.

I am stacking the images to be able to track a certain spot in the image over time. It is not do to interferometric processing, only to see the evolution of the backscattering for instance.

For this application, do you think stacking is sufficient ?

It will depend on whether the product geocoding is accurate to within a
pixel. With RS2 there can be a drift.

I see. I’ll heed your advice and try to set up a full coregistration. Thanks !

i try to stack 2 radarsat images in SNAP but its not going through , both images have been calibrated, multilooked and reprojected .
what could be the problem?