[Gdal-dev] Export Aux File from GDAL dataset?

Michael S. Rosen mrosen at lizardtech.com
Tue Nov 20 17:39:14 EST 2007


Lennox,

 

If you've got a GDAL dataset of one sort, you should be convert it to an
HFADataset without undue difficulty.  The HFADataset will write out the
.aux file you need.

 

Set up your HFADataset something rather like this, I think:

 

      char **papszOptions = NULL;

      papszOptions = CSLSetNameValue(papszOptions, "AUX", "YES"); //
create aux file only (no raster data)

      int nXSize = pImage->getWidth();

      int nYSize = pImage->getHeight();

      int nBands = pImage->getNumBands();

      GDALDataType eType = GDT_Unknown ; 

      switch (pImage->getDataType())

      {

      case LTI_DATATYPE_UINT8: eType = GDT_Byte;          break; 

      case LTI_DATATYPE_SINT8: eType = GDT_Byte;          break;

...

      }

      GDALDataset *poDstDS;

      poDstDS = poDriver->Create(fsOutput.utf8(), nXSize, nYSize,
nBands, eType,

         papszOptions);

 

      // Add the metadata we choose to support 

      const LTIGeoCoord &geo = pImage->getGeoCoord();

      double xUL, yUL, xRes, yRes, xRot, yRot;

      geo.get(xUL, yUL, xRes, yRes, xRot, yRot);

      double adfGeoTransform[6];

      adfGeoTransform[0] = xUL - 0.5 * xRes; // Upper left corner of
upper left pixel

      adfGeoTransform[1] = xRes;

      adfGeoTransform[2] = xRot;

      adfGeoTransform[3] = yUL - 0.5 * yRes; // Bottom right corner of
bottom right pixel

      adfGeoTransform[4] = yRot;

      adfGeoTransform[5] = yRes;

      CPLErr err = poDstDS->SetGeoTransform(adfGeoTransform);

...

 

      const char *pWkt = geo.getWKT();

      OGRSpatialReference oSRS( pWkt );

      oSRS.exportToWkt(pWkt);

 

      err = poDstDS->SetProjection(pWkt);

...

      // This destruction causes GDAL's driver to flush to disk

      if (poDstDS != NULL)

      {

         delete poDstDS;

      }

 

________________________________

From: gdal-dev-bounces at lists.maptools.org
[mailto:gdal-dev-bounces at lists.maptools.org] On Behalf Of Lennox Antoine
Sent: Tuesday, November 20, 2007 11:56 AM
To: gdal
Subject: [Gdal-dev] Export Aux File from GDAL dataset?

 

Hi All,

A colleague of mines has 1500+ MrSID files with no coordinate system
assigned. They are trying to read this using ERDAS IMAGINE.

I can easily assign the coordinate system in GDAL, however, there is no
way (that I know of) to get IMAGINE to recognize the coordinate system
since it stores auxiliary information in aux files. 

I am wondering if there is a way to export the aux files from the GDAL
dataset, so that when IMAGINE reads it back, it gets the correct
coordinate system?

-Lennox

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/ms-tnef
Size: 11446 bytes
Desc: not available
Url : http://lists.osgeo.org/pipermail/gdal-dev/attachments/20071120/90b7d729/attachment.bin


More information about the gdal-dev mailing list