Oops. This would have to be made a non-member function so a different driver could be specified.
THK On Sat, Aug 21, 2010 at 7:24 PM, Tim Keitt <tke...@gmail.com> wrote: > How about: > > /************************************************************************/ > /* ShallowCopy() */ > /************************************************************************/ > > GDALDataset *GDALDriver::ShallowCopy( const char * pszFilename, > GDALDataset * poSrcDS, > GDALDataType etype, int nBands, > int bStrict, char ** papszOptions, > GDALProgressFunc pfnProgress ) > > { > if( pfnProgress == NULL ) > pfnProgress = GDALDummyProgress; > > /* -------------------------------------------------------------------- */ > /* Create destination dataset. */ > /* -------------------------------------------------------------------- */ > GDALDataset *poDstDS; > int nXSize = poSrcDS->GetRasterXSize(); > int nYSize = poSrcDS->GetRasterYSize(); > CPLErr eErr; > > CPLDebug( "GDAL", "Using default GDALDriver::CreateCopy implementation." ); > > if( !pfnProgress( 0.0, NULL, pProgressData ) ) > { > CPLError( CE_Failure, CPLE_UserInterrupt, "User terminated" ); > return NULL; > } > > poDstDS = Create( pszFilename, nXSize, nYSize, nBands, eType, > papszOptions ); > > if( poDstDS == NULL ) > return NULL; > > /* -------------------------------------------------------------------- */ > /* Try setting the projection and geotransform if it seems */ > /* suitable. For now we don't try and copy GCPs, though I */ > /* suppose we should. Also copy metadata. */ > /* -------------------------------------------------------------------- */ > double adfGeoTransform[6]; > > if( poSrcDS->GetGeoTransform( adfGeoTransform ) == CE_None > && (adfGeoTransform[0] != 0.0 > || adfGeoTransform[1] != 1.0 > || adfGeoTransform[2] != 0.0 > || adfGeoTransform[3] != 0.0 > || adfGeoTransform[4] != 0.0 > || adfGeoTransform[5] != 1.0) ) > { > poDstDS->SetGeoTransform( adfGeoTransform ); > } > > if( poSrcDS->GetProjectionRef() != NULL > && strlen(poSrcDS->GetProjectionRef()) > 0 ) > { > poDstDS->SetProjection( poSrcDS->GetProjectionRef() ); > } > > poDstDS->SetMetadata( poSrcDS->GetMetadata() ); > > return poDstDS; > } > > > On Sat, Aug 21, 2010 at 7:14 PM, Tim Keitt <tke...@gmail.com> wrote: >> OK. I found the source. Yes, that is fairly straightforward to copy and >> modify. >> >> It seems making a copy without propagating the raster bands would be >> very common operation. Would it make sense to introduce a new function >> to GDAL? ShallowCopy? >> >> THK >> >> On Sat, Aug 21, 2010 at 7:05 PM, Tim Keitt <tke...@gmail.com> wrote: >>> I noticed DefaultCreateCopy, but appears not to be documented. At >>> least there is no click through link in the class reference. What does >>> it do? How is it modified? In the driver code? >>> >>> THK >>> >>> On Sat, Aug 21, 2010 at 7:00 PM, Chaitanya kumar CH >>> <chaitanya...@gmail.com> wrote: >>>> Tim, >>>> >>>> You can create it easily by modifying GDALDriver::DefaultCreateCopy() >>>> >>>> On Sat, Aug 21, 2010 at 9:51 PM, Tim Keitt <tke...@gmail.com> wrote: >>>>> >>>>> I am writing a utility that takes a raster as input and outputs a >>>>> raster with all attributes the same, except that I only want one >>>>> output band and I want to specify its type independent of the data >>>>> type in the input file. Is there a function that creates a copy of a >>>>> dataset (or creates a virtual dataset), but does not copy any raster >>>>> bands? This would really simplify things as all I would have to do is >>>>> add a band to the output dataset of the desired type. >>>>> >>>>> THK >>>>> >>>>> -- >>>>> Timothy H. Keitt >>>>> http://www.keittlab.org/ >>>>> _______________________________________________ >>>>> gdal-dev mailing list >>>>> gdal-dev@lists.osgeo.org >>>>> http://lists.osgeo.org/mailman/listinfo/gdal-dev >>>> >>>> >>>> >>>> -- >>>> Best regards, >>>> Chaitanya kumar CH. >>>> /tʃaɪθənjə/ /kʊmɑr/ >>>> +91-9494447584 >>>> 17.2416N 80.1426E >>>> >>> >>> >>> >>> -- >>> Timothy H. Keitt >>> http://www.keittlab.org/ >>> >> >> >> >> -- >> Timothy H. Keitt >> http://www.keittlab.org/ >> > > > > -- > Timothy H. Keitt > http://www.keittlab.org/ > -- Timothy H. Keitt http://www.keittlab.org/ _______________________________________________ gdal-dev mailing list gdal-dev@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/gdal-dev