Rainer M Krug wrote: > What I would like to do is tho change the default type from CELL to > FCELL - i.e. whenever a new raster is created, it will *always* and > *automatically* be saved in a FCELL raster, even if it only contains > integer values, and not in a CELL raster.
This isn't possible. If a module generates a CELL map, it's invariably because it's performing the calculations using integers. Converting the final result to floating-point wouldn't help; if the integer calculations overflow, converting the result to floating-point won't "undo" the overflow. Some modules will generate either integer or floating-point output depending upon the type of the inputs. > so > > oldmap * 1 > > results in a raster of the same type as oldmap, Arithmetic operations on mixed types promote to the lesser type to the greater type, where CELL < FCELL < DCELL. > where > > oldmap * 1.0 > > would result in a FCELL? Actually, it will result in DCELL. r.mapcalc follows C syntax: floating-point literals are double precision unless suffixed with an "f", so "oldmap * 1.0f" will result in FCELL (unless oldmap is DCELL). But float(oldmap) or double(oldmap) do the same thing but avoid the gratuitous multiply operation. Also: 1. If you are having issues with overflow, you need to promote values before calculations, e.g. "float(x) * y". Using "float(x * y)" will result in x*y overflowing, then the overflowed value will be converted. 2. Single precision (FCELL) only has a 24-bit mantissa, so integers greater than 2^24 (16777216) cannot always be represented exactly. Double precision (DCELL) has a 53-bit mantissa. -- Glynn Clements <[email protected]> _______________________________________________ grass-user mailing list [email protected] http://lists.osgeo.org/mailman/listinfo/grass-user
