[gdal-dev] ENVI Header information from GeoTIFF file

nguler at jlab.org nguler at jlab.org
Wed Jan 13 15:22:33 PST 2016


Dear GDAL users,

I am just starting to use GDAL and apparently I don't quite understand many
classes. My purpose is to extract some map information from GeoTIFF files
(LANDSAT data). I need to access this information to generate an ENVI file
header. When i import the tiff file, I can see the following information is
already in the file:

---- Map Info Properties ----
Type = Projected
Pixel Tie Point X = 0.5
Pixel Tie Point Y = 0.5
Map Tie Point X = 145200.0
Map Tie Point Y = 2189700.0
Pixel Size X = 30.0
Pixel Size Y = 30.0
Units = Meters
Rotation = 0.0

---- Extents Properties ----
Extent Left = 145185.0
Extent Top = 2189715.0
Extent Right = 372315.0
Extent Bottom = 1967385.0
Units = Meters

Coordinate System String =
PROJCS["UTM_Zone_19N",GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137.0,298.257223563]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]],PROJECTION["Transverse_Mercator"],PARAMETER["False_Easting",500000.0],PARAMETER["False_Northing",0.0],PARAMETER["Central_Meridian",-69.0],PARAMETER["Scale_Factor",0.9996],PARAMETER["Latitude_Of_Origin",0.0],UNIT["Meter",1.0]]


I am able to get the coordinate system properties by using the following
commands but I first need to set few things to use exportToWTK.

      OGRSpatialReference oSRS;
      char *pszWKT = NULL;
      oSRS.SetProjCS("UTM_Zone_19N");
      oSRS.SetWellKnownGeogCS("WGS84");
      oSRS.SetUTM(19, TRUE);
      oSRS.SetWellKnownGeogCS("WGS84");
      oSRS.exportToWkt(&pszWKT);
      printf("%s\n", pszWKT);

Is there any way of getting the information without setting anything. After
all, when I import the tiff file into ENVI, ENVI knows all these things so it
should be in the file. But. i don't know this information before i read the
file like SetProjCS, SetWellKnownGeogCS, SetUTM values are unknown but they
are in the file.

I can get some of the map info (Map Tie Point and Pixel Size) from
GetGeoTransform member. How can I get the other map info as shown above (Pixel
Tie Point), Rotation etc.. and the "Extents Properties".

Is there any way to get individual fields in the "Coordinate System String",
like I could extract the UNIT information from there to use in the map info. I
am trying to avoid string manipulation since I am not sure how the string
structure changes from file to file.

Thank you for your help.
Best regards,
- Nevzat




More information about the gdal-dev mailing list