[Gdal-dev] Is it possible to just copy the new data without affecting the header ?

Frank Warmerdam warmerdam at pobox.com
Fri Mar 7 15:50:42 EST 2003


Anand Madhavan wrote:
> Hi Mr. Warmerdam,
> 
>    Thanks for your reply to my question regarding copying all the header
> information of a hfa file. Basically, I have a source .img file and another
> source .pgm file ( both of same dimensions! ). I need to create a new output
> .img file which has the header information of the source .img file and the
> data of the .pgm file. I guess the best bet is to just make a copy of the
> souce .img file, and copy the data into it from the .pgm file. But, is it
> possible to just copy the imagery data from a .pgm to .img file without
> affecting the header inside the already existing band of the .img? ( eg.
> georeferencing, etc...).(Assuming the width and height are the same) If so,
> kindly guide me. Thanks!

Anand,

With limitations this is possible. There is no pre-written application that
does it, but it can be scripted fairly easily in Python.  The caveat is that
all the .img tiles have to be uncompressed otherwise they cannot be written
over.

I would suggest you review how imagery is copied from file to file in the
gdal_merge.py script.  You should be able to use something like what is
done in the raster_copy() function plus a bit of stuff to open the files.

Good luck,

-- 
---------------------------------------+--------------------------------------
I set the clouds in motion - turn up   | Frank Warmerdam, warmerdam at pobox.com
light and sound - activate the windows | http://pobox.com/~warmerdam
and watch the world go round - Rush    | Geospatial Programmer for Rent





More information about the Gdal-dev mailing list