Enabling tif compression

May 5, 2015 at 3:57 PM
Hello all,

I'm working on an application that creates a bunch of gis output and it would be quite helpful to enable tif compression to reduce file sizes.

From the API documentation it looks like there is support but I can't find any examples of it in use.

So far I tried adding the following lines (vb.net) to my main form load sub routine:

Dim gs As New MapWinGIS.GlobalSettings
gs.TiffCompression = MapWinGIS.tkTiffCompression.tkmLZW

But this didn't seem to change the file output size. Using LZW compression in Arcmap reduces the size from 660mb to 9mb.

Many thanks for sharing your package,
Colin
Developer
May 5, 2015 at 4:01 PM
Hi Colin,

exactly which methods do you use to produce output? We have TiffCompression global setting indeed. But perhaps it's not used everywhere throughout the code.

Regards,
Sergei
May 5, 2015 at 4:05 PM
Basically I'm doing something like this...


Dim outputGrid As New MapWinGIS.Grid
Dim outputFile as String = "c:\temp\test.tif"

outputGrid.PutFloatWindow(0, 5000, 0, 500, outputpixels(0))

outputGrid.CreateNew(outputFile, header, MapWinGIS.GridDataType.ByteDataType, 0)

outputGrid.AssignNewProjection("+proj=utm +zone=11 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs ")
outputGrid.Save()
outputGrid.Close()
May 5, 2015 at 4:10 PM
Using gdal in python I would specify the following arguments in the driver.Create function call:

create_args = ['COMPRESS=LZW', 'PREDICTOR=2', 'TILED=Yes',
               'BLOCKXSIZE=128', 'BLOCKYSIZE=128']
I'm not sure how to pass the equivalent through mapwingis.


btw I'm on 4.9.0 32bit
May 5, 2015 at 4:12 PM
oops, PutFloatWindow would come after outputGrid.CreateNew!
Developer
May 5, 2015 at 4:45 PM
No, the setting wasn't used. I've committed a quick fix. We are preparing v4.9.3.5 now, so it's likely that this fix will be released within a few days. It would be good to allow to pass other creation options from MapWinGIS API. But maybe a bit later, in v4.9.4. I'm working on exposing more of the GDAL API in dev494 branch.