[gdal-dev] Metadata from GeoTIFF to ENVI

Even Rouault even.rouault at spatialys.com
Fri Jan 1 12:58:36 PST 2016


Le vendredi 01 janvier 2016 21:17:09, Nevzat Guler a écrit :
> Thanks Even.
> I changed the line as you suggested but still missing some of the
> information in the header file. The header I get has the following:
> 
> ENVI
> description = {
> createdFile.hsi}
> samples = 7571
> lines   = 7411
> bands   = 1
> header offset = 0
> file type = ENVI Standard
> data type = 12
> interleave = bsq
> byte order = 0
> band names = {
> Band 1}
> AREA OR POINT = Point
> 
> But, I know there are more info in the metadata including map info,
> coordinate systems and extents data etc..

The following metadata items are ignored from the metadata array and must be 
set instead through the appropriate GDAL API, such as SetProjection(), 
SetGeoTransform(), SetDescription(), etc...

        if (poKey == "description" || poKey == "samples" || poKey == "lines" 
||
            poKey == "bands" || poKey == "header offset" || poKey == "file type" 
||
            poKey == "data type" || poKey == "interleave" || poKey == "byte 
order" ||
            poKey == "class names" || poKey == "band names" || poKey == "map 
info" ||
            poKey == "projection info")

See ENVIDataset::FlushCache() in 
https://svn.osgeo.org/gdal/trunk/gdal/frmts/raw/envidataset.cpp

> 
> How do I access to the metadata, meaning, how do I learn what kind of
> information exists in the papszMetadataSet variable? If I knew that I
> could try to write the header file myself. I am sorry if this is explained
> in somewhere but I could not find any example on how to access to
> metadata.

papszMetadataSet is a "Pointer to an Array of Pointers to String Zero-
terminated" (papsz), the array itself being terminated by a NULL pointer

for( char** papszIter = papszMetadataSet; *papszIter != NULL; papszIter++ )
	printf("%s\n", *papszIter);

> 
> Best regards ,
> - Nevzat
> 
> -----Original Message-----
> From: Even Rouault [mailto:even.rouault at spatialys.com]
> Sent: Friday, January 01, 2016 5:03 AM
> To: gdal-dev at lists.osgeo.org
> Cc: nguler at jlab.org
> Subject: Re: [gdal-dev] Metadata from GeoTIFF to ENVI
> 
> Le jeudi 31 décembre 2015 23:31:40, nguler at jlab.org a écrit :
> > Dear GDAL Users,
> > 
> > I am reading a GeoTIFF file and creating an ENVI file. I don't want to
> > use the CreateCopy method but the Create method.
> > 
> > I tried something like the following to transfer the metadata:
> >    char **papszMetadataSet;
> >    papszMetadataSet = poDataset->GetMetadata();
> >    poDstDS->SetMetadata(papszMetadataSet);
> > 
> > But, it did not work. I am pretty new to GDAL and I would greatly
> > appreciate an example on how to transfer Metadata while creating an
> > ENVI type file. I would like to learn how to transfer the whole
> > metadata and also selected part of it.
> 
> Nevzat,
> 
> According to http://www.gdal.org/frmt_various.html#ENVI , "all ENVI header
> fields will be stored in the ENVI metadata domain, and all of these can
> then be written out to the header file". Which means in your case, you
> should motify your last line to be :
> 
> poDstDS->SetMetadata(papszMetadataSet, "ENVI");
> 
> Even
> 
> > Best regards,
> > - Nevzat
> > 
> > 
> > 
> > _______________________________________________
> > gdal-dev mailing list
> > gdal-dev at lists.osgeo.org
> > http://lists.osgeo.org/mailman/listinfo/gdal-dev
> 
> --
> Spatialys - Geospatial professional services http://www.spatialys.com

-- 
Spatialys - Geospatial professional services
http://www.spatialys.com


More information about the gdal-dev mailing list