Can RasterIO write one band at a time or must I combine my separate R,G,B buffers first?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Can RasterIO write one band at a time or must I combine my separate R,G,B buffers first?

Ethan
I am writing a C++ program that reads in 3 separate single band geotiffs, applies some math to them, then outputs a single geotiff files that contains the data from those 3 files in the bands 1,2 and 3.  I've so far set up the code to follow the methods from the gdal api tutorial and have read in the values from each of the 3 geotiffs to 3 separate buffers.  When it comes time to use RasterIO to write to my single output geotiff, is there any way to write one band at a time?  Or is there any way to use the RasterIO function without first combining my 3 buffers into a single buffer?  For me the RasterIO documentation is a little unclear when it describes:
        nBandCount the number of bands being read or written.
        panBandMap the list of nBandCount band numbers being read/written. Note band numbers are 1 based. This may be NULL to select the first nBandCount bands.

Thanks in advance for any help it's much appreciated.
Reply | Threaded
Open this post in threaded view
|

Re: Can RasterIO write one band at a time or must I combine my separate R,G,B buffers first?

Kyle Shannon
Ethan, you can fetch single bands using GDALRasterBand* poBand = GetRasterBand(1) and use poBand->RasterIO(...).  See docs here:



/**
 *
 * Kyle Shannon
 * [hidden email]
 *
 */




On Wed, Feb 8, 2012 at 08:39, Ethan <[hidden email]> wrote:
I am writing a C++ program that reads in 3 separate single band geotiffs,
applies some math to them, then outputs a single geotiff files that contains
the data from those 3 files in the bands 1,2 and 3.  I've so far set up the
code to follow the methods from the gdal api tutorial and have read in the
values from each of the 3 geotiffs to 3 separate buffers.  When it comes
time to use RasterIO to write to my single output geotiff, is there any way
to write one band at a time?  Or is there any way to use the RasterIO
function without first combining my 3 buffers into a single buffer?  For me
the RasterIO documentation is a little unclear when it describes:
       nBandCount      the number of bands being read or written.
       panBandMap      the list of nBandCount band numbers being read/written. Note
band numbers are 1 based. This may be NULL to select the first nBandCount
bands.

Thanks in advance for any help it's much appreciated.

--
View this message in context: http://osgeo-org.1560.n6.nabble.com/Can-RasterIO-write-one-band-at-a-time-or-must-I-combine-my-separate-R-G-B-buffers-first-tp4376337p4376337.html
Sent from the GDAL - Dev mailing list archive at Nabble.com.
_______________________________________________
gdal-dev mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/gdal-dev


_______________________________________________
gdal-dev mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/gdal-dev
Reply | Threaded
Open this post in threaded view
|

Re: Can RasterIO write one band at a time or must I combine my separate R,G,B buffers first?

Ethan
Thanks Kyle that worked perfectly, much obliged.
Reply | Threaded
Open this post in threaded view
|

[gdal-dev] Use Gdal in CentOS Mono

Jaugeas, Pascal (External)
In reply to this post by Kyle Shannon

Hello,

 

I develop an application using Gdal dlls (to read grib file and  DTED and VMAP shape…).

This application is developed with Visual Studio 2008 in C# .NET 3.5.

I want to port this appli in a linux CentOS 5.5  but I have an error when I execute this .exe with “mono”.

I have just deplace  my bin directory. Normally, it works for another application.

But the error concern Gdal Dll (ogr…).

 

Do you have an idea to solve my problem? Maybe replace gdal Windows Dll by gdal Linux So ? but which ones ?

 

Best regards

 

Pascal


_______________________________________________
gdal-dev mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/gdal-dev