1

I am using ArcMap 10.2.2.

I have two .hgt files in 16-bit signed integer data. All I have done so far is to mosaic them together (Mosaic to new raster).

Since the DEM data are provided in Motorola or IEEE byte order, which stores the most significant byte first ("big endian"), I`d have to swap the bytes. The only examples I have found show how to swap the unsigned integer data, e.g. CON([in_grid] >= 32768, [in_grid] - 65536, [in_grid])

Can someone advise me which expression should I use for 16-bit signed integer?

  • Are the .hgt files "twos complement" or "ones complement"? (the latter is how DTED files are encoded, and permits a range of values from -65535 to 65635 with both positive and negative zeros). If the values are twos complement, you can use bitwise arithmetic: newval = oldval<< 8 | ((oldval>>8) & 0x0FF) Ones complement would be trickier. – Vince Dec 28 '15 at 19:15
  • I have no idea if they are "ones complement" or "twos complement". How can I see it? – mikbet Dec 28 '15 at 21:29
  • They appear to be twos complement, but the bitwise operators in Spatial Analyst require a more extravagant usage: newgrid = BitwiseOr( bitwiseLeftShift( BitwiseAnd( oldgrid,255),8), BitwiseAnd(BitwiseRightShift( oldgrid, 8),255) ) If you read the files as generic binary, with a .hdr file, you should have been able to specify endianness at the onset, which would have saved extra work after mosaicking – Vince Dec 28 '15 at 22:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.