When I read a raster and then save it with rasterio the pixels are sligthly modified. Code example:
import rasterio
inputFile = './band3.jp2'
with rasterio.open(inputFile) as b3:
v3 = b3.read(1)
print('Before: ',v3)
profile3 = b3.profile
##Saving raster
output='./test.jp2'
with rasterio.open(output, 'w', **profile3) as dst:
dst.write(v3, 1)
##Reading the raster I just saved
with rasterio.open(output) as b3:
v3 = b3.read(1)
print('After: ',v3)
This outputs:
Before:
[[ 0 0 0 ... 665 632 661]
[ 0 0 0 ... 728 687 704]
[ 0 0 0 ... 703 702 700]
...
[ 0 0 0 ... 613 605 603]
[ 0 0 0 ... 610 600 605]
[ 0 0 0 ... 608 606 607]]
Warning 6: driver JP2OpenJPEG does not support creation option TILED #I don't think this is important
After:
[[ 11 0 0 ... 663 629 655]
[ 0 0 0 ... 717 680 687]
[ 0 0 0 ... 689 693 687]
...
[ 1 0 0 ... 604 597 587]
[ 3 0 0 ... 604 595 593]
[ 0 0 0 ... 594 594 589]]
I'm not sure if it is important because I didn't modify it but the profile looks like:
{'driver': 'JP2OpenJPEG', 'dtype': 'uint16', 'nodata': None, 'width': 10980, 'height': 10980, 'count': 1, 'crs': CRS.from_epsg(32615), 'transform': Affine(10.0, 0.0, 600000.0,
0.0, -10.0, 1600020.0), 'blockxsize': 1024, 'blockysize': 1024, 'tiled': True}