Thanks for the reply, that's what I was looking for! Derek ________________________________________ From: [email protected] [[email protected]] on behalf of Frank Warmerdam [[email protected]] Sent: Friday, July 15, 2011 10:22 PM To: Cole, Derek Cc: [email protected] Subject: Re: [gdal-dev] Writing data to "CreateCopy" files
On Fri, Jul 15, 2011 at 3:57 PM, Cole, Derek <[email protected]> wrote: > I have a couple of questions regarding this. > > Is the dataset that is returned from CreateCopy able to be used immediately? > I would like to use it to get the first band from it, and use RasterIO on > that band. Derek, Yes, you should be able to read the resulting file with the returned GDALDataset object immediately. Whether you can write to the resulting file will depend on the format. Some formats are readonly (with CreateCopy being the only way to accomplishing writing). > Secondly - the data I am trying to write with RasterIO is unsigned char, but > when I was reading the data, I had to read it with a GDT_Float32, which was > allocated like so: > > float * floatData = (float *) > CPLMalloc(sizeof(float)*bufSizeX*bufSizeY); > > and that seemed to be working well. Will my copy have to be written via a > GDT_Float32 data buffer like the one I read it into initially, or can I just > change the RasterIO parameter on the write to be GDT_Byte? You can read into a float buffer and write back out using an unsigned char buffer as long as you use the appropriate data type (GDT_Byte or GDT_Float32) in the RasterIO call. RasterIO wlil take care of on the fly conversion of the data. Be aware that writing a float buffer to a Byte file will not cause the file on disk to be upgraded to store floating point values. Instead RasterIO will convert the floating point values to unsigned char. When down converting types out of range values are clamped to the max and min of the target type and otherwise a floor() convertion is applied when going to integer types. Best regards, -- ---------------------------------------+-------------------------------------- I set the clouds in motion - turn up | Frank Warmerdam, [email protected] light and sound - activate the windows | http://pobox.com/~warmerdam and watch the world go round - Rush | Geospatial Software Developer _______________________________________________ gdal-dev mailing list [email protected] http://lists.osgeo.org/mailman/listinfo/gdal-dev
