A line of data can be read into memory using the DBReadLine() intrinsic. First a data buffer needs to be allocated to hold the data being read from the file.
local float databuffer[LinesSize]
DBReadLine() can be used to read any part of a line from anywhere within the image directly into the data buffer. If the buffer is not of the same type as the data on the file, the data is automatically translated to the appropriate type. DBReadLines takes 6 arguments (in order):
For example, the following command will read all of the first line of data of the first channel:
call DBReadLine( fd, 1, 0, 0, NumPixels, DataBuffer )
Once the data has been read, the contents of the buffer can be examined and manipulated. For example, the following loop determines the maximum value in the line of data.
local float MaxValue
local integer i
MaxValue = DataBuffer[1]
for i = 2 to NumPixels
if ( DataBuffer[i] > MaxValue ) then
MaxValue = DataBuffer[i]
endif
endfor
printf "The maximum value in the line is %f\n", MaxValue
The DBWriteLine() intrinsic is used to write data back to the file. For example, to copy the contents of DataBuffer into the last line of channel 2:
call DBWriteLine( fd, 2, 0, NumLines-1, NumPixels, DataBuffer )
In this case the third and fourth arguments to the function are the x and y offsets to the start of the last line of the channel.
© PCI Geomatics Enterprises, Inc.®, 2026. All rights reserved.