[Gdal-dev] saving GeoTiff
Frank Warmerdam
warmerdam at pobox.com
Tue Mar 11 08:29:07 EST 2003
Ayman Kamal wrote:
> I want to be able to convert a "bmp" file to a
> "GeoTiff" file.
>
> I used gdal_translate to do this, but the resulting
> file didn't of course contain georeferencing data.
>
> Now:
> 1. Is it possible (if I find the goereferencing data)
> to give them to GDAL SDK so that GDAL can generate a
> GeoTiff file with georeferencing data embeded inside?
>
> if (1.)
> {
> 2. What data do I need to supply to GDAL to
> accomplish this?
>
> 3. What functions to use in GDAL to save such data
> in thre resulting GeoTiff file?
> }
> else
> {
> 4. Can you help me in any means to accomoplish
> this?
> }
Ayman,
You need to call GDALSetGeoTransform() with the appropriate affine geotransform.
Please ensure you are using a fairly recent GDAL (like a CVS snapshot not less
than 3 weeks old as there were some bugs in GeoTIFF update-in-place in 1.1.8).
The following is a fairly minimal example. If you want to write the coordinate
system also use the GDALSetProjection() method.
#include "gdal.h"
int main()
{
GDALDatasetH hDS;
double adfGeoTransform[6];
GDALAllRegister();
hDS = GDALOpen( "work.tif", GA_Update );
adfGeoTransform[0] = 1000; /* top left x */
adfGeoTransform[1] = 2.0; /* horizontal pixel size */
adfGeoTransform[2] = 0.0;
adfGeoTransform[3] = 6120; /* top left y */
adfGeoTransform[4] = 0.0;
adfGeoTransform[5] = -2.0; /* vertical pixel size */
GDALSetGeoTransform( hDS, adfGeoTransform );
GDALClose( hDS );
}
Best regards,
--
---------------------------------------+--------------------------------------
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