diff --git a/AUTHORS.txt b/AUTHORS.txt index 10023468..dc4f4b6c 100644 --- a/AUTHORS.txt +++ b/AUTHORS.txt @@ -2,7 +2,7 @@ Authors ======= Sean Gillies -@brendan-ward https://github.com/brendan-ward +Brendan Ward https://github.com/brendan-ward Asger Skovbo Petersen https://github.com/AsgerPetersen James Seppi https://github.com/jseppi Chrisophe Gohlke https://github.com/cgohlke diff --git a/scripts/rio_cp b/scripts/rio_cp index 2e2f92f3..1dd4fed1 100644 --- a/scripts/rio_cp +++ b/scripts/rio_cp @@ -15,7 +15,7 @@ def main(source, destination, opts, template=None, log=None): with rasterio.open(source) as src: # First, copy the opts to the destination's kwargs. - kwargs = src.meta.copy() + kwargs = src.meta kwargs.update(opts) # If there's a template file, overlay its georeferencing. @@ -27,7 +27,7 @@ def main(source, destination, opts, template=None, log=None): # Write to the destination. # TODO: use shortcut to source buffer. with rasterio.open(destination, 'w', **kwargs) as dst: - for i in src.indexes: + for i in dst.indexes: dst.write_band(i, src.read_band(i)) except: @@ -36,6 +36,7 @@ def main(source, destination, opts, template=None, log=None): return 0 + if __name__ == '__main__': import argparse @@ -58,26 +59,55 @@ if __name__ == '__main__': metavar='FILE', help="Use a georeferenced file as a template") parser.add_argument( - '-z', + '-z', '--lzw', action='store_true', help="Compress destination using LZW") parser.add_argument( - '-v', + '--interleave-band', action='store_true', - help="Verbose logging") + help="Band rather than pixel interleaved") + parser.add_argument( + '-t', '--tiled', + action='store_true', + help="Tiled rather than striped TIFFs") + parser.add_argument( + '--block-height', + metavar='HEIGHT', + help="Tile or strip height") + parser.add_argument( + '--block-width', + metavar='WIDTH', + help="Tile width") + parser.add_argument( + '-v', '--verbose', + action='count', + default=0, + help="Increase verbosity") + parser.add_argument( + '-q', '--quiet', + action='count', + default=0, + help="Decrease verbosity") args = parser.parse_args() - if args.v: - logging.basicConfig(stream=sys.stderr, level=logging.DEBUG) - else: - logging.basicConfig(stream=sys.stderr, level=logging.INFO) + verbosity = args.verbose - args.quiet + log_level = max(10, 30 - 10*verbosity) + logging.basicConfig(stream=sys.stderr, level=log_level) logger = logging.getLogger('rio_cp') # TODO: quick check of filenames before we call main(). options = {} - if args.z: + if args.interleave_band: + options['interleave'] = 'band' + if args.lzw: options['compress'] = 'LZW' + if args.tiled: + options['tiled'] = True + if args.block_height: + options['blockysize'] = args.block_height + if args.block_width: + options['blockxsize'] = args.block_width # TODO: support other formats. options['driver'] = 'GTiff'