[gdal-dev] Creating a new raster and adding data

Even Rouault even.rouault at mines-paris.org
Mon Jul 20 15:17:09 EDT 2009


Amanda,

you're not doing anything wrong now. It's rather a defect of the current C# 
GDAL bindings when dealing with multiple bands. See ticket 
http://trac.osgeo.org/gdal/ticket/3073 that contains a proposed fix for the 
issue.

In the meantime, you can use the WriteRaster() method on each band instead. 
For most drivers, it will have similar performance to WriteRaster() on the 
dataset itself.

Best regards,
Even

Le Monday 20 July 2009 18:36:27 Henneke, Amanda M, vous avez écrit :
> Ok, so after some more experimentation, I think I found that the reason
> it was dying was due to a file being too large.  When I run it on a
> smaller dataset, it seems I am successful in getting past the
> WriteRaster command in my code.
>
> The bad news is that it doesn't seem to be working properly.  It seems
> to write the first band correctly, but bands 2-5 are written
> incorrectly.  The buffer I'm using checks out before and after the
> WriteRaster command.  So it has got to be something with the WriteRaster
> command that is not working.  I've played with the offsets and all,
> especially the bandspace, linespace and rasterspace arguments.   Anyone
> have similar problems, or any ideas as to why I can't get the
> WriteRaster to work?
>
> Thanks!
>
>
> Amanda M. Henneke
>
> When One tugs at a single thing in Nature, he finds it attached to the
> rest of the world. -John Muir
>   Please consider the environment before printing this e-mail.
>
> -----Original Message-----
> From: Frank Warmerdam [mailto:warmerdam at pobox.com]
> Sent: Friday, July 17, 2009 3:33 PM
> To: Henneke, Amanda M
> Subject: Re: [gdal-dev] Creating a new raster and adding data
>
> Henneke, Amanda M wrote:
> > Thanks Frank for your help, I think I'm further, but still not quite
> > there.
> >
> > The definition requires me to send the iBandMap as an array, I cannot
> > insert the index of the band I wish to write, because then I'm just
> > passing an integer.  So with that said, I decided to combine all my
> > byte arrays (buffers) of data into one array and call Write Raster as
> > follows:
> >
> > byte[] buffers = new byte[(iHeight * iWidth) * 3];
> > r_buffer.CopyTo(buffers, 0); g_buffer.CopyTo(buffers,
> > r_buffer.Length); b_buffer.CopyTo(buffers, r_buffer.Length * 2);
> >
> > ds_new.WriteRaster(0, 0, iWidth, iHeight, buffers, iWidth, iHeight, 3,
> >
> > iBandMap, 0, 0, 0);
> >
> > But I'm still getting the same exception, so something else must not
> > be quite right.  I've tried playing around with the pixelSpace,
> > lineSpace and bandSpace parameters and still no success...any other
> > ideas what I'm still missing?
>
> Amanda,
>
> Your new approach looks reasonable.  I don't know what is going wrong.
>
> Best regards,




More information about the gdal-dev mailing list