How to extract location from Strided GeoTIFF raster?

It wasn’t completely random, just a bit.
I saw that Raster(filepath) was available but I didn’t want to bring in the whole GDAL, felt overkill for what I needed to do :slight_smile:

I don’t know the standard, nor the conventions, so I don’t know if this is something that whoever made the file decided or if it can be relied upon, but It would have been awesome, in this case, to have spatial information automatically inferred for all images in the iterator, based on the top level image metadata, and rescaled using the difference in image size.

for example:

julia> GeoTIFF.affineparams2D(GeoTIFF.metadata(nth(geotiffs, 1)))
([0.0002999999999999996 0.0; 0.0 -0.0003000000000000001], [142.0000611111, -10.000138888905807])

julia> GeoTIFF.affineparams2D(GeoTIFF.metadata(nth(geotiffs, 2)))
([1.0 0.0; 0.0 1.0], [0.0, 0.0])

julia> size(nth(geotiffs, 1))
(23333, 16666)

julia> size(nth(geotiffs, 2))
(11667, 8333)

while it could be inferred to be:

modelpixelscale = [0.0006 0.0; 0.0 -0.0006] # rescaled from the size ratio
modeltiepoints = [142.0000611111, -10.000138888905807] #inherited from main image

or something like that.

EDIT: I did a little digging, It is actually possible to know that this is indeed the case using the SUBFILETYPE tag, in the TIFF Spec [0][1]:

A general indication of the kind of data contained in this subfile.

Replaces the old SubfileType field, due to limitations in the definition of that field.

NewSubfileType is mainly useful when there are multiple subfiles in a single TIFF file.

This field is made up of a set of 32 flag bits. Unused bits are expected to be 0. Bit 0 is the low-order bit. Currently defined values are:

Bit 0 is 1 if the image is a reduced-resolution version of another image in this TIFF file; else the bit is 0.
Bit 1 is 1 if the image is a single page of a multi-page image (see the PageNumber field description); else the bit is 0.
Bit 2 is 1 if the image defines a transparency mask for another image in this TIFF file. The PhotometricInterpretation value must be 4, designating a transparency mask.

Which for my file is indeed a chain of IFDs with Tag(SUBFILETYPE, 1)

[0]: Baseline TIFF Tag NewSubfileType (TIFFTAG_SUBFILETYPE), code 254 (0x00FE)
[1]: PDF of TIFF SPEC

1 Like