RE: [gdal-dev] CreateCopy() with same metadata, different raster data
What about using the VRT driver? Is that for the situation I am describing? According to the CreateCopy documentation: It is intended that CreateCopy() will often be used with a source dataset which is a virtual dataset allowing configuration of band types, and other information without actually duplicating raster data (see the VRT driver). This is what is done by the gdal_translate utility for example. And according to the first example of Programatic creation of VRT datasets on http://www.gdal.org/gdal_vrttut.html This looks like it creates clone of everything but the raster data. Can I basically do this when I am loading my image for the first time, then when my outputs are ready, open this, create a copy using the NITF driver, and then write to the bands of the NITF driver using RasterIO? Thanks Derek From: gdal-dev-boun...@lists.osgeo.org [gdal-dev-boun...@lists.osgeo.org] on behalf of Frank Warmerdam [warmer...@pobox.com] Sent: Wednesday, June 15, 2011 10:44 AM To: gdal-dev@lists.osgeo.org Subject: Re: [gdal-dev] CreateCopy() with same metadata, different raster data On 11-06-14 09:18 PM, Cole, Derek wrote: > Hrmm, that is sort of unfortunate. I have set up a tiling algorithm to read > in tiles at a time of imagery data, which is already slow-ish, even doing it > it with threads. Having to do a whole new read of the entire image at once > (since it doesnt seem CreateCopy takes any block parameters) would be pretty > time consuming. > > Am I better off trying to just copy the Dataset manually, creating a new > file from that? Derek, If efficiency is important, and you have a limited amount of metadata you need to copy, I would setup your imagery in memory as a MEM dataset and then programatically copy the parts of the metadata you need to it from the source file. Then do a CreateCopy from that to your final file. You can ee something like that done in C in the MapServer msSaveImageGDAL() function at: http://trac.osgeo.org/mapserver/browser/trunk/mapserver/mapgdal.c#L152 In all this I am assuming your final format is one that only supports CreateCopy() (like JPEG or PNG) otherwise you can just imperatively create the output file and set the info on it after writing the imagery. Best regards, -- ---+-- I set the clouds in motion - turn up | Frank Warmerdam, warmer...@pobox.com light and sound - activate the windows | http://pobox.com/~warmerdam and watch the world go round - Rush| Geospatial Programmer for Rent ___ gdal-dev mailing list gdal-dev@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/gdal-dev ___ gdal-dev mailing list gdal-dev@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/gdal-dev
Re: [gdal-dev] CreateCopy() with same metadata, different raster data
On 11-06-14 09:18 PM, Cole, Derek wrote: Hrmm, that is sort of unfortunate. I have set up a tiling algorithm to read in tiles at a time of imagery data, which is already slow-ish, even doing it it with threads. Having to do a whole new read of the entire image at once (since it doesnt seem CreateCopy takes any block parameters) would be pretty time consuming. Am I better off trying to just copy the Dataset manually, creating a new file from that? Derek, If efficiency is important, and you have a limited amount of metadata you need to copy, I would setup your imagery in memory as a MEM dataset and then programatically copy the parts of the metadata you need to it from the source file. Then do a CreateCopy from that to your final file. You can ee something like that done in C in the MapServer msSaveImageGDAL() function at: http://trac.osgeo.org/mapserver/browser/trunk/mapserver/mapgdal.c#L152 In all this I am assuming your final format is one that only supports CreateCopy() (like JPEG or PNG) otherwise you can just imperatively create the output file and set the info on it after writing the imagery. Best regards, -- ---+-- I set the clouds in motion - turn up | Frank Warmerdam, warmer...@pobox.com light and sound - activate the windows | http://pobox.com/~warmerdam and watch the world go round - Rush| Geospatial Programmer for Rent ___ gdal-dev mailing list gdal-dev@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/gdal-dev
RE: [gdal-dev] CreateCopy() with same metadata, different raster data
Hrmm, that is sort of unfortunate. I have set up a tiling algorithm to read in tiles at a time of imagery data, which is already slow-ish, even doing it it with threads. Having to do a whole new read of the entire image at once (since it doesnt seem CreateCopy takes any block parameters) would be pretty time consuming. Am I better off trying to just copy the Dataset manually, creating a new file from that? Derek From: gdal-dev-boun...@lists.osgeo.org [gdal-dev-boun...@lists.osgeo.org] on behalf of Frank Warmerdam [warmer...@pobox.com] Sent: Tuesday, June 14, 2011 7:23 PM To: gdal-dev@lists.osgeo.org Subject: Re: [gdal-dev] CreateCopy() with same metadata, different raster data On 11-06-14 07:04 PM, Cole, Derek wrote: > Is it possible to use CreateCopy() to easily copy in to a new image modified > raster data based off the old image? I know all the metadata is going to be > the > same, I have simply changed the data after reading it from the original, and > need to store it back to disk. Derek, Well, I wouldn't say it is very easy, but there are a few approaches. One approach would be to use CreateCopy() to copy the imagery, metadata and other information into a memory dataset (using the MEM) driver. Then update the imagery on this MEM dataset according to what you need, and then use CreateCopy() to copy the result to the final file. It is also possible, but complicated, to create a VRT wrapper you can pass to CreateCopy that pulls from your modified image and using the original file for the metadata. Generally for this sort of situation I would just CreateCopy to a geotiff file, update the imagery, and then CreateCopy() from that to the final file. Best regards, -- ---+-- I set the clouds in motion - turn up | Frank Warmerdam, warmer...@pobox.com light and sound - activate the windows | http://pobox.com/~warmerdam and watch the world go round - Rush| Geospatial Programmer for Rent ___ gdal-dev mailing list gdal-dev@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/gdal-dev ___ gdal-dev mailing list gdal-dev@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/gdal-dev
Re: [gdal-dev] CreateCopy() with same metadata, different raster data
On 11-06-14 07:04 PM, Cole, Derek wrote: Is it possible to use CreateCopy() to easily copy in to a new image modified raster data based off the old image? I know all the metadata is going to be the same, I have simply changed the data after reading it from the original, and need to store it back to disk. Derek, Well, I wouldn't say it is very easy, but there are a few approaches. One approach would be to use CreateCopy() to copy the imagery, metadata and other information into a memory dataset (using the MEM) driver. Then update the imagery on this MEM dataset according to what you need, and then use CreateCopy() to copy the result to the final file. It is also possible, but complicated, to create a VRT wrapper you can pass to CreateCopy that pulls from your modified image and using the original file for the metadata. Generally for this sort of situation I would just CreateCopy to a geotiff file, update the imagery, and then CreateCopy() from that to the final file. Best regards, -- ---+-- I set the clouds in motion - turn up | Frank Warmerdam, warmer...@pobox.com light and sound - activate the windows | http://pobox.com/~warmerdam and watch the world go round - Rush| Geospatial Programmer for Rent ___ gdal-dev mailing list gdal-dev@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/gdal-dev