How to save measurement range when converting to 8 bits

Hi.
i have file with values interval from 100 to 320. To decrease it’s size and crop ROI i use grdconvert/gdal_translate with casting data from 16bits to 8bits.
To do this, I am forced to narrow the existing values range because of nodata value is zero.
In addition, there is a requirement to invert the values.
So my command includes -a_scale -1.96 -a_offset 380 and it’s reduces the interval by ~0.7

How to get initial (~220) interval in this case? File used as input in grdimage.

Thank You

radiation
radiation.zip (299,6 КБ)

You really want to get into this? There is almost no gain. It can be done with some work but integers compress very highly and 8bit ints do not go along very well with netCDF.

ok, how to plot 16 bits data. I think that it must be some cunning cpt file.
Or it can be any data in first colomn in this file. Yes, i’m trying this

You plot it like other grids … except that, and I don’t know why, GMT doesn’t like this .nc file. You’ll have to use the=gd suffix (means, import via GDAL) in order to manipulate this grid.

I guessed it. The result is
grdmath file.tif=gd 0 GT file.tif=gd 100 SUB file.tif=gd IFELSE = output.nc
but.

  • fault to set any -R parameter. It was the goal of my attempts I’ve the error in case of setting -R

grdmath [WARNING]: (e - x_min) must equal (NX + eps) * x_inc), where NX is an integer and |eps| <= 0.0001.
grdmath [WARNING]: e reset from -150 to -149.976
grdmath [ERROR]: Computed -srcwin falls outside raster size of 10000x5000.
grdmath [ERROR]: ERROR reading file with gdalread.
grdmath (gmtapi_import_grid): Could not open file [input.tif=gd]
Error returned from GMT API: GMT_GRID_READ_ERROR (18)
If i use gdal_translate with -prowin no errors raised

  • really, no any difference 8/16 bit. But maybe it’s important for memory allocation
  • don’t find successful syntax for using STO/RCL operators. If “=rd” skipped result file size raised (x8)

GMT internally uses Float32. You gain nothing doing those operations if memory consumption inside GMT is the goal.

The goal is cropping the ROI. I wrote about future using cropping files in other soft maybe. The HDF format is more convenient than GeoTIFF.. In any case it’s really as syntactic sugar. We forgot about it

Than probably the best is to use gdal_translate. Your .nc file not GMT friendly anyway.