I'm using rasterio to analyze satellite imagery stored in JPEG2000 format and am having the problem that pixel values change when opening and then saving the same file again. Any ideas why this happens?
with rasterio.open('/tmp/in.jp2') as infile:
with rasterio.open('/tmp/out.jp2', 'w', count=infile.count, dtype=infile.dtypes[0], height=infile.height, width=infile.width, crs=infile.crs, transform=infile.transform) as outfile:
outfile.write(infile.read())
with rasterio.open('/tmp/in.jp2') as f:
data = f.read()
print(data.min(), data.max())
# output: 0 19614
with rasterio.open('/tmp/out.jp2') as f:
data = f.read()
print(data.min(), data.max())
# output: 0 19596