Created
January 12, 2017 19:34
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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