<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div><div><div>On Mar 25, 2010, at 3:49 PM, Frank Warmerdam wrote:</div><blockquote type="cite"><div>Nathan Vander Wilt wrote:<br><blockquote type="cite">I used gdal_merge to combine four tiles into a perfectly square image.<br></blockquote><blockquote type="cite">However, the resulting file was double the size on disk than I would expect<br></blockquote><blockquote type="cite">based on its dimensions and bit depth. I opened it in a hex editor, and<br></blockquote><blockquote type="cite">there is a huge pattern of data that repeats 0x00003075 followed by a ton of<br></blockquote><blockquote type="cite">zeroes.<br></blockquote><blockquote type="cite">Why is gdal_merge writing all this extra data? Does it have something to do<br></blockquote><blockquote type="cite">with the "sparse" blocks discussed in this thread? <a href="http://lists.osgeo.org/pipermail/gdal-dev/2008-October/018750.html">http://lists.osgeo.org/pipermail/gdal-dev/2008-October/018750.html</a><br></blockquote><blockquote type="cite">I found how to perhaps compress these blocks with format options<br></blockquote><blockquote type="cite">(<a href="http://gdal.org/frmt_gtiff.html">http://gdal.org/frmt_gtiff.html</a>) and could try that, but that may lead to<br></blockquote><blockquote type="cite">compatibility issues. Why are these blocks in the file at all? Again, the<br></blockquote><blockquote type="cite">merged image is square and is completely covered by the source data.<br></blockquote><br>NateVW,<br><br>There are a variety of reasons the file could be larger than expected.<br><br>1) Is the file compressed? If so, gdal_merge's rewriting of blocks<br>can result in them being moved to the end of the file if the block is<br>larger on the second write.<br><br>2) Is the file tiled? Depending on tile and image size partially used<br>tiles on the right and bottom of an image can result in files being<br>significantly larger than expected.<br><br>A "tiffdump" report on the output file might help deduce what is going on.<br></div></blockquote></div><div><br></div><div><br></div><div>To test something else, I used gdal_retile.py -ps <half_original_width> <half_original_height> to chop a single source GeoTIFF into 4 pieces. I then simply used gdal_merge.py to recombine those four files into a new GeoTIFF. The result looks exactly the same in an image viewer, but the file itself is twice the size it should be. The extra zero cruft doesn't seem to be helping anyone but Seagate.</div><br><div>Here is the information tiffdump reports for the remerged file:</div><div><br></div><div><div>path/to/remerged.tif:</div><div>Magic: 0x4949 <little-endian> Version: 0x2a</div><div>Directory 0: offset 8 (0x8) next 0 (0)</div><div>ImageWidth (256) SHORT (3) 1<10000></div><div>ImageLength (257) SHORT (3) 1<10000></div><div>BitsPerSample (258) SHORT (3) 3<8 8 8></div><div>Compression (259) SHORT (3) 1<1></div><div>Photometric (262) SHORT (3) 1<2></div><div>StripOffsets (273) LONG (4) 10000<281147892 281177892 281207892 281237892 281267892 281297892 281327892 281357892 281387892 281417892 281447892 281477892 281507892 281537892 281567892 281597892 281627892 281657892 281687892 281717892 281747892 281777892 281807892 281837892 ...></div><div>SamplesPerPixel (277) SHORT (3) 1<3></div><div>RowsPerStrip (278) SHORT (3) 1<1></div><div>StripByteCounts (279) LONG (4) 10000<30000 30000 30000 30000 30000 30000 30000 30000 30000 30000 30000 30000 30000 30000 30000 30000 30000 30000 30000 30000 30000 30000 30000 30000 ...></div><div>PlanarConfig (284) SHORT (3) 1<1></div><div>SampleFormat (339) SHORT (3) 3<1 1 1></div><div>33550 (0x830e) DOUBLE (12) 3<0.15 0.15 0></div><div>33922 (0x8482) DOUBLE (12) 6<0 0 0 553500 4.83e+06 0></div><div>34735 (0x87af) SHORT (3) 32<1 1 0 7 1024 0 1 1 1025 0 1 1 1026 34737 22 0 2049 34737 7 22 2054 0 1 9102 ...></div><div>34737 (0x87b1) ASCII (2) 30<WGS 84 / UTM zone 11N|WG ...></div><div><br></div><div>The original file has the following info:</div><div><br></div><div><div>path/to/original.tif:</div><div>Magic: 0x4949 <little-endian> Version: 0x2a</div><div>Directory 0: offset 300000008 (0x11e1a308) next 0 (0)</div><div>ImageWidth (256) SHORT (3) 1<10000></div><div>ImageLength (257) SHORT (3) 1<10000></div><div>BitsPerSample (258) SHORT (3) 3<8 8 8></div><div>Compression (259) SHORT (3) 1<1></div><div>Photometric (262) SHORT (3) 1<2></div><div>StripOffsets (273) LONG (4) 10000<8 30008 60008 90008 120008 150008 180008 210008 240008 270008 300008 330008 360008 390008 420008 450008 480008 510008 540008 570008 600008 630008 660008 690008 ...></div><div>Orientation (274) SHORT (3) 1<1></div><div>SamplesPerPixel (277) SHORT (3) 1<3></div><div>RowsPerStrip (278) SHORT (3) 1<1></div><div>StripByteCounts (279) LONG (4) 10000<30000 30000 30000 30000 30000 30000 30000 30000 30000 30000 30000 30000 30000 30000 30000 30000 30000 30000 30000 30000 30000 30000 30000 30000 ...></div><div>PlanarConfig (284) SHORT (3) 1<1></div><div>33550 (0x830e) DOUBLE (12) 3<0.15 0.15 1></div><div>33922 (0x8482) DOUBLE (12) 6<0 0 0 553500 4.83e+06 0></div><div>34735 (0x87af) SHORT (3) 28<1 1 0 6 1024 0 1 1 1025 0 1 1 2048 0 1 4326 2054 0 1 9102 3072 0 1 32611 ...></div></div></div><div><br></div><div>thanks,</div><div>-natevw</div><div><a href="http://calftrail.com">http://calftrail.com</a></div></div></body></html>