Re: [gdal-dev] Writing pixel values

Ivan Lucena ivan.lucena at pmldnet.com
Wed Sep 15 11:58:21 EDT 2010


Akhil,

How did you create or opened the output? Did you also create the bands before calling GDALRasterIO?

See examples on: http://gdal.org/gdal_tutorial.html

Regards,

Ivan


>  -------Original Message-------
>  From: Akhil Jaggarwal <axj4159 at cs.rit.edu>
>  To: gdal-dev at lists.osgeo.org
>  Subject: [gdal-dev] Writing pixel values
>  Sent: Sep 15 '10 10:52
>  
>  Hi,
>  
>  Any comments/suggestions on this issue would be immensely helpful!
>  
>  I'm storing the pixel values in a buffer like this:
>  
>  pafScanline = (short int*)CPLMalloc(sizeof(short int)*nxSize*nySize);
>  
>  I can read the data alright. The call to GDALRasterIO is being made
>  correctly, which I do with:
>  
>  GDALRasterIO(hBand, GF_Read, 0, 0, nxSize, nySize,
>                         pafScanline,
>                         nxSize,nySize,
>                         GDT_Int16,
>                         0, 0);
>  However, when it comes to the part of writing a pixel data to an
>  output file, the call to GDALRasterIO fails:
>  
>  for(i = 0; i < nySize; i++) {
>                 for(j = 0; j < nxSize; j++) {
>  
>                         if( CE_Failure == GDALRasterIO( hDestDS,
>  GF_Write, 0, 0, j, i,
>                           change1, j, i , GDT_Int16, 0,0) ) {
>                                   printf("Write Error!");
>                                   return 1;
>                           }
>               }
>    }
>  
>  Where change1 is a variable to hold pixel data that I want to change.
>  It's declared in the following manner:
>  
>  short int*change1;
>  change1 = malloc(sizeof(short int));
>  *change1 = 1;
>  
>  I can't get what exactly am I missing. The file i'm using is a tiled,
>  16 bit signed TIFF.
>  
>  How do I change the value at a pixel location?
>  
>  Thanks!
>  _______________________________________________
>  gdal-dev mailing list
>  gdal-dev at lists.osgeo.org
>  http://lists.osgeo.org/mailman/listinfo/gdal-dev
>  


More information about the gdal-dev mailing list