[gdal-dev] Creating modified copies of a file
Cole, Derek
dcole at integrity-apps.com
Tue Jul 5 18:26:06 EDT 2011
Just as an interesting side-note: I tried to do a CreateCopy on one of these files that was 7GB. Using CreateCopy() it took almost 2 hours. When I simply copied to file contents using a cp command (this is CentOS), the copy takes about a minute. I am not sure why that is so terribly slow in GDAL.
Also, I experimented trying to insert a band into an already existing NITF file, but the software spits back an error message that the format does not support it. It seems maybe I am stuck doing like Even's last email, which requires building out all the Meta, projection, transform data all into the file manually. Bummer.
Derek
________________________________________
From: Even Rouault [even.rouault at mines-paris.org]
Sent: Tuesday, July 05, 2011 2:09 PM
To: gdal-dev at lists.osgeo.org
Cc: Cole, Derek; Chaitanya kumar CH
Subject: Re: [gdal-dev] Creating modified copies of a file
Le mardi 05 juillet 2011 19:55:21, Cole, Derek a écrit :
> Right, I can do this for my already opened and read-from data set. However,
> I want to have a separate file. This means I have to copy that original
> data set, right? I can't seem to figure out how to copy a data set without
> actually copying the raster data (which is huge in comparison to the
> meta). Are you suggesting I just add another band to the already opened
> file? Not entirely sure I like this approach, but it may be doable.
Well, you should study closely the GDAL API, but the general plot is :
hInDS = GDALOpen(...)
hOutDS = GDALCreate(...)
GDALSetProjection(hOutDS, GDALGetProjectionRef(hInDS)) /* copy projection info
from source dataset */
GDALGetGeoTransform(hInDS, ...)
GDALSetGeoTransform(hOutDS, ...) /* copy geotransform info from source
dataset*/
GDALRasterIO(GF_Write, ....) /* write imagery */
GDALClose(hOutDS)
>
> Derek
> ________________________________
> From: Chaitanya kumar CH [chaitanya.ch at gmail.com]
> Sent: Tuesday, July 05, 2011 1:35 PM
> To: Cole, Derek
> Cc: gdal-dev at lists.osgeo.org
> Subject: Re: [gdal-dev] Creating modified copies of a file
>
> Derek,
>
> Writing into a raster band is a lot like reading into it. Use the function
> you use to read the pixels to write the pixels back. Don't forget to close
> the dataset at the end using GDALClose() [1]. Also, check out the
> GDALFlushCache() and similar functions in [2].
>
> [1]: http://www.gdal.org/gdal_8h.html#0984222d45a72028fcbbf1f44831ffbc
> [2]: http://www.gdal.org/gdal_8h.html
>
> On Tue, Jul 5, 2011 at 9:16 PM, Cole, Derek
> <dcole at integrity-apps.com<mailto:dcole at integrity-apps.com>> wrote: Hello,
>
> I think I started to ask about this before on this forum, but I have since
> used GDAL a bit more and might be better to generate a new thread.
>
> I have been using GDAL to read in NITF files, getting the RasterBand data,
> and manipulating it, and displaying the results in my viewer.
>
> Now, I would like to be able process data, then save it into a new NITF.
> This new NITF will have the same geocoords and all of the same data as the
> original, with the exception of a new raster band replacing the original.
> Is there a way to create a clone of the original image WITHOUT copying the
> data? I do not want to have to replicate the old data on disk, only the
> overwrite it with my new data that is coming from the external processing.
> I looked into creating the virtual data sets, but I am not sure if that is
> my answer. If I just pass in an empty "" as the destination, it says it
> will create that dataset in memory. Is this what I want to do?
>
> My algorithm processes only a portion of the image at a time, so what I
> envisioned in my head was being able to essentially write out header /meta
> information in a file, and "append" blocks of raster data into the right
> place in the file, as they complete processing. This way there is no
> single lag-point while waiting to create a copy of data on disk to another
> place on disk, or having to create a large file on disk all at once. These
> image files are 1GB+
>
> Any tips for trying to set up this scenario?
>
> Thanks
>
> Derek
>
> _______________________________________________
> gdal-dev mailing list
> gdal-dev at lists.osgeo.org<mailto:gdal-dev at 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
More information about the gdal-dev
mailing list