TransWikia.com

Rasterio modifying JP2000 values

Geographic Information Systems Asked by Ron Gitson on February 20, 2021

I am trying to mask out some of the Sentinel-2 L1C Bands prior to other applications that require me to keep the classic .SAFE structure of the data.

I usually use rasterio with no trouble, but even with an operation as simple as

import rasterio as rio 

input_band = ".../T33NVE_20180101T091351_B02.jp2"
out = ".../test"

with rio.open(input_band) as src:
    data = src.read()
    prof = src.profile
    
with rio.open(out, mode='w', **prof) as dst:
    dst.write(data)    

Here is what I get :

Input Image :
Base Image

Output Image
Coppied image

I know JP2000 is a lossy format, and I don’t usually use it….
What can I do to end up with the jp2 files recognized by Sen2cor?

One Answer

This rasterio issue suggests to add two parameters to the profile to write the image in a lossless fashion:

profile.update({
    'QUALITY': '100',
    'REVERSIBLE': 'YES',
})

Source: https://github.com/mapbox/rasterio/issues/1677

Correct answer by guampi on February 20, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP