
    nj}#                     8   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	J
r
  S r          SS\\   S\S	\\   S
\S\\   S\S\S\S\S\\   4S jjr " S S\
5      r\ R$                  4S jr\S:X  a#  \ R*                  " \" \ R$                  5      5        gg)    N)Real)Optional)gdal)GDALArgumentParser
GDALScriptc           
          [        U R                  5       HF  nU R                  SX R                  S5      nUR	                  SX R                  SX0R
                  S9  MH     g )Nr      )buf_type)rangeYSize
ReadRasterXSizeWriteRasterDataType)srcbanddstbandline	line_datas       W/var/www/html/pdf-tiff/venv/lib/python3.13/site-packages/osgeo_utils/gdal_fillnodata.pyCopyBandr   *   sS    gmm$&&q$qA	t]]Ay;K;K 	 	
 %    src_filenameband_numberdst_filenamedriver_namecreation_optionsquietmaskmax_distancesmoothing_iterationsoptionsc
           	         U	=(       d    / n	U=(       d    / n [         R                    Uc&  [         R                  " U [         R
                  5      n
O%[         R                  " U [         R                  5      n
U
c  [        SU -  5        gU
R                  U5      nUGb0  [         R                  " U5      nUR                  UU
R                  U
R                  SUR                  U5      nU
R                  5       nUS:w  a  UR                  U5        U
R                  SS9nU(       a  UR!                  U5        UR                  S5      nUR#                  5       nUb  UR%                  U5        UR'                  5       nUR)                  U5        U[         R*                  :X  a!  UR-                  5       nUR/                  U5        [1        UU5        OUnU(       a  S nO[         R2                  nUS:X  a  UR5                  5       nO'[         R                  " U5      nUR                  S5      n[         R                  " UUUUU	US	9nS n
S nS nU$ ! [         a/    [        S5        [        S5        [        S5        [        S5         gf = f)
N z@gdal.FillNodata() not available.  You are likely using "old gen"z6bindings or an older version of the next gen bindings.r	   zUnable to open %sT)can_return_nulldefault)callback)r   
FillNodataAttributeErrorprintOpen	GA_UpdateGA_ReadOnlyGetRasterBandGetDriverByNameCreateRasterXSizeRasterYSizer   GetProjectionSetProjectionGetGeoTransformSetGeoTransformGetNoDataValueSetNoDataValueGetColorInterpretationSetColorInterpretationGCI_PaletteIndexGetColorTableSetColorTabler   TermProgress_nocbGetMaskBand)r   r   r   r   r   r   r   r   r    r!   src_dsr   drvdst_dswktgtr   ndvcolor_interpcolor_table	prog_funcmaskbandmask_dsresults                           r   gdal_fillnodatarK   2   sJ    mG'-2
 <8<)9)9:~!L01"";/G "";/
 ""$"9  %##D#9""2&&&q)$$&?""3'557&&|44000!//1K!!+.'"  	**	y&&())D/((+__F FFGMq  b	PQFGb	s   I 6J Jc                   <   ^  \ rS rSrU 4S jrS\4S jrS rSrU =r	$ )GDALFillNoData   c                 f   > [         TU ]  5         SU l        [        R                  " S5      U l        g )Nz/Fill raster regions by interpolation from edgesz            It Fills selection regions (usually nodata areas)
            by interpolating from valid pixels around the edges of the area.
            Additional details on the algorithm are available in the GDALFillNodata() docs.)super__init__titletextwrapdedentdescription)self	__class__s    r   rQ   GDALFillNoData.__init__   s,    F
#??_
r   returnc           
         U R                   nUR                  SSSSSS9  UR                  SS[        S	SS
S9  UR                  SS[        SSSS9  UR                  SS[        SSSSS9  UR                  SS[        SSSS9  UR                  SSSS [        S!S"S#9  UR                  S$S%S&S'S(S)9  UR                  S*S+[        / S,SS-S.9  UR                  S/[        S0S19  UR                  S2[        S3S19  U$ )4Nz-qz-quietr   
store_trueziThe script runs in quiet mode. The progress monitor is suppressed and routine messages are not displayed.)destactionhelpz-mdr   d   zyThe maximum distance (in pixels) that the algorithm will search out for values to interpolate. The default is 100 pixels.)r\   typer%   metavarr^   z-sir    r   zThe number of 3x3 average filter smoothing iterations to run after the interpolation to dampen artifacts. The default is zero smoothing iterations.z-or!   extend*z
name=valuez,Specify a special argument to the algorithm.)r\   r`   r]   nargsra   r^   z-maskr   filenamer%   zaUse the first band of the specified file as a validity mask (zero is invalid, non-zero is valid).)r\   r`   ra   r%   r^   z-bz-bandr   bandr	   z&The band to operate on, defaults to 1.)r\   ra   r`   r%   r^   z-ofr   GTiffgdal_formatz4Select the output format. Use the short format name.)r\   r%   ra   r^   z-cor   appendzPasses a creation option to the output format driver. Multiple options may be listed. See format specific documentation for legal creation options for each format.)r\   r`   r%   r]   ra   r^   r   zMThe source raster file used to identify target pixels. Only one band is used.)r`   r^   r   zjThe new file to create with the interpolated result. If not provided, the source band is updated in place.)parseradd_argumentfloatintstr)rV   argvrj   s      r   
get_parserGDALFillNoData.get_parser   s   Y 	 	
 	") 	 		
 	'*M 	 	
 	 ? 	 	
 	4 	 	
 	9 	 	
 	!G 	 	
 	# 0 	 
	
 	% 	 	
 	D 	 	
 r   c                     [        S0 UD6$ )N )rK   )rV   kwargss     r   doitGDALFillNoData.doit  s    (((r   )rU   rR   )
__name__
__module____qualname____firstlineno__rQ   r   rp   ru   __static_attributes____classcell__)rW   s   @r   rM   rM      s"    
a"4 aF) )r   rM   c                 4    [        5       R                  U 5      $ )N)rM   main)ro   s    r   r~   r~     s      &&r   __main__)
Nr	   Nrg   NFr%   r_   r   N)sysrS   numbersr   typingr   osgeor   #osgeo_utils.auxiliary.gdal_argparser   r   r   rn   rm   listboolrK   rM   ro   r~   rw   exitrs   r   r   <module>r      s   B      N
 #'"&'+ !"l3-ll 3-l 	l
 tnl l l l l d^l^o)Z o)d hh ' zHHT#((^ r   