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
to_raster() function modifying original variable values on output
I added a reproducible script below and attached a link to the data.
Code Sample
importrioxarrayimportxarrayasxrimportnumpyasnpfrompyprojimportCRS# Open datafpath="./2020/002/00/OR_ABI-L2-LSTM1-M6_G16_s20200020000291_e20200020000349_c20200020001006.nc"ds_xarr=xr.open_dataset(fpath, decode_coords="all")
# Lets convert coords to latitude and longitudecc=CRS.from_cf(ds_xarr.goes_imager_projection.attrs)
ds_xarr.rio.write_crs(cc.to_string(), inplace=True)
sat_height=ds_xarr.goes_imager_projection.attrs["perspective_point_height"]
ds_xarr['x'] =ds_xarr.x.values*sat_heightds_xarr['y'] =ds_xarr.y.values*sat_heightds_xarr4326=ds_xarr.rio.reproject("epsg:4326")
# lets view the min and max valuesprint("original min value: ", np.nanmin(ds_xarr4326['LST'].data)) # 255.795print("original max value:" , np.nanmax(ds_xarr4326['LST'].data)) # 287.8375# Save as raster fileds_xarr4326['LST'].rio.to_raster("./GOES16_LST.tif",driver="GTiff")
# Lets read in output file and view the min max values (why are these different than original data?)outds=xr.open_dataset("./GOES16_LST.tif")
print("outds min value: ", np.nanmin(outds['band_data'].data)) # 108.08print("outds maxvalue: ", np.nanmax(outds['band_data'].data)) # 271.91748
When saving the xarray as a raster (GeoTiff file), the original data values are modified.
See output for min and max values above for more insight.
Originally, min max values were [255.795, 287.8375]. After saving to .tif file, new min max values are [108.08, 271.91748].
Expected Output
Environment Information
rioxarray version: 0.11.1
rasterio version: 1.2.10
GDAL version: (3.4.3)
Python version: 3.10.5
Installation method
conda
Conda environment information (if you installed with conda):
Environment (conda list):
The text was updated successfully, but these errors were encountered:
to_raster() function modifying original variable values on output
I added a reproducible script below and attached a link to the data.
Code Sample
test data location:
https://github.com/arojas314/data-sharing/blob/main/OR_ABI-L2-LSTM1-M6_G16_s20200020000291_e20200020000349_c20200020001006.nc
Problem description
When saving the xarray as a raster (GeoTiff file), the original data values are modified.
See output for min and max values above for more insight.
Originally, min max values were [255.795, 287.8375]. After saving to .tif file, new min max values are [108.08, 271.91748].
Expected Output
Environment Information
0.11.1
1.2.10
3.4.3
)3.10.5
Installation method
Conda environment information (if you installed with conda):
Environment (
conda list
):The text was updated successfully, but these errors were encountered: