-
-
Save kapadia/3704e4c301668ff9c931 to your computer and use it in GitHub Desktop.
This file contains 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 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