Skip to content

Instantly share code, notes, and snippets.

@mhweber
Created January 12, 2017 19:34
Show Gist options
  • Select an option

  • Save mhweber/de1e929af35a76895e2a18a6113ca2cf to your computer and use it in GitHub Desktop.

Select an option

Save mhweber/de1e929af35a76895e2a18a6113ca2cf to your computer and use it in GitHub Desktop.
Reduce the bit depth of a given raster using georasters package in python
import georasters as gr
def reduce_depth(inras, outras, out_depth, nodata):
infile = gr.from_file(inras)
out= gr.GeoRaster(
infile.raster,
infile.geot,
nodata_value=nodata,
projection=data.projection,
datatype='Byte')
out.to_tiff(outras)
if __name__ == '__main__':
start = dt.now()
inras = 'L:/Priv/CORFiles/Geospatial_Library/Data/Project/StreamCat/LandscapeRasters/QAComplete/WaterMask/Mosaics/RipBuf100_01.tif'
outras = 'c:/users/mweber/temp/bool_test.tif'
reduce_depth(inras, outras, out_depth='Byte', nodata=255)
print dt.now() - start2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment