Skip to content

Instantly share code, notes, and snippets.

@sgillies
Forked from kapadia/check_rio.py
Created June 9, 2014 20:48
Show Gist options
  • Save sgillies/5a41833861181ab548cb to your computer and use it in GitHub Desktop.
Save sgillies/5a41833861181ab548cb 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