Last active
August 29, 2015 14:03
-
-
Save kapadia/0f81ea84bc176aef4516 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 sys | |
import numpy as np | |
import rasterio as rio | |
def copy(srcpath, dstpath): | |
with rio.drivers(): | |
with rio.open(srcpath, 'r') as src: | |
metadata = src.meta | |
r, g, b = map(src.read_band, (1, 2, 3)) | |
metadata.update(count=3) | |
with rio.open(dstpath, 'w', **metadata) as dst: | |
dst.transform = metadata["affine"] | |
dst.crs = metadata["crs"] | |
dst.write_band(1, r) | |
dst.write_band(2, g) | |
dst.write_band(3, b) | |
if __name__ == '__main__': | |
if len(sys.argv) != 3: | |
sys.exit() | |
copy(*sys.argv[1:3]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
gdalinfo before
gdalinfo after