You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When I export my 'true_color' satellite image as a netcdf file containing RGB values of each pixel I end up with individual values for R,G or B greater than 255. Surely output RGB values should be between 0 and 255 or 0 and 1. Perhaps there is a scaling factor missing from the netcdf header?
Here is my code:
from satpy.scene import Scene
from satpy import find_files_and_readers
from datetime import datetime
from netCDF4 import Dataset
import numpy as np
files = find_files_and_readers(sensor='olci',
start_time=datetime(2019, 3, 15, 4, 28),
end_time=datetime(2019, 3, 15, 4, 30),
base_dir="/Users/il/Downloads/",
reader='olci_l1b')
scn = Scene(filenames=files)
scn.load(['true_color'])
scn.save_dataset('true_color', writer='cf', filename='true_color.nc')
OLCI_data=Dataset('true_color.nc')
OLCI_z=np.asarray(OLCI_data['true_color'])
print(np.nanmax(OLCI_z))
Thanks for reporting this. Saving an RGB image to netcdf will not apply the enhancements, so the data you have then are the untouched physical values read from the files, in this case reflectances. In turn these are more that 100% sometimes because of sun zenith angle normalisation for example. Usually for RGB, we use GeoTiffs or other image formats here, but do you plan to visualise RGBs in netcdf in your case ?
Yes that was my intention - I wanted to avoid working with GeoTiffs mainly just because I never have before and thought this could be a quicker way of doing things. Looks like I might have to though?
Perhaps it ought to be changed in the output netcdf so it doesn't say 'R', 'G', 'B' in the 'bands' parameter as this is a little misleading.
At the moment, having enhanced RGBs (stretched to 0-255) isn't implemented for netcdf saving, but it shouldn't be to difficult to implement. If you feel like you want to give it a try, be sure to join us on the pytroll slack if you need some guidance (see pytroll.org to find out how to connect to slack).
Hello,
When I export my 'true_color' satellite image as a netcdf file containing RGB values of each pixel I end up with individual values for R,G or B greater than 255. Surely output RGB values should be between 0 and 255 or 0 and 1. Perhaps there is a scaling factor missing from the netcdf header?
Here is my code:
Returns:
351.80767121471672
Here is the netcdf header:
Many thanks,
The text was updated successfully, but these errors were encountered: