2

I am trying to make a code to read and retrieve geographical and raster data from a geotiff file, but I'm having a hard time with the extended tags. I have no problem with the regular TIFF tags (like IMAGEWIDTH, using tiffgetfield()) or the geokeys (like ProjectedCSTypeGeoKey, using GTIFKeyGet() or taking it from the definition struct), but what's giving me problem are the extended tags provided by geotiff library.

I can see the information I need (pixel scale and tie point tags) using GTIFPrint(), but I don't know how to access the metadata file, and haven't been able to get the data I want using TIFFGetField() since I can't call the function properly.

This is how I was calling TIFFGetField

double* pixscl;
int* pixscalesize;

TIFFGetField(tif, GTIFF_TIEPOINTS, &pixscalesize);
printf("Model Pixel Scale Tag is:\n      %d\n", pixscalesize);

What I'm getting here is the number of elements in the tag, which is 3 for pixel scale, and 6 for tie point, but still have no access to the actual values.

Any ideas on how I can store the values of these tags to print or use in another function?

PS: I am using only libgeotiff, GDAL is out of discussion because all of its components, and I'm aiming to a light weight and simple application.

1

After two days of trying to answer this precise question, I finally found the solution of GTIFImageToPCS(). TIFFGetField() is not intended to do this, and GTIFKeyGet() only works on single-field keys.

  • Hi Denton, thanks for your answer. I think you might be confused because GTIFImageToPCS() is used to convert coordinates, not to handle keys/tags – FelipeBrubeck May 22 '18 at 16:12
  • It extracts and converts some of the relevant tags and gives you access at least to the ModelTiepointTags. The basic problem is that any of the TIFF key handling was only designed to deal with individual keys. Initially the GeoTIFF designers stuck to that, but at some point, they added tags with multiple values. GTIFImageToPCS allowed me to solve at least part of this. To be honest, I didn't try to get PixScaleSize, so I overstated what I could do. Initially, I wrote a very cautious reply which was deleted right away, so then I got frustrated, since I think your basic problem is the same. – A.M. Denton May 23 '18 at 19:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.