
    !\iE                     D   S r SSKJr  SSKrSSKrSSKrSSKJr  SSKJ	r	  SSK
Jr  SSKJr  \R                  " \5      r\R$                  " SS	9\	R&                  \	R(                  \	R*                  \	R,                  \	R.                  \	R0                  \R2                  " S
\R4                  " \ V s/ s H   o R6                  S::  d  M  U R8                  PM"     sn 5      SSSS9\	R:                  \	R<                  \	R>                  \	R@                  \R2                  " SSSS9\R2                  " S\!SSS9\R2                  " SSSS9\	RD                  \RF                  S 5       5       5       5       5       5       5       5       5       5       5       5       5       5       5       5       5       rgs  sn f )zRaster stack CLI command.    )zip_longestN)
Resampling)options)resolve_inout)stackz1Stack a number of bands into a multiband dataset.)
short_helpz--resampling   nearestzResampling method.T)typedefaulthelpshow_defaultz2--target-aligned-pixels/--no-target-aligned-pixelsFz0Align the output bounds based on the resolution.)r   r   z--mem-limit@   z4Limit on memory used to perform calculations, in MB.)r   r   r   z!--use-highest-res/--use-first-reszUUse the highest resolution of sources or the resolution of the first source argument.c                    [        XUS9u  p![        U   nSn/ n[        XSS9 GH>  u  nn[        R                  " U5       nUR
                  nSSS5        Uc!  UR                  W5        U[        U5      -  nMV  SU;   ae  [        S UR                  S5      5      u  nnUc  SnUR                  W[        US-
  U5         5        U[        U[        US-
  U5         5      -  nM  [        [        [        UR                  S5      5      5      n[        U5      S:X  a  UR                  US   5        US-  nGM  [        U5      nUR                  U5        U[        U5      -  nGMA     0 nU(       a  UUS	'   U(       a  UUS
'   U R                  S      [        UUUUU	UUUUUUUUS9  SSS5        g! , (       d  f       GNh= f! , (       d  f       g= f)a  Stack a number of bands from one or more input files into a
multiband dataset.

Input datasets must be of a kind: same data type, dimensions, etc. The
output is cloned from the first input.

By default, rio-stack will take all bands from each input and write them
in same order to the output. Optionally, bands for each input may be
specified using a simple syntax:

  --bidx N takes the Nth band from the input (first band is 1).

  --bidx M,N,0 takes bands M, N, and O.

  --bidx M..O takes bands M-O, inclusive.

  --bidx ..N takes all bands up to and including N.

  --bidx N.. takes all bands from N to the end.

Examples, using the Rasterio testing dataset, which produce a copy.

  rio stack RGB.byte.tif -o stacked.tif

  rio stack RGB.byte.tif --bidx 1,2,3 -o stacked.tif

  rio stack RGB.byte.tif --bidx 1..3 -o stacked.tif

  rio stack RGB.byte.tif --bidx ..2 RGB.byte.tif --bidx 3.. -o stacked.tif

)filesoutput	overwriter   N)	fillvaluez..c                 *    U (       a  [        U 5      $ S $ )N)int)xs    U/var/www/html/kml_chatgpt/mouzaenv/lib/python3.13/site-packages/rasterio/rio/stack.py<lambda>stack.<locals>.<lambda>s   s    !A(=(=       ,driverphotometricenv)boundsresnodatadtypeindexesoutput_count
resamplingtarget_aligned_pixels	mem_limituse_highest_resdst_pathdst_kwds)r   r   r   rasterioopenr%   appendlenmapsplitslicelistr   obj
stack_tool)ctxr   r   r   r   r!   r"   r'   r#   r$   bidxr   r(   r)   r*   creation_optionsr&   r%   pathitemsrcsrc_indexesstartstoppartsr,   s                             r   r   r      s   j "	RMFJ'JLG!%>
d]]4 C++K !<NN;'C,,LT\=tzz$?OPKE4}NN;uUQY'=>?CE%!)T,B CDDLS$**S/23E5zQuQx(!Uu%E
*) ?, H#"-	%!"7+	
 
9 ! 8 
s   F/G/
F>	
G)$__doc__	itertoolsr   loggingclickr-   rasterio.enumsr   rasterio.rior   rasterio.rio.helpersr   rasterio.stackr   r6   	getLogger__name__loggercommandfiles_inout_arg
output_opt
format_optrgb_opt
bounds_optresolution_optoptionChoicevaluename
nodata_opt	dtype_optbidx_magic_optoverwrite_optr   r9   pass_context)rs   0r   <module>r]      s    !    %   . .			8	$ MN	zBz!WW\vqvvzB	C	 	8	;
 		?	 '	`
 	c
             OHc
7 Cs   -FF