Hello all,
I am using python and snappy to copy data from a source product (geo-tiff) to a larger target product and I encountered the following problems:
- When saving the target product as HDF5, no geolocation is saved in the product, i.e. when opening it in SNAP, the pixels only have the value, no latitude/longitude.
- When making the target product larger (10.000x10.000 pixels) the method “target_band.ensureRasterData()” gives a OutOfMemoryError.
Here the relevant part of my code:
source = snappy.ProductIO.readProduct(path)
b = source.getBand(param)
target = snappy.Product(source.getProductType(), source.getProductType(), 10000, 10000)
snappy.ProductUtils.copyProductNodes(source, target)
type = snappy.ProductData.TYPE_INT32
target_band = snappy.Band('_world', type, 10000, 10000)
snappy.ProductUtils.copyRasterDataNodeProperties(b, target_band)
target.addBand(target_band)
target_band.setNoDataValue(np.nan)
target_band.setNoDataValueUsed(True)
target.setProductWriter(snappy.ProductIO.getProductWriter('HDF5'))
target.writeHeader(snappy.String('target.h5'))
target_band.ensureRasterData()
gc_target = target.getSceneGeoCoding()
map_crs = gc_target.getMapCRS()
gc_target = CrsGeoCoding(map_crs, 10000,10000,7.0,48.0,0.0027,0.0027)
#set pixel values with "target_band.setPixel(...)"
snappy.ProductIO.writeProduct(target, 'target.h5', 'HDF5')
target.closeIO()
Am I using the ProductWriter wrongly? Is there another way to ensure that the RasterData and the GeoCoding is set correctly?
Thanks for any help!