[GIS] How to force 1-bit raster output in ArcGIS 10.1 for Desktop

arcgis-10.1arcgis-desktopbit depthraster

Any ideas on how to force a 1bit raster output in ArcGIS 10.1? By default, ArcGIS is being very dense about recognizing pixel depth. I have a binary raster [0,1] and a mask raster [1] and they are being written as 32bit. Because of this they are ~10GB rather than ~32MB.

The raster dimensions are row=51836, col=53276 at 30m. I am outputting an "img" format. I tried writing into a filegeodatabase and it outputs 8bit. However, when I try to convert the filegeodatabase raster into a img format it produces a garbage raster (scrambled pixels representing only part of the image). In the arguments for the "convert raster to different format" (ArcCatalog context menu), I am specifying 1 bit and removing the default NoData value or setting it to a 0 background value. The resulting rasters are either still 32bit or garbage.

When originally creating the rasters, I am wrapping my raster calculator statement in Int() but am still getting 32bit, which should not be possible. I could imagine 8bit output, but 32bit is nonsensical for integer and is normally assigned to floating point. I do have my geoprocessing environment defined and am working in an Albers projection.

Best Answer

I just did some basic tests, converting a raster to a binary mask by performing a Con, which created an 8-bit output. From there, I could use Copy Raster to convert the output to a 1-bit raster:

arcpy.CopyRaster_management("in_raster", "C:/workspace/foo.img", "", "", "", "", "", "1_BIT")

I confirmed that ArcGIS and GDAL both see this as a 1-bit raster. For other formats, 1-bit output may not be possible, the limitations for each format are listed on the supported raster formats page.

If you are really pushing for the smallest possible files, there are even some other tricks you can use:

  • If you can, you'll be better off using GeoTIFF, which supports more settings, and will produce files ~30% smaller than the equivalent Erdas Image file.
  • Disable Pyramids, with:

    arcpy.env.pyramid = "0"
    
  • Make sure that you're using an appropriate compression setting arcpy.env.compression for the output raster. LZW is a good default, but if you are working with 1-bit rasters, you can push things even further with the CCITT family of compression algorithms, originally designed for Fax machines. You can set this with:

    arcpy.env.compression = "CCITT_1D"
    

The two environment settings I mentioned here can also be added to the environment of the geoprocessing tools, under "Environment > Raster Storage".

If none of this works for you, would you be able to share a piece of your data for us to test against?

Related Question