Add external DEM as elevation band

Dear developers,

I have a question regarding the AddElevationOp of the snap-engine. When I want to add a external DEM (geotiff-file) it gives me an error (nullpointer). The nullpointer occurs during initialize when the target file is created.

        if (externalDEM != null && !externalDEM.trim().isEmpty()) {

            fileElevationModel = new FileElevationModel(new File(externalDEM), resamplingMethod, null);
            noDataValue = fileElevationModel.getNoDataValue();
        } else {

            dem = DEMFactory.createElevationModel(demName, resamplingMethod);
            noDataValue = dem.getDescriptor().getNoDataValue();


When debugging I found that this line in createTargetProduct() causes the problem:


When using an external DEM, the dem-variable is still empty. I think that fileElevationModel should be dem? What do you think?

Kind regards,


Yes, this is a bug. The dem variable is not correctly initialised inelevationBand.setDescription(dem.getDescriptor().getName())
@JunLu I’ve send a pull request, which should fix this problem.

Hi Marco, the modified code has been merged into master. Thanks. Jun

Hi Guys,

Thanks for your quick replies and fixes, but I still got errors when adding an external DEM. I went into the code and found that there are more bugs.

In createTargetProduct() this line still causes problems with an external DEM:


Because the dem.getDescriptor() does not exist for a external DEM…

When I comment this out and re-run the operator, a new error occurs in computeTile() at this line:

final double demNoDataValue = dem.getDescriptor().getNoDataValue();

This happens because of the same reason.

Maybe as a suggestion, I looked into the InterferogramOp and there you have to provide a the no-data value of the external dem yourself (“externalDemNoDataValue”) and they use the filename as name for the DEM. Would this a solution to fix these bugs?

Kind regards,


I think you don’t have the latest sources yet. There were more updates yesterday evening. Please update and try again. Thanks for your effort. It’s much appreciated.

Ah I see the new commits now. Probably the where added about the time I replied to this post. Thanks a lot, these fixes are also much appreciated!


I am an external DEM generated in ENVI (SRTM 30m). How can I import it into SNAP?
Here are the files and extensions. The first file is the one that I use in ENVI for terrain correction.
Thank you,

you have to convert it into a tif file first. Also subseting might be a good idea (considering the file size).
You can do this in QGIS, for example.