[Gdal-dev] how to write block by block to file

Frank Warmerdam warmerdam at pobox.com
Thu Jan 15 01:18:46 EST 2004


Pushkar Pradhan wrote:
>>Well, it is hard to be sure why it is seg faulting.  I would suggest
>>running it in the debugger to at least determine where it faults!
> 
> Sorry not to tell that, it causes seg fault at this line:
>   poDstDS = poDriver->Create(dwtFile, imgXSize, imgYSize, 1, GDT_Float32,
>   NULL);

Pushkar,

Now that I review your earlier email, I see you did state where it crashed.
What is poDriver?  Are you sure it isn't NULL?  dwtFile is a proper filename?
Nothing to odd about imgXSize or imgYSize?  Assuming that poDriver is a
driver supporting the create call (such as GeoTIFF) things should be fine.

>>However, your above code is likely to fail on partial right side, or
>>bottom edge tiles/blocks if the file is actually tiled, rather than
>>being using scanline blocks.
>>Unless maximum performance is of the utmost importance, I would suggest
>>simplifying this to read and write the data one scanline at a time.
> 
> I'm trying to parallelize my algorithms so I think I will try different read
> sizes (e.g. tile vs. strips).
> Doesn't GDAL handle it when you reach the right/bottom boundaries by
> returning only valid data, I think libtiff does something like this, because
> when I was using libtiff I used similar code.

GDAL's RasterIO() calls do not in general allow you to read or write windows
that fall off the edges of the datasource.  The lower level block io API
has no problem with edge tiles of course.

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