I am using C# bindings for gdal in order to get elevation data from GeoTIFF files. The API contains a Band.ReadRaster method. This method supports a lot of data types, but for reading unsigned integers, only contains a method compatible with byte data. However, GeoTIFF files also support data being in ushort or uint format.
How can I use the byte version of ReadRaster to read these formats?
My assumption is to create a byte array that is of length [img width * img height * 2] for ushort and [img width * img height * 4] for uint, call the ReadRaster method, and then convert every two bytes in the array to a ushort (or 4 bytes to a uint).
However, if this is the correct path, I am not sure if I need to worry about byte ordering (little endian vs big endian)?
What would be the method I need to use to convert the bytes to ushort or uint?
Will BitConverter.ToUInt16 and BitConverter.ToUInt32 work?