IDRISI->GRASS (negative numbers)
Michael Shapiro
shapiro at zorro.cecer.army.mil
Sat Apr 11 08:02:19 EDT 1992
>How to get IDRISI files containing negative values to GRASS.
I need a little more information about IDRISI. Are they 2 byte
data values? If so you have to work a little harder to get GRASS
to see them as negatives. GRASS stores negative in a funny (but
machine portable) way. They are alway 4 byte numbers. 2 byte
negatives will look like large positive values to GRASS. Assuming
byte swapping is putting the numbers in highbyte/lowbyte
ordering, and assuming that "IDRISI" is using 2s complement (a
likely possibility) then -1 will look like 1111111111111111 in
IDRISI, to GRASS like 255*256+255 = 65535, -2 in idrisi is
1111111111111110 or 255*256+254 = 65534. The largest positive 2
byte value is 0111111111111111 = 128*256 + 255 = 32767. Thus you
could import the IDRISI files (after byte swapping) and run a
mapcalc script to convert large positive values back to their
correct negatives
r.mapcalc "grass = if (idrisi < 32768, idrisi, idrisi - 65536)"
This assumes 2 byte data, high/low byte ordering after swapping,
2s complement negatives, etc. If you have something else then you
need to work out a similar scenario.
-----------------------------------------------------------------
Michael Shapiro U.S. Army CERL
email: shapiro at zorro.cecer.army.mil Environmental Division
phone: (217) 352-6511 ext 526 P.O. Box 9005
fax: (217) 373-7222 Champaign, Ill. 61826-9005
-----------------------------------------------------------------
More information about the grass-user
mailing list