Principle component Analysis in SNAP

Hi all,
When I use Principle component analysis in SNAP, the result is including components (PC1, PC2, PC3, PC4) and some files such as error, response and flag. What do they mean ? When I analyse PCA in Envi, there is no files like this. Anyone can explain?
Thank you.

Unfortunately it is a bit of a mess with the PCA. There are two implementations of it. And they are not accessible from everywhere. Sometimes it’s the one, sometimes the other.
But if your result contains the bands response, error and flags I know which one you have used

flags
Contains a flag which marks the pixels which where covered by the ROI mask you can specify.
error
The membership error for a sample. The error is computed by projecting the sample into eigenspace then projecting it back into sample space
response
The dot product of each basis vector against the sample. Can be used as a measure for membership in the training sample set. High values correspond to a better fit.

The other PCA can be found if you use the Graph Builder.
However, we need to clean up the mess and document the PCA.
Actually it is already known since a while. We have it in our issue tracker
(SNAP-393, SNAP-692).

3 Likes

Thank you very much for explaining. Marpet

Hello,

Could you maybe explain again what are the bands “response” and “error” in a way understandable for a remote sensing newbie? :slight_smile: Also, is it good to have all zeros in the “error” band?

I have also not much knowledge of this matter.
Maybe Wikipedia helps a bit?

Hello everyone,

I am using a time series of ladnsat data (from 1990 up to present) to perform land cover classification.
My graph i created in SNAP executes the following steps.

read image-> GLCM-> PCA-> RandomForest-> write image

I am applying the same steps in all 7 images. Everything goes well, apart from the landsat scene acquired in 1990. WHen i run the graph, i get the following error message.

Error: More data needed to compute the desired number of components

The full error message is the following:

INFO: org.hsqldb.persist.Logger: dataFileCache open start .90% done. org.esa.snap.core.gpf.OperatorException: More data needed to compute the desired number of components at org.esa.snap.core.gpf.graph.GraphProcessor$GPFImagingListener.errorOccurred(GraphProcessor.java:363) at com.sun.media.jai.util.SunTileScheduler.sendExceptionToListener(SunTileScheduler.java:1646) at com.sun.media.jai.util.SunTileScheduler.scheduleTile(SunTileScheduler.java:921) at javax.media.jai.OpImage.getTile(OpImage.java:1129) at javax.media.jai.PlanarImage.getData(PlanarImage.java:2085) at com.bc.ceres.glevel.MultiLevelImage.getData(MultiLevelImage.java:64) at org.esa.snap.core.gpf.internal.OperatorContext.getSourceTile(OperatorContext.java:407) at org.esa.snap.core.gpf.internal.OperatorContext.getSourceTile(OperatorContext.java:393) at org.esa.snap.core.gpf.internal.OperatorImage.computeRect(OperatorImage.java:73) at javax.media.jai.SourcelessOpImage.computeTile(SourcelessOpImage.java:137) at com.sun.media.jai.util.SunTileScheduler.scheduleTile(SunTileScheduler.java:904) at javax.media.jai.OpImage.getTile(OpImage.java:1129) at com.sun.media.jai.util.RequestJob.compute(SunTileScheduler.java:247) at com.sun.media.jai.util.WorkerThread.run(SunTileScheduler.java:468) Caused by: java.lang.IllegalArgumentException: More data needed to compute the desired number of components at org.esa.snap.cluster.PrincipalComponentAnalysis.computeBasis(PrincipalComponentAnalysis.java:70) at org.esa.snap.cluster.PrincipalComponentAnalysisOp.initPca(PrincipalComponentAnalysisOp.java:294) at org.esa.snap.cluster.PrincipalComponentAnalysisOp.doExecute(PrincipalComponentAnalysisOp.java:161) at org.esa.snap.core.gpf.internal.OperatorContext.executeOperator(OperatorContext.java:1243) at org.esa.snap.core.gpf.internal.OperatorImage.computeRect(OperatorImage.java:65) at javax.media.jai.SourcelessOpImage.computeTile(SourcelessOpImage.java:137) at com.sun.media.jai.util.SunTileScheduler.scheduleTile(SunTileScheduler.java:904) ... 11 more

This never happened to me before. I do not quite understand what it means by more data needed to compute the desired number of components. The number of component i am using is six. Even if i reduced or increased the number of components, i get the same error for this specif scene only.

Did anyone else came across with this error message?

Hi,

The same issue when performing PCA analysis occurred to me as well. I have not figured out what the problem is. Someone else might have the answer

Hi Marpet. Would you recomend to use other softwares instead of SNAP becouse of the abscence of PCA documentation?

No, I wouldn’t. As far as I know, it works quite well as long as you know what to do.

PCA is running well but I did not find out the eigenvector matrix to evaluate the PCA results.

PCA has strong dependency on scene area/statistics and bands context (all or selective sensor bands like indicated by the print screen B2, B3, B11, B12). So, we need all statistics like covariance or correlative matrix (standardized PCA), cumulative covariance, eigenvalues and eigenvectors matrix to made possible evaluate the results.

I suppose that we could organize the matrix based on “basis vector” but this is not secure because there is not a clear algorithim ordenance/linking of entry bands and components products

I strangely get a message: SVD Failed.

Am applying it to GLCM data.
Is there something I’m missing?
Should the data have actual HH/HV products as an i/p too apart from texture parameters?

Am I missing any basics?

have you checked if all bands look alright? Did you specifically select the input bands? Sometimes there are additional quality bands or cloud flags (Sentinel-2) which should not be included in the PCA.

Thanks for taking the time to respond Andreas.
I actually gave GLCM output (of 10 bands consisting of texture information) as an input for computing PCA -as I have read in one of the discussions here that PCA helps in reducing the no.of bands as well as keeps the important ones.
So definitely S2 is not the case here. May be, GLCM has few bands that function alike (eg, ASM & Energy), Is that the issue? Or this (PCA) cannot be applied on GLCM o/p?

if the GLCM bands look alright, you should be able to apply PCA to the product. Can you please visually check each of them if they contain valid data?
Also here, we should now focus in one topic - it makes sense to continue here: Sentinel-1 SNAP toolbox image view does not export as Geotiff with spatial reference - #17 by ABraun
If I had to do it, I would first geocode the data, then perform GLCM, then apply PCA.

Would you recomend to use other softwares instead of SNAP becouse of the abscence of PCA documentation?

not really, it works as it should and results will probably quite similar with other tools.

thanks for you quick reply, .

It is still very difficult to use PCA in the snap. the documentation needed to analyze the results is lacking. I tried everything that was suggested here on the forum, but you never have the eigenvalues ​​and eigenvectors that need to be reordered based on the variance/covariance matrix or the correlation matrix, as an option to choose between the two processes for the analyst. images/bands of great quality would give a multitude of possibilities for using techniques and bands such as FCPs, Crósta technique.

1 Like


this is an example of what needs to come out in the pca txt report - statistics and the matrix of var-covar or correl. we do not have to calculate nothing else but only analyze the matrix. the percentage of variance for each should come together and another topics is that we will never have negative values among PC1 values.

1 Like