2

I have an image that I have created which is basically paired image with two bands: band 1 is NDVI image from Sentinel 2 band 2 is SAR image from Sentinel 1

I have tried to export this image to my drive and I get the next error:

bands must have compatible data types; found inconsistent types: Float32 and Float64.

I have seen here few posts about the same error, but couldn't fix it:

I have tried to change it to int16, and it worked, but i'm afraid I'm losing data. I have tried to use the same code but instead of 16 to put 32 but i'm afraid I'm losing data from the 64 and to be honest I couldn't understand really the different between the different numbers. Also, I couldn't use toUint64(). When I upload the int32 image to QGIS, I got black square with values of 0. I don't really need the visualization but I'm worried that I have gotten values 0 and I don't have any value.

pairedImage = pairedImage.toUint32();

Export.image.toDrive({
  image: pairedImage,
  description: 'imageToDriveExample',
  scale: 20,
  region: geometry
});
print('Paired Image',pairedImage);

My end goal is to understand what are the consequence of this, which data I might lose and how I can keep my data.

2

Sentinel-1 SAR bands are Double type (64-bit floating point) and computed images derived from normalizedDifference() (e.g., NDVI) are Float type (32-bit floating point).

The difference is in range capacity and precision. However, regarding satellite-based image data, the full capacity of 32-bit floating point precision is far more precision than the instruments can provide, so using the lowest precision data type of your images (Float) would be fine. See here for more information on Float and Double types.

When you cast floating point data using toUint32() you are eliminating the unit fraction and forcing negative values to 0, which is why your result is all 0s.

I would cast both bands to Float independently and then combine them for exporting.

// Cast SAR band to 32-bit floating point.
mySarBand = mySarBand.toFloat();

// Cast NDVI band to 32-bit floating point.
myNdviBand = myNdviBand.toFloat();

// Combine the bands into a single image.
var pairedImage = ee.Image.cat([mySarBand, myNdviBand])
  .rename('SAR', 'NDVI');

// Export image to Drive.
Export.image.toDrive({...arguments...});

Depending on the range of the data, you can also minimize file size by multiplying your data by 1,000 or 10,000 and then cast as Int16, which retains a few decimal places of precision for floating point data, which is generally enough.

var myDataScaled = myData.multiply(10000).toShort();

Not the answer you're looking for? Browse other questions tagged or ask your own question.