1

I have to calculate upfront from an polygon, how big the GeoTIFF is going to be in bytes. I have a fixed pixel size and know how many pixels there are going to be in the GeoTIFF. The GeoTIFF has only one band.

How is the relation between amount of pixels and file's size in GeoTIFFs?

1
  • With compression, it's difficult to accurately predict TIFF size
    – Vince
    Feb 6, 2020 at 18:13

1 Answer 1

5

Uncompressed file size in bytes =

bands * rows * cols * bit depth / 8 (+ a small amount for any geotiff/tiff header data)

Note - number of pixels = rows * cols

For example a single band 256 * 512 16bit integer Geotiff would be (1256512*16)/8 = 262,144 bytes with no header.

I just created a couple that were 262,546 bytes (no georeferencing) and 262,766 bytes (with georeferencing).

However, as Vince says, with compression, it's difficult to accurately predict TIFF size. For example, I created a Geotiff with the above dimensions, lots of random values and compression and the output was larger (351,610 bytes) than if I hadn't compressed it. Alternatively, a Geotiff with the same dimensions, but just a single value compresses very well (7,238 bytes)

5
  • ok thx. so gdal e.g. gives out geotiffs always compressed? means, is compressed the standard way that programmes are saving geotiffs?
    – Leo
    Feb 7, 2020 at 7:56
  • 2
    No. GDAL by default produces uncompressed output. gis.stackexchange.com/q/1104/2856
    – user2856
    Feb 7, 2020 at 8:02
  • cool, than this is the answer I was looking for
    – Leo
    Feb 7, 2020 at 8:55
  • 1
    but you should nearly always turn compression on for real world data sets
    – Ian Turton
    Feb 7, 2020 at 9:45
  • And calculate overviews which will add ~1/3 of size. Apr 14, 2023 at 7:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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