[gdal-dev] netCDF metadata writing problem

Florian Mueller icephase26 at gmail.com
Fri Apr 1 10:00:12 EDT 2011


Hi all,

I have a GTiff with 2 Bands and want to copy it into a netCDF with 2
subsets using the C-API. Copying it works without any problem, but I
cannot change the names of the subsets in the metadata of the subsets.
I tried it by using GDALSetMetadata(hout2 ,test, "SUBDATASETS"), which
has no effect (return value is 0). With GDALGetMetadata( hout2,
"SUBDATASETS" ) I can read the metadata information without any
problem. Also GDALSetMetadata( hout2 ,test, "" ) allows me to write
into the metadata of the netCDF file, but how can I change (write)
metadata of the subdata sets?

Here are parts of my code:

char **test;

hDriver2 = GDALGetDriverByName ("netCDF");
if ((hout2 = GDALCreateCopy( hDriver2, ofilename, hout, TRUE,NULL,
NULL, NULL )) == NULL)
{
                printf("Cannot create output file <%s>\n",ofilename);
}

test = GDALGetMetadata( hout2, "SUBDATASETS" );                 //
returns the metadata of the subdatasets
sprintf( test[0], "SUBDATASET_1_NAME=TEST" );
GDALSetMetadata( hout2 ,test, "SUBDATASETS" );         // no effect

Any idea how to write metadata to the subdata sets using the netCDF driver?

Best regards,
Florian


More information about the gdal-dev mailing list