[gdal-dev] Doubt about memory raster

Jorge Arévalo jorge.arevalo at gmail.com
Tue Feb 9 11:24:57 EST 2010


2010/2/9 Frank Warmerdam <warmerdam at pobox.com>:
> Jorge Arévalo wrote:
>>
>> In MEM driver page: http://www.gdal.org/frmt_mem.html says:
>>
>> "PIXELOFFSET: Offset in bytes between the start of one pixel and the
>> next on the same scanline. (optional)"
>>
>> The data pixels are bytes, but the pixeloffset is 2. I suppose in the
>> example, the data pixels are interlaced (one scan line starts on
>> pabyBigMem and the other in pabyBigMem + 1), and for this reason
>> pixeloffset = 2.
>>
>> How do you specify this (if pixels are interlaced or not) when
>> creating the raster and adding the bands? Maybe this is not necessary,
>> and you specify this when reading or writing, but then, why in
>> GDALDatasetRasterIO the pixeloffset and lineoffset are set to 0?
>
> Jorge,
>
> To address such an existing array, the options to GDALAddBand()
> would need to include DATAPOINTER, PIXELOFFSET and LINEOFFSET.
> DATAPOINTER for the first call to addband would be pabyBigMem
> and it would be pabyBigMem+1 for the second band.   In both
> cases PIXELOFFSET would be 2 and LINEOFFSET would be
> PIXELOFFSET*(image_width_in_pixels).
>

Mmm... But I suppose this is in case of rasters with pixel type =
Byte. In that cases, should I always follow this scheme? pArray for
first band, pArray + 1 for second band, and so on (interlaced)? I
mean, why don't pArray for first band, pArray + raster_width for
second band...(non interlaced)?

Anyway, I'm working in a "WKT Raster format to GDAL format" parser. I
get all the bands in different arrays: void * pBandData, for example.
And the pixel type of these bands can be Byte, Int16, Float32, etc.
So, I don't have one array for all the raster data, I have a different
one per band.

In such situation, has sense this scheme?

DATAPOINTER = pBandData
PIXELOFFSET = (GDALDataTypeSize(raster_pixel_size) / 8) (this is, 1 =
pixel size byte, 2 = pixel size int16, 4 = pixel size int32, etc)
LINEOFFSET = PIXELOFFSET * raster_width_in_px

Thanks in advance,

Jorge

> Best regards,
> --
> ---------------------------------------+--------------------------------------
> I set the clouds in motion - turn up   | Frank Warmerdam,
> warmerdam at pobox.com
> light and sound - activate the windows | http://pobox.com/~warmerdam
> and watch the world go round - Rush    | Geospatial Programmer for Rent
>
>


More information about the gdal-dev mailing list