Hello Mark.
Here’s an excerpt from the top-level CreateNew, which in turn calls the tkGridRaster.CreateNew. As you can see, it extracts the values from the Header prior to calling tkGridRaster.CreateNew. From that point on, the Header is not involved in the process.
if (_trgrid->CanCreate(newFileType))
{
double dx;
Header->get_dX(&dx);
double dy;
Header->get_dY(&dy);
VARIANT ndv;
VariantInit(&ndv);
Header->get_NodataValue(&ndv);
double dndv;
dVal(ndv,dndv);
CComBSTR projection;
Header->get_Projection(&projection);
long ncols;
Header->get_NumberCols(&ncols);
long nrows;
Header->get_NumberRows(&nrows);
double xllcenter;
Header->get_XllCenter(&xllcenter);
double yllcenter;
Header->get_YllCenter(&yllcenter);
CComBSTR cTbl;
Header->get_ColorTable(&cTbl);
_trgrid->BSTR2ColorTable(cTbl);
bool result = _trgrid->CreateNew(W2A(Filename), newFileType, dx, dy, xllcenter, yllcenter,
dndv, OLE2A(projection), ncols, nrows, DataType, boolInRam, value, true);
if (result)
{
_filename = OLE2W(Filename);
*retval = VARIANT_TRUE;
}
else
{
delete _trgrid;
_trgrid = NULL;
}
}
else
{
CallbackHelper::ErrorMsg("Grid.CreateNew: writing to this format is not allowed.");
return S_OK;
}
Inside the tkGridRaster class, it uses GDAL as follows, passing in the rows and columns, with no reference to the Header.
poDriver = GetGDALDriverManager()->GetDriverByName(pszFormat);
. . .
_rasterDataset = poDriver->Create( Utility::ConvertToUtf8(filename), ncols, nrows, 1, _genericType, papszOptions );
So when you ask about re-writing the Header, I’m not sure if the Header is even a GDAL construct, but instead a higher-level MapWinGIS construct. From what I can tell, if you modify the Header properties after creation of the Grid, it will have no impact because it is no longer referenced.
That’s at least what I know (think I know) at the moment.
Regards,
Jerry.