
    !\ib'                         S r SSKrSSKrSSKJr  SSKJ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r\R$                  " \5      rS	 r\R,                  " S
S\R.                  " 5       S\S9r\R2                  " SS9\\R4                  \R6                  \R8                  \R:                  \R<                  \R>                  \R@                  " SSSSSS9\RB                  \R@                  " SSS\"SSS9\R@                  " S\"SSS9\R@                  " SS\#SSS9\RH                  \RJ                  \RL                  \RN                  S  5       5       5       5       5       5       5       5       5       5       5       5       5       5       5       5       5       r(g)!z$ rio rasterize    N)ceil)Affine)CRSError)disjoint_bounds)options)resolve_inoutc                     U$ )z%Process and validate input file names )ctxparamvalues      Y/var/www/html/kml_chatgpt/mouzaenv/lib/python3.13/site-packages/rasterio/rio/rasterize.pyfiles_handlerr      s    L    fileszINPUTS... OUTPUT)nargstypemetavarcallbackzRasterize features.)
short_helpz	--src-crs	--src_crssrc_crszSource coordinate reference system.  Limited to EPSG codes for now.  Used as output coordinate system if output does not exist or --like option is not used. Default: EPSG:4326)defaulthelpz--default-valuez--default_valuedefault_value   z#Default value for rasterized pixels)r   r   r   z--fillzoFill value for all pixels not overlapping features.  Will be evaluated as NoData pixels for output.  Default: 0z
--propertypropzProperty in GeoJSON features to use for rasterized values.  Any features that lack this property will be given --default_value instead.c                   ^
^ SSK Jn  SSKJn  SSKJn  [        XUS9u  p![        R                  " SXSS9nUS	Ln U(       a  UR                  U5      OUR                  S
5      nT
[        T
5      :X  a  [        T
5      m
U[        U5      :X  a  [        U5      nU R                  S      U
U4S jn[        R                  " U(       a  UR                  S5      OS5       n[        R                  " UR!                  5       5      nS	S	S	5        SW;   a+  / nUS    H  nUR#                  US   U" U5      45        M!     O/SU;   a  US   U" U5      44nO[        R                  " S[$        SS9eUR'                  SU" U5      5      n[(        R*                  R-                  U5      (       Ga6  [(        R.                  " US5       nU(       a&  UUR0                  :w  a  [        R                  " SSSS9e[3        UUR                  5      (       a  [        R4                  " SSS9  UR6                  nU" UUS   US   4UR'                  SUS   5      U	UR'                  SS	5      T
US9n[9        SUS   S-   5       H^  nUR!                  USS 9nUU:g  n UU    UU '   UR:                  R=                  5       (       a  S!UR:                  U '   UR?                  UUS"9  M`     S	S	S	5        GOUb  [(        R.                  " U5      n!U(       a&  UU!R0                  :w  a  [        R                  " S#SSS9e[3        UU!R                  5      (       a  [        R4                  " S$SS9  U!R@                  n"SU"S'   U!RB                  U"S'   U!RE                  5         GOcU=(       d    UnURF                  (       a:  US   S%:  d  US&   S':  d  US   S(:  d	  US)   S*:  a  [        R                  " S+XS,S9eU(       a4  Uu  n#n$US&   US   -
  [I        U#5      -  US)   US   -
  [I        U$5      -  4nOU(       d  [        R                  " S-XS.S9e[K        U5      S:X  a
  US   US   4n[M        [        [O        US&   US   -
  [I        US   5      -  5      5      S5      n#[M        [        [O        US)   US   -
  [I        US   5      -  5      5      S5      n$SUU#U$[Q        US   SUS   SUS   * US)   5      US/.n"U(       a  UU"S0'   U"RR                  " S30 UD6  Ub  UU"S1'   U" UU"S   U"S   4U"S   U	U"R'                  SS	5      T
US9nSU";  a  URT                  U"S'   [(        R.                  " US240 U"D6 nUR?                  USS"9  S	S	S	5        S	S	S	5        g	! [         a    Uef = f! , (       d  f       GN= f! , (       d  f       N9= f! , (       d  f       NJ= f! , (       d  f       g	= f)4ae  Rasterize GeoJSON into a new or existing raster.

If the output raster exists, rio-rasterize will rasterize feature
values into all bands of that raster.  The GeoJSON is assumed to be
in the same coordinate reference system as the output unless
--src-crs is provided.

--default_value or property values when using --property must be
using a data type valid for the data type of that raster.

If a template raster is provided using the --like option, the affine
transform and data type from that raster will be used to create the
output.  Only a single band will be output.

The GeoJSON is assumed to be in the same coordinate reference system
unless --src-crs is provided.

--default_value or property values when using --property must be
using a data type valid for the data type of that raster.

--driver, --bounds, --dimensions, --res, --nodata are ignored when
output exists or --like raster is provided

If the output does not exist and --like raster is not provided, the
input GeoJSON will be used to determine the bounds of the output
unless provided using --bounds.

--dimensions or --res are required in this case.

If --res is provided, the bottom and right coordinates of bounds are
ignored.

Note
----

The GeoJSON is not projected to match the coordinate reference
system of the output or --like rasters at this time.  This
functionality may be added in the future.

r   )CRS)	rasterize)bounds)r   output	overwritez#invalid CRS.  Must be an EPSG code.r   )r   
param_hintNz	EPSG:4326envc                 L   > T(       a  SU ;   a  U S   R                  TT5      $ T$ )N
properties)get)featurer   r   s    r   feature_value rasterize.<locals>.feature_value   s+    /|,00}EE  r   -featuresgeometryzInvalid GeoJSONinputbboxzr+z4GeoJSON does not match crs of existing output rasterzeGeoJSON outside bounds of existing output raster. Are they in different coordinate reference systems?T)errheightwidthaffine	transformdtype)	out_shaper6   all_touchedr7   r   fillr   count)maskedF)indexesz+GeoJSON does not match crs of --like rasterz\GeoJSON outside bounds of --like raster. Are they in different coordinate reference systems?iL      i   P   z1Bounds are beyond the valid extent for EPSG:4326.z--boundszpixel dimensions are requiredz--res)r;   crsr4   r3   r6   driverrC   nodatawr
   )+rasterio.crsr    rasterio.featuresr!   r"   r   clickBadParameterfrom_stringr   intobj	open_filepopjsonloadsreadappendr0   r)   rasterioshutilexistsopenrB   r   echometarangemaskanywriteprofiler6   closeis_geographicfloatlenmaxr   r   updater7   )%r   r   r#   rC   liker"   
dimensionsresr   r9   r   r:   r   r$   rD   creation_optionsr    r!   calculate_bounds	bad_paramhas_src_crsr+   gj_fgeojson
geometriesfgeojson_boundsoutrX   resultbidxdatanetemplate_dskwargsr4   r3   s%             ` `                        r   r!   r!   $   s   h !+<!i9MF ""#H#&+OI%K.9#//'*s{?[ M**M*s4y4y		!
 __UUYYq\<jj-G = JZ(!!1Z=-2B"CD )7"":.g0FGJJ$$%6e079 9 !V-=g-FG??!!&))vt,7cgg#5,, .F3:wP P #>3::>>JJ  4 $()
 xx"#H~tG}="hhxk1BC +((7D1"/ "!T']Q%67D88D86D4B%bzDHyy}}(-		"IIdDI1 8/ -,B &mmD17koo#=,, .=3:wP P #>;3E3EFFJJ  * $()
 %,,"#w&1&;&;{#!!#  1>((q	D(F1IO"1IOvay2~#00)*F F
 $.ME6VAY.%,>VAY.%-?C #00;w@ @ SQ"1vs1v.D&)fQi*? %c!f*. %/ !0124E T6!9vay+@!&s1v+/ &0 "1235F ""$!'A6!9a#a&(.q	"3$ '-F8$MM-,-!#)x !(+VG_= -'jj$/+F f$"(,,wvs5f5		&!	, 6Q 
  " =< -,d 65Q 
sb   )U9 (6V=%V	B<V=?DVJV=V,(V=9V	
V	V=
V)	%V=,
V:	6V==
W))__doc__rO   loggingmathr   r5   r   rH   rS   rasterio.errorsr   rasterio.coordsr   rasterio.rior   rasterio.rio.helpersr   rasterio.shutil	getLogger__name__loggerr   argumentPathfiles_inout_argcommand
output_opt
format_optlike_file_opt
bounds_optdimensions_optresolution_optoptionall_touched_optr`   stroverwrite_opt
nodata_optrg   pass_contextr!   r
   r   r   <module>r      s          $ +   .  
		8	$ ..
	 /0k;	4#$
 	!2O!*OQhUAFG lFd BO P 	Y-    PGQ $        14Y-r   