Stacking all bands and saving as COG #202
-
What I'm trying to do is to stack all of the bands in a single COG, but, for me this is not working: # Create the reader
reader = Reader()
# Open your product
prod = reader.open(product_path, remove_tmp=True)
ok_bands = prod.get_existing_bands()
prod.stack(ok_bands, stack_path="stack_COG.tiff", driver="COG", **{TO_REFLECTANCE: False}) Not sure what is the proper way of doing this, but I would like as well to resample all the bands to the higher resolution one instead of the lower resolution one. 🤔 I'm wondering as well, if there is a way to set the colorintrp to the proper Red, Green and Blue bands 🤔 |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 6 replies
-
|
Beta Was this translation helpful? Give feedback.
-
I didn't know that PS : you could also do: # Create the reader
reader = Reader()
# Open your product
prod = reader.open(product_path, remove_tmp=True)
ok_bands = prod.get_existing_bands()
stack = prod.stack(ok_bands, **{TO_REFLECTANCE: False})
# Sertit (you may need to install `tifffile` library)
rasters.write(stack, "stack_COG.tiff", driver="COG", dtype="float32")
# or using directly
stack.rio.to_raster("stack_COG.tiff", driver="COG", dtype="float32") |
Beta Was this translation helpful? Give feedback.
I didn't know that
driver
was a used keyword when reading 🤔I've purged it. It works for me. Could you try again (you may need to install
tifffile
library) ?PS : you could also do: