<s> import logging <EOL> import math <EOL> import os . path <EOL> import click <EOL> from cligj import files_inout_arg , format_opt <EOL> from . helpers import resolve_inout <EOL> from . import options <EOL> import rasterio <EOL> from rasterio . env import Env <EOL> from rasterio . transform import Affine <EOL> @ click . command ( short_help = "<STR_LIT>" ) <EOL> @ files_inout_arg <EOL> @ options . output_opt <EOL> @ format_opt <EOL> @ options . bounds_opt <EOL> @ options . resolution_opt <EOL> @ options . nodata_opt <EOL> @ options . force_overwrite_opt <EOL> @ click . option ( '<STR_LIT>' , type = int , default = <NUM_LIT:7> , <EOL> help = "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> @ options . creation_options <EOL> @ click . pass_context <EOL> def merge ( ctx , files , output , driver , bounds , res , nodata , force_overwrite , <EOL> precision , creation_options ) : <EOL> """<STR_LIT>""" <EOL> from rasterio . merge import merge as merge_tool <EOL> verbosity = ( ctx . obj and ctx . obj . get ( '<STR_LIT>' ) ) or <NUM_LIT:1> <EOL> output , files = resolve_inout ( <EOL> files = files , output = output , force_overwrite = force_overwrite ) <EOL> with Env ( CPL_DEBUG = verbosity > <NUM_LIT:2> ) as env : <EOL> sources = [ rasterio . open ( f ) for f in files ] <EOL> dest , output_transform = merge_tool ( sources , bounds = bounds , res = res , <EOL> nodata = nodata , precision = precision ) <EOL> profile = sources [ <NUM_LIT:0> ] . profile <EOL> profile . pop ( '<STR_LIT>' ) <EOL> profile [ '<STR_LIT>' ] = output_transform <EOL> profile [ '<STR_LIT>' ] = dest . shape [ <NUM_LIT:1> ] <EOL> profile [ '<STR_LIT:width>' ] = dest . shape [ <NUM_LIT:2> ] <EOL> profile [ '<STR_LIT>' ] = driver <EOL> profile . update ( ** creation_options ) <EOL> with rasterio . open ( output , '<STR_LIT:w>' , ** profile ) as dst : <EOL> dst . write ( dest ) </s>
