Gpt Write NetCDF vs NetCDF4

Conversion into NetCDF4-BEAM is very useful to save some memory when storing processed images.
I am able to convert (or export) into NetCDF4-BEAM or NetCDF4-CF from the snap gui.
I would like to do the same thing with gpt:

gpt Write -PformatName=$oformat -Pfile=$ofile -Ssource=$ifile

If I set oformat as NetCDF-CF or NetCDF-BEAM, it is working perfectly!
But, when oformat = NetCDF4-CF or NetCDF4-BEAM (enabling image compression), I do get, but it is unreadable:

ncdump -h
ncdump: NetCDF: Unknown file format

Any idea?

Is it possible that the ncdump is outdated?
Maybe it can only read NetCDF3 and not yet NetCDF4?

Thanks for your reply.
After some tests on several machines, neither gdalinfo, ncinfo nor snap software can open the generated by gpt in netcdf4.
( generated via snap gui is all right)

Can you provide me both files, the input and the output?
I’ll send you a PM with a location where you can upload it.

Hello Tristan,

Unfortunately I hadn’t the time to investigate your problem in more detail. As there has been a similar report now, the priority rises.

It seems we found the issue and solved it. It will be deployed with the next SNAP update.
If bands already existed with the name ‘lat’ or ‘lon’ then the error happend.
So renaming those bands can help or excluding them by a subset after reprojection should help as a workaround.

gpt is now producing the following error when asking for any NetCDF* format
(gpt Write -PformatName=NetCDF-CF -Pfile=$ofile -Ssource=$ifile):

	at org.esa.snap.core.gpf.internal.OperatorExecutor$GPFImagingListener.errorOccurred(
Caused by: java.lang.NullPointerException
	at org.esa.snap.dataio.netcdf.NetCdfWriteProfile.writeProduct(
	at org.esa.snap.dataio.netcdf.DefaultNetCdfWriter.writeProductNodesImpl(
	at org.esa.snap.core.dataio.AbstractProductWriter.writeProductNodes(
	at org.esa.snap.core.gpf.common.WriteOp.doExecute(
	at org.esa.snap.core.gpf.internal.OperatorContext.executeOperator(
	at org.esa.snap.core.gpf.internal.OperatorImage.computeRect(
	... 3 more

Error: org.esa.snap.core.gpf.OperatorException

On the other hand, it is working perfectly for other formats (HDF5, GeoTIFF…)
Any idea?

This should be fixed (SNAP-1088) with the next version.

1 Like