Comparing 2 NDVI images

Hi, I have downloaded two Sentinel-2 images (MSI) with a time difference between the 2 downloads. I created the NDVI from them (Bands 8 and 4)-OK. I want to compare the 2 images to find the differences between the them. How to perform ? Thx.

before calculating the difference in NDVI you should calibrate the scenes first.
You can do this with the sen2cor plugin.

Then calculate the NDVI for both scenes

Stack the two NDVI rasters (Raster > Geometric Operations > Collocation)

Then you can open the band maths of the collocated product and subtract the NDVI from the second scene from the NDVI of the first scene. This shows you the total increase/decrease at each pixel.
If you want the relative change (in %) perform a division instead.

1 Like

Thx. ABraun. I will explore the sen2cor plugin/


I would like to comparise two NDVI images of the same area, acquired from Sentinel 2 Level 2 products.
After collocation, when I try to open any band in collocated product, the error shows up:

_Failed to open image view. _
expression: Undefined symbol ‘ndvi_flags_M.NDVI_ARITHMETIC_M’.

There are 5 bands in collocated product: ndvi_M, ndvi_flags_M, ndvi_S, ndvi_flags_S, collocation_flags. The same error for each of them.

Besides that error, what expression would you recommend to use in ‘band maths’ later, to show the differences between two ndvi’s? Something like (ndvi_M-ndvi_S)/(ndvi_M) ?

Thanks in advance, Wojciech

This happens because of a bug in the collocation. You can work around by right-clicking on the band and select Properties. Remove the valid pixel expression. Afterwards, it should work.

Thank you for your reply. The valid pixel expression was present only in ndvi_S, ndvi_flags_S bands. After making it empty the error still shows up :confused:

I can paste error logs here If it can help to solve the problem:

org.esa.snap.core.jexp.ParseException: Undefined symbol ‘ndvi_flags_M.NDVI_ARITHMETIC_M’.
at org.esa.snap.core.jexp.impl.ParserImpl.reportError(
at org.esa.snap.core.jexp.impl.ParserImpl.parseCallOrRef(
at org.esa.snap.core.jexp.impl.ParserImpl.parsePrimary(
at org.esa.snap.core.jexp.impl.ParserImpl.parsePostfix(
at org.esa.snap.core.jexp.impl.ParserImpl.parseUnary(
at org.esa.snap.core.jexp.impl.ParserImpl.parseMul(
at org.esa.snap.core.jexp.impl.ParserImpl.parseAdd(
at org.esa.snap.core.jexp.impl.ParserImpl.parseBitwiseAnd(
at org.esa.snap.core.jexp.impl.ParserImpl.parseBitwiseXOr(
at org.esa.snap.core.jexp.impl.ParserImpl.parseBitwiseOr(
at org.esa.snap.core.jexp.impl.ParserImpl.parseComparison(
at org.esa.snap.core.jexp.impl.ParserImpl.parseLogicalAnd(
at org.esa.snap.core.jexp.impl.ParserImpl.parseLogicalOr(
at org.esa.snap.core.jexp.impl.ParserImpl.parseConditional(
at org.esa.snap.core.jexp.impl.ParserImpl.parseAssign(
at org.esa.snap.core.jexp.impl.ParserImpl.parseTerm(
at org.esa.snap.core.jexp.impl.ParserImpl.parseImpl(
at org.esa.snap.core.jexp.impl.ParserImpl.parse(
at org.esa.snap.core.jexp.impl.ParserImpl.parse(
at org.esa.snap.core.dataop.barithm.BandArithmetic.parseExpression(
at org.esa.snap.core.image.VirtualBandOpImage.parseExpression(
Caused: java.lang.IllegalArgumentException: expression: Undefined symbol ‘ndvi_flags_M.NDVI_ARITHMETIC_M’.
at org.esa.snap.core.image.VirtualBandOpImage.parseExpression(
at org.esa.snap.core.image.VirtualBandOpImage.parseExpression(
at org.esa.snap.core.datamodel.VirtualBand.createSourceImage(
at org.esa.snap.core.datamodel.Mask$BandMathsType.createImage(
at org.esa.snap.core.datamodel.Mask.createSourceImage(
at org.esa.snap.core.datamodel.RasterDataNode.getSourceImage(
at org.esa.snap.core.layer.MaskLayerType.createMultiLevelSource(
at org.esa.snap.core.layer.MaskLayerType.createMultiLevelSource(
at org.esa.snap.core.layer.MaskLayerType.createLayer(
at org.esa.snap.core.layer.MaskLayerType.createLayer(
at org.esa.snap.ui.product.ProductSceneImage.createMaskCollectionLayer(
at org.esa.snap.ui.product.ProductSceneImage.getMaskCollectionLayer(
at org.esa.snap.ui.product.ProductSceneView.getMaskCollectionLayer(
at org.esa.snap.ui.product.ProductSceneView.setMaskOverlayEnabled(
at org.esa.snap.ui.product.ProductSceneView.(
[catch] at org.esa.snap.rcp.actions.window.OpenImageViewAction$1.done(
at javax.swing.SwingWorker$ Source)
at javax.swing.SwingWorker$ Source)
at Source)
at javax.swing.SwingWorker$DoSubmitAccumulativeRunnable.actionPerformed(Unknown Source)
at javax.swing.Timer.fireActionPerformed(Unknown Source)
at javax.swing.Timer$ Source)
at java.awt.event.InvocationEvent.dispatch(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$500(Unknown Source)
at java.awt.EventQueue$ Source)
at java.awt.EventQueue$ Source)
at Method)
at$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at org.netbeans.core.TimableEventQueue.dispatchEvent(
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at Source)

Thank you.

I addition you need to remove the masks in the Mask Manager.
I’m sorry. It’s not very convenient to use at the moment, at least in certain cases. I hope we can fix this soon

1 Like

Works excellent, feel like a boss, thanks a lot for your help!

Have a nice weekend,

1 Like

@ABraun What do you mean by “calibrate the scene” with sen2cor? I thought Sen2cor was used to obtain L2A image from L1C image.

yes. And by doing so your values of different scenes become comparable because it reduces the different illumination conditions or atmospheric layers, for example.

For L2A images this is should be already done then?

yes, in the meanwhile, some can be downloaded already at level 2A.

1 Like


I have had the same problem displaying NDVI images. I have cleared out the valid expression box and removed all the masks. I still get a null value reply from the image viewer. I’m using an iMac computer, if that makes a difference.

Thanks, Norm

I also had this problem very recently. Please fix the collocation bug.