Writing product problem with ProductIO.writeProduct

The problem I am facing is part of more complex workflow, but I believe that it could be simplified to this simple case. I have a tif image file and I am reading it from disk to Product like this:

java.io.File file = new java.io.File(outFilePath);
Product inProduct = CommonReaders.readProduct(file);

The inProduct variable seems fine, it has band, dimensions and so. Now I just try to save it to other location on disk like this:

ProductIO.writeProduct(inProduct, "d:\\desktop\\test.tif", "GeoTIFF");

The resulting file is created, it has correct dimensions, resolution, but it has no data, it is all zeros. What am I doing wrong?

I just did the same and the resulting file is okay.
I just used ProductIO instead of CommonReaders, but this should not make a difference.
Which version of SNAP do you use?

        File file = new File("H:\\geotiff\\LzwGeotiff_issue\\AL01_AV2_OBS_1C_20080715T181736_20080715T181748_ESR_013182_3985.TIF");
        Product inProduct = ProductIO.readProduct(file);
        ProductIO.writeProduct(inProduct, "H:\\_temp\\test.tif", "GeoTIFF");

Thank you. I have snap 8.0. But I have already came to conclusion, that the code is OK.
The problem is with that tif file. I have created it with gdal module in Python. In ArcMap it has correct values, but in Snap it is all zeros. I guess I am missing something in that raster creation process, but have no clue what. Don’t you have some tip what may be the problem?

What’s the data type and the value range of the data?
Can you provide the file?

I found it. I have created output raster for writing tif in python like this:
out_ds = driver.Create(out_file, cols, rows, 1, gdal.CGDT_Float32)
The issue was that it was complex number not floating point. This way it worked:
out_ds = driver.Create(out_file, cols, rows, 1, gdal.GDT_Float32)
Thank you.

1 Like