
    !\in"                        S r SSKrSSK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  SSKJr  SSKJr  S	 rS
 rS rS rS r\R,                  " SSS9\R.                  \R0                  \R2                  \R4                  " SSSSS9\R4                  " S\SSS9\R4                  " SSSSS9\R4                  " S\SS9\R4                  " SSS 9\R4                  " S!S"S 9\R4                  " S#S$\SS%S&S'9\R4                  " S(S)\S*SSS+S,9\R4                  " S-\S.S/S09\R6                  \R8                  S1 5       5       5       5       5       5       5       5       5       5       5       5       5       5       5       rg)2z=Fetch and edit raster dataset metadata from the command line.    N)CRS)in_dtype_rangeColorInterp)CRSError)options)guard_transformc                     U R                   (       aL  U R                   R                  S5      (       a,  Ub)  X R                   S'   U R                   R                  S5      nU$ ).Get tags from a template file or command line.likeall_like)objget)ctxparamvalues      Y/var/www/html/kml_chatgpt/mouzaenv/lib/python3.13/site-packages/rasterio/rio/edit_info.pyall_handlerr      sC    
ww377;;v&&5+<#
F#L    c                 `   [         R                  " XU5      nUcZ  U(       aS   [        R                  " U5      n [        U[        5      (       a  [        U5      nU$ [        R                  " U5      n U$ U$ ! [         a    Un NLf = f! [         a    [        R                  " SU-  USS9ef = f)z3Get crs value from a template file or command line.z'%s' is not a recognized CRS.crsr   
param_hint)r   from_like_contextjsonloads
ValueError
isinstancedictr   from_stringr   clickBadParameterr   r   r   retvals       r   crs_handlerr%      s    &&s59F~%	ZZ&F	/&$''V M 0
 M6M  	F	  	/$$/&8/ /	/s"   A7  B	 B	 7BB	$B-c                     [         R                  " XU5      nUc  U(       a   [        S U 5       5      nU$ U$ ! [         a    [        R
                  " SU-  USS9ef = f)r   c              3   B   #    U  H  oR                  S 5      v   M     g7f)=N)split).0ps     r   	<genexpr>tags_handler.<locals>.<genexpr>7   s     61''#,,s   z'%s' contains a malformed tag.	transformr   )r   r   r   	Exceptionr!   r"   r#   s       r   tags_handlerr0   2   sl    &&s59F~%	5666F
 M6M	  	5$$0585 5	5s	   9 $Ac                     [         R                  " XU5      nUc,  U(       a%   [        R                  " U5      n [        U5      nU$ U$ ! [         a     Nf = f! [         a    [        R                  " SU-  USS9ef = f)z9Get transform value from a template file or command line.z*'%s' is not recognized as an Affine array.r.   r   )	r   r   r   r   r   r	   r/   r!   r"   r#   s       r   transform_handlerr2   ?   s    &&s59F~%	JJu%E	5$U+F
 M6M  		  	5$$<uD5 5	5s   A	 A 	
AA$A=c           	         Uc  U$ UR                  5       S:X  a  [        R                  " XU5      $ UR                  5       S:X  a/  [        R                  [        R
                  [        R                  4$ UR                  5       S:X  a>  [        R                  [        R
                  [        R                  [        R                  4$ [        UR                  S5      5      nU HX  nU[        R                  ;  d  M  [        R                  " SR                  USR                  [        R                  5      S95      e   [        S U 5       5      $ )	zkValidate a string like ``red,green,blue,alpha`` and convert to
a tuple.  Also handle ``RGB`` and ``RGBA``.
r   rgbrgba,z@color interpretation '{ci}' is invalid.  Must be one of: {valid}z, )civalidc              3   4   #    U  H  n[         U   v   M     g 7f)Nr   )r*   r7   s     r   r,   &colorinterp_handler.<locals>.<genexpr>g   s     ;{[_{s   )lowerr   r   r   redgreenbluealphatupler)   __members__r!   r"   formatjoin)r   r   r   colorinterpr7   s        r   colorinterp_handlerrE   P   s	    }	&	 ((U;;	%	 1 1;3C3CCC	&	  1 1;3C3C[EVEVVVEKK,-B000(($fTYY{/F/F%G % IJ J  ;{;;;r   z	edit-infozEdit dataset metadata.)
short_helpz--unset-nodataFTz!Unset the dataset's nodata value.)defaultis_flaghelpz--crszNew coordinate reference system)callbackrG   rI   z--unset-crszUnset the dataset's CRS value.z--transformzNew affine transform matrix)rJ   rI   z--unitsz&Edit units of a band (requires --bidx))rI   z--descriptionz,Edit description of a band (requires --bidx)z--tagtagszKEY=VALzNew tag.)rJ   multiplemetavarrI   z--allallmdr   z/Copy all metadata items from the template file.)rJ   
flag_valueis_eagerrG   rI   z--colorinterpzname[,name,...]|RGB|RGBA|likezSet color interpretation for all bands like 'red,green,blue,alpha'. Can also use 'RGBA' as shorthand for 'red,green,blue,alpha' and 'RGB' for the same sans alpha band.  Use 'like' to inherit color interpretation from '--like'.)rJ   rM   rI   c           	         US:X  a  U R                   S   nU R                   S      [        R                  " US5       nU(       a  US   nUS   nUS   nUS   n
US   nU(       a  Ub  [        R                  " S
5      eU(       a  U(       a  [        R                  " S5      eU(       a	   S	Ul        OEUbB  UR                  S   nUb*  [        UU5      (       d  [        R                  " SU-  USS9eX>l        U(       a  S	Ul        OU(       a  X^l        U(       a  X~l        U
(       a  UR                  " S0 U
D6  U(       a  UR                  X(5        U	(       a  UR                  X)5        U(       a^  U(       aP  [!        U5      UR"                  :w  a7  [        R                  " SR%                  [!        U5      UR"                  S95      e Xl        S	S	S	5        S	S	S	5        U(       a`  U R                   S      [        R                  " US5       nUR                  (       a  [*        R,                  " S5        S	S	S	5        S	S	S	5        g	g	! [         a$  n[        R                  " [        U5      5      eS	nAff = f! [(         a$  n[        R                  " [        U5      5      eS	nAff = f! , (       d  f       N= f! , (       d  f       N= f! , (       d  f       N= f! , (       d  f       g	= f)a^  Edit a dataset's metadata: coordinate reference system, affine
transformation matrix, nodata value, and tags.

The coordinate reference system may be either a PROJ.4 or EPSG:nnnn
string,

  --crs 'EPSG:4326'

or a JSON text-encoded PROJ.4 object.

  --crs '{"proj": "utm", "zone": 18, ...}'

Transforms are JSON-encoded Affine objects like:

  --transform '[300.038, 0.0, 101985.0, 0.0, -300.042, 2826915.0]'

Prior to Rasterio 1.0 GDAL geotransforms were supported for --transform,
but are no longer supported.

Metadata items may also be read from an existing dataset using a
combination of the --like option with at least one of --all,
`--crs like`, `--nodata like`, and `--transform like`.

  rio edit-info example.tif --like template.tif --all

To get just the transform from the template:

  rio edit-info example.tif --like template.tif --transform like

r   envzr+nodatar   r.   rK   rD   Nz4--unset-nodata and --nodata cannot be used together.z.--unset-crs and --crs cannot be used together.r   z/outside the range of the file's data type (%s).r   zWhen using '--like' for color interpretation the template and target images must have the same number of bands.  Found {template} color interpretations for template image and {target} bands in target image.)templatetargetrzaCRS was not unset. Availability of his functionality differs depending on GDAL version and driver )r   rasterioopenr!   r"   rS   NotImplementedErrorClickExceptionstrdtypesr   r   r.   update_tagsset_band_unitset_band_descriptionlencountrB   rD   r   warningswarn)r   inputbidxrS   unset_nodatar   	unset_crsr.   unitsdescriptionrK   rN   r   rD   dstexcdtypeesrcs                      r   editrp   j   s]   @ 	ud3s8_F,Ck*I=D.KF.$$F  $$%UVV5!
 JJqME!.*G*G((EM ' 
  JCGG%MOO#d#d*$$T7K(CII5** $V!$[!1"yy $ *+ +3"-A 4J WWU^X]]5#6#wwCD 7^^ ] ' 5**3s8445T  3**3q6223C 43L 76^^s   J9A,J(*I1DJ(I7J94K(K
4K
I4I//I44J(7
J%J  J%%J((
J6	2J99
K

K	K
K))__doc__r   rc   r!   rX   rasterio.crsr   rasterio.dtypesr   rasterio.enumsr   rasterio.errorsr   rasterio.rior   rasterio.transformr	   r   r%   r0   r2   rE   commandfile_in_argbidx_optedit_nodata_optoptionlike_optpass_contextrp   rW   r   r   <module>r      s   C       * & $   .(
"<4 {'?@t68gT46mUD35m&702iFGoACgvtj2gwUDF 1+
)* 	pD  *F2C H2568    A:pDr   