Skip to content

Instantly share code, notes, and snippets.

@kapadia
Created June 2, 2014 17:41
Show Gist options
  • Save kapadia/3704e4c301668ff9c931 to your computer and use it in GitHub Desktop.
Save kapadia/3704e4c301668ff9c931 to your computer and use it in GitHub Desktop.
import os
import sys
import pdb
import numpy as np
import rasterio as rio
def check_rio(fpath):
with rio.drivers():
with rio.open(fpath, "r") as src:
r, g, b = map(src.read_band, (1, 2, 3))
metadata = src.meta
metadata.update(count=3)
with rio.drivers():
with rio.open("result.tif", "w", **metadata) as dst:
dst.write_band(1, r)
dst.write_band(2, g)
dst.write_band(3, b)
if __name__ == '__main__':
if len(sys.argv) != 2:
print "Usage: python check_rio.py some-image.tif"
sys.exit()
check_rio(sys.argv[1])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment