
    nj{0                     b   S SK r S SKrS SKJrJr  S SKJrJr  S SKJ	r	J
r
  S SKJr              SS\\   S\\\4   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)OptionalUnion)gdalogr)GDALArgumentParser
GDALScript)GetOutputDriverForsrc_filenameband_numberdst_filename	overwritedriver_namedst_layernamedst_fieldnamequietmaskoptionslayer_creation_optionsconnectedness8c           	      `
   [        U[        5      (       a!  UR                  S5      (       d  [        U5      nU	=(       d    / n	U(       a  U	R	                  S5        Uc
  [        USS9nUc  Sn[        R                  " U 5      nUc  [        SU -  5        gUS:X  a4  UR                  S5      R                  5       nU	R	                  SU -   5        O[        U[        5      (       a_  UR                  S	5      (       aI  UR                  [        U[        S	5      S  5      5      R                  5       nU	R	                  SU -   5        OUR                  U5      nUS
:X  a  UR                  5       nO0US:X  a  S nO'[        R                  " U5      nUR                  S5      n [        R                  " S5        [        R                  " USS9n[        R                  " 5         Ub  U(       a  UR!                  5       nS n[#        U5       H/  nUR%                  U5      nUc  M  UR'                  5       U:X  d  M/    O   SnUU:w  aF  UR)                  [        R*                  5      S:X  a#   UR-                  U5      [        R.                  :H  nU(       d9  US:X  a3  S n[        R0                  " U5      (       a  [        R2                  " U5        UcB  [        R4                  " U5      nU(       d  [        SU< SU< S35        UR7                  U5      n UR9                  U5      nSnUc  UR;                  5       nUR=                  U[        R>                  UU
(       a  U
O/ S9nUc  Sn[        R@                  nURB                  [        RD                  :X  d  URB                  [        RF                  :X  a  [        RH                  n[        RJ                  " UU5      nURM                  U5        SnONU
(       a  [        S5        Ub9  URO                  5       RQ                  U5      nUS:  a  [        SU< SU< S35        U(       a  S nO[        RR                  nURU                  5         [        RV                  " XUUU	US9nU[        RX                  :X  a  UR[                  5         OUR]                  5         S nS nS nS nU$ ! [         aJ     [        R                  " U5      nO! [         a    S n Of = fU(       a  U(       d  [        U S35      e GN+f = f! [         a    Sn GNf = f! [         a    S n GNf = f)Nr   z8CONNECTED=8F)	is_rasteroutzUnable to open %s   zDATASET_FOR_GEOREF=zmask,defaultnoneCPLQuietErrorHandler)updatezR exists, but cannot be updated. You may need to remove it before or use -overwritezCreating output z of format .)	geom_typesrsr   DNr   zKWarning: layer_creation_options will be ignored as the layer already existszWarning: cannot find field 'z' in layer '')callback)/
isinstancestr
startswithintappendr	   r   OpenprintGetRasterBandGetMaskBandlenPushErrorHandlerr   PopErrorHandler	ExceptionGetLayerCountrangeGetLayerGetNameTestCapabilityODsCDeleteLayerDeleteLayerOGRERR_NONEVSIStatLUnlinkGetDriverByNameCreateDataSourceGetLayerByNameGetSpatialRefCreateLayer
wkbPolygon
OFTIntegerDataType	GDT_Int64
GDT_UInt64OFTInteger64	FieldDefnCreateFieldGetLayerDefnGetFieldIndexTermProgress_nocbStartTransaction
PolygonizeCE_NoneCommitTransactionRollbackTransaction)r
   r   r   r   r   r   r   r   r   r   r   r   src_dssrcbandmaskbandmask_dsdst_dscntiLayerpoLayer	delete_okdrv	dst_layer	dst_fieldr!   	data_typefd	prog_funcresults                                W/var/www/html/pdf-tiff/venv/lib/python3.13/site-packages/osgeo_utils/gdal_polygonize.pygdal_polygonizerb   +   s    +s##K,B,B6,J,J+&mG~&(G YY|$F~!L01f&&q)557,|;<	K	%	%+*@*@*I*I&&s;s7|~+F'GHTTV,|;<&&{3y&&(	))D/((+45,q1 i""$CjFoof-G"w'8M'I !
 	S=$$S%8%89Q>& & 2 26 :coo MI ax==..KK-
 ~!!+.kRS%%l3
))-8	 I""$&&nn.D*"	 ' 
	   MNN	t~~-1A1AT__1T((I]]=)4b!	!] $!..0>>}MI1}$m5 	**	 __9i9F ##%%%'GFFGMW  	XXl+F 	F	). rs . ! & %I&.  	s[   A R3 !"T
 	T 3
T>STS$!T#S$$TT
TTT-,T-c                   <   ^  \ rS rSrU 4S jrS\4S jrS rSrU =r	$ )GDALPolygonize   c                 f   > [         TU ]  5         SU l        [        R                  " S5      U l        g )Nz.Produces a polygon feature layer from a rasterap              This utility creates vector polygons for all connected regions of pixels in the raster
            sharing a common pixel value. Each polygon is created with an attribute indicating
            the pixel value of that polygon.
            A raster mask may also be provided to determine which pixels are eligible for processing.
            The utility will create the output vector datasource if it does not already exist,
            otherwise it will try to append to an existing one.
            The utility is based on the GDALPolygonize() function
            which has additional details on the algorithm.)super__init__titletextwrapdedentdescription)self	__class__s    ra   rh   GDALPolygonize.__init__   s+    E
#??>

    returnc           
      H   U R                   nUR                  SSSSSS9  UR                  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 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9  UR                  S.[        S/S09  UR                  S1[        S2S09  UR                  S3[        S4S5S69  UR                  S7[        S4S8S69  U$ )9Nz-qz-quietr   
store_trueziThe script runs in quiet mode. The progress monitor is suppressed and routine messages are not displayed.)destactionhelpz-8r   z0Use 8 connectedness. Default is 4 connectedness.z-or   r)   z
name=valuezRSpecify a special argument to the algorithm. This may be specified multiple times.)rt   typeru   metavarrv   z-maskr   filenamer   zaUse the first band of the specified file as a validity mask (zero is invalid, non-zero is valid).)rt   rw   rx   r   rv   z-nomaskstore_constr   zYDo not use the default validity mask for the input band (such as nodata, or alpha masks).)rt   ru   constr   rv   z-bz-bandr   band1zThe band on <raster_file> to build the polygons from. Starting with GDAL 2.2, the value can also be set to "mask", to indicate that the mask band of the first band must be used (or "mask,band_number" for the mask of a specified band).)rt   rx   rw   r   rv   z-ofz-fr   
ogr_formatzpSelect the output format. if not specified, the format is guessed from the extension. Use the short format name.)rt   rx   rv   z-lcor   zFSpecify a layer creation option. This may be specified multiple times.z
-overwriter   z*overwrite output file if it already existsr
   z7The source raster file from which polygons are derived.)rw   rv   r   zBThe destination vector file to which the polygons will be written.r   ?z;The name of the layer created to hold the polygon features.)rw   nargsrv   r   z3The name of the field to create (defaults to "DN").)parseradd_argumentr&   )rm   argvr   s      ra   
get_parserGDALPolygonize.get_parser   s   Y 	 	
 	!C	 	 	
 	 e 	 	
 	4 	 	
 	 0 	 	
 	H 	 	
 	 ) 	 	
 	) Y 	 	
 	=	 	 	
 	J 	 	
 	U 	 	
 	N	 	 	
 	F	 	 	
 rp   c                     [        S0 UD6$ )N )rb   )rm   kwargss     ra   doitGDALPolygonize.doit^  s    (((rp   )rl   ri   )
__name__
__module____qualname____firstlineno__rh   r   r   r   __static_attributes____classcell__)rn   s   @ra   rd   rd      s"    
q"4 qf) )rp   rd   c                 4    [        5       R                  U 5      $ )N)rd   main)r   s    ra   r   r   b  s      &&rp   __main__)Nr   NFNNNFr   NNF)sysrj   typingr   r   osgeor   r   #osgeo_utils.auxiliary.gdal_argparser   r   osgeo_utils.auxiliary.utilr	   r&   r(   boollistrb   rd   r   r   r   exitr   rp   ra   <module>r      s+  D   "  N 9 #'#$"&!%#'#'"-1 m3-msCxm 3-m 	m
 #m C=m C=m m m d^m %TNm m`D)Z D)N hh ' zHHT#((^ rp   