[gdal-dev] Creating a new raster and adding data
Henneke, Amanda M
amanda.m.henneke at boeing.com
Fri Jul 17 08:38:59 EDT 2009
Hello all-
Using the C# gdal libraries, I'm trying to create a new raster dataset with 5 bands and then use the WriteRaster method to add data to each of those 5 bands.
This is what I have so far...
Dataset ds = Gdal.Open("F:\\Mat_Class\\Alaska\\new_tifs\\class_ak_sheet_8a.tif", Access.GA_Update);
Dataset ds_new = drv.Create("F:\\Mat_Class\\Alaska\\new_tifs\\class_ak_sheet_8a_test.tif", ds.RasterXSize, ds.RasterYSize, 5, DataType.GDT_Byte, new string[] { });
byte[] r_buffer = new byte[iWidth * iHeight];
byte[] g_buffer = new byte[iWidth * iHeight];
byte[] b_buffer = new byte[iWidth * iHeight];
<get/set values for r_buffer, g_buffer and b_buffer>
int[] iBandMap = { 1, 2, 3, 4, 5 };
ds_new.WriteRaster(0, 0, iWidth, iHeight, r_buffer, iWidth, iHeight, 1, iBandMap, 0, 0, 0);
ds_new.WriteRaster(0, 0, iWidth, iHeight, g_buffer, iWidth, iHeight, 2, iBandMap, 0, 0, 0);
ds_new.WriteRaster(0, 0, iWidth, iHeight, b_buffer, iWidth, iHeight, 3, iBandMap, 0, 0, 0);
I'm getting an exception that says "AccessViolationException was unhandled. Attemped to read or write protected memory. This is often an indication that other memory is corrupt."
Any one have any ideas what I'm doing wrong?
Thanks for any help!
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.
More information about the gdal-dev
mailing list