[Gdal-dev] Re: RasterIO: replicating a value
Carlos A. Rueda
carueda at ucdavis.edu
Thu Feb 17 02:50:55 EST 2005
Hi Frank again,
OK, the Fill() seems to be a reasonable way to assure that
you put some appropriate "background" value. That's OK.
However, I'm still noticing something wrong regarding my
original posting: replicating a value. The attached test
program creates a 10x6 1-band raster of type byte; fills
it with '_' and then calls RasterIO to set the upper left
7x3 region with 'X':
$ g++ rasteriotest.cc -lgdal -Wall
$ ./a.out
result = 0
$ cat raster
_____________X______________________________________________
but it should be:
XXXXXXXXXXXXXXXXXXXXX_______________________________________
Right?
Thanks again.
Carlos
Frank Warmerdam wrote:
> On Wed, 16 Feb 2005 15:35:34 -0800, Carlos A. Rueda <carueda at ucdavis.edu> wrote:
>
>>Hi Frank,
>>
>>Attached is a small test program that recreates (at least for me)
>>the problem:
>>
>>$ g++ rasteriotest.cc -lgdal
>>$ ./a.out
>>result = 0
>>$ ls -l
>>-rwxr-xr-x 1 carueda carueda 36774 Feb 16 15:03 a.out
>>-rw-r--r-- 1 carueda carueda 604000 Feb 16 15:12 rasterfilename
>>-rw-r--r-- 1 carueda carueda 339 Feb 16 15:12 rasterfilename.hdr
>>-rw-r--r-- 1 carueda carueda 1185 Feb 16 15:09 rasteriotest.cc
>>
>>but rasterfilename should be 1000x1000x1x4 = 4000000 bytes long.
>>Well, I'm assuming that just creating/deleting the dataset object would
>>set the whole size of the file (with whatever default band values)
>>regardless of what data are explicitily written. If this is not the
>>case, how can I guarantee the desired size without having to write
>>the whole dataset (my application is certainly filling some regions
>>but not the whole thing necessarily).
>
>
> Carlos,
>
> There is no guarantee that all the space required for a file will be
> allocated at the Create() call or even when a newly created files is
> closed. If you want to be certain that the file is fully written out you
> will need to call Fill() on it, or in some other fashion write the whole
> thing.
>
> Sorry ... I realize that isn't the answer you were hoping for.
>
> Best regards,
-------------- next part --------------
A non-text attachment was scrubbed...
Name: rasteriotest.cc
Type: text/x-c++src
Size: 1247 bytes
Desc: not available
Url : http://lists.osgeo.org/pipermail/gdal-dev/attachments/20050216/2a6d2e09/rasteriotest.bin
More information about the Gdal-dev
mailing list