
    !\i"                     |   S r SSKrSSKrSSKJrJrJr  SSKJrJ	r	J
r
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S
KJr  \R4                  " \5      r " S S\\\5      r " S S\	\\5      r " S S\
\\5      r " S S\5      r  " S S\5      r!\\La  \!r" " S S\ 5      r#S r$SS jr%g! \ a    \r Ntf = f)zhClasses capable of reading and writing datasets

Instances of these classes are called dataset objects.
    N)get_dataset_driverdriver_can_createdriver_can_create_copy)DatasetReaderBaseDatasetWriterBaseBufferedDatasetWriterBaseMemoryFileBase)WindowMethodsMixin)
ensure_env)RasterioDeprecationWarning)TransformMethodsMixin)_UnparsedPath)FilePathBasec                       \ rS rSrSrS rSrg)DatasetReader   z&An unbuffered data and metadata readerc                     SR                  U R                  =(       a    S=(       d    SU R                  U R                  5      $ )Nz&<{} DatasetReader name='{}' mode='{}'>closedopenformatr   namemodeselfs    N/var/www/html/kml_chatgpt/mouzaenv/lib/python3.13/site-packages/rasterio/io.py__repr__DatasetReader.__repr__"   4    7>>KK$H.		499F 	F     N__name__
__module____qualname____firstlineno____doc__r   __static_attributes__r!   r    r   r   r      s    0Fr    r   c                       \ rS rSrSrS rSrg)DatasetWriter'   zQAn unbuffered data and metadata writer. Its methods write data
directly to disk.
c                     SR                  U R                  =(       a    S=(       d    SU R                  U R                  5      $ )Nz&<{} DatasetWriter name='{}' mode='{}'>r   r   r   r   s    r   r   DatasetWriter.__repr__,   r   r    r!   Nr"   r!   r    r   r*   r*   '   s    Fr    r*   c                       \ rS rSrSrS rSrg)BufferedDatasetWriter1   zMaintains data and metadata in a buffer, writing to disk or
network only when `close()` is called.

This allows incremental updates to datasets using formats that don't
otherwise support updates, such as JPEG.
c                     SR                  U R                  =(       a    S=(       d    SU R                  U R                  5      $ )Nz.<{} BufferedDatasetWriter name='{}' mode='{}'>r   r   r   r   s    r   r   BufferedDatasetWriter.__repr__;   s4    ?FFKK$H.		499F 	Fr    r!   Nr"   r!   r    r   r/   r/   1   s    Fr    r/   c                   T   ^  \ rS rSrSrSU 4S jjr\  S	S j5       rS rS r	Sr
U =r$ )

MemoryFile@   a2  A BytesIO-like object, backed by an in-memory file.

This allows formatted files to be read and written without I/O.

A MemoryFile created with initial bytes becomes immutable. A
MemoryFile created without initial bytes may be written to using
either file-like or dataset interfaces.

Examples
--------

A GeoTIFF can be loaded in memory and accessed using the GeoTIFF
format driver

>>> with open('tests/data/RGB.byte.tif', 'rb') as f, MemoryFile(f) as memfile:
...     with memfile.open() as src:
...         pprint.pprint(src.profile)
...
{'count': 3,
 'crs': CRS({'init': 'epsg:32618'}),
 'driver': 'GTiff',
 'dtype': 'uint8',
 'height': 718,
 'interleave': 'pixel',
 'nodata': 0.0,
 'tiled': False,
 'transform': Affine(300.0379266750948, 0.0, 101985.0,
       0.0, -300.041782729805, 2826915.0),
 'width': 791}

c                 "   > [         TU ]  XX4S9  g)a7  Create a new file in memory

Parameters
----------
file_or_bytes : file-like object or bytes, optional
    File or bytes holding initial data.
filename : str, optional
    An optional filename. A unique one will otherwise be generated.
ext : str, optional
    An optional extension.

Returns
-------
MemoryFile
)file_or_bytesdirnamefilenameextNsuper__init__)r   r7   r8   r9   r:   	__class__s        r   r=   MemoryFile.__init__a   s      	'8 	 	
r    c
                 \   [        U R                  5      nU R                  (       a  [        S5      e[	        U 5      S:  a1  [
        R                  SUR                   35        [        U4XS.U
D6nO[        U5      nU" US4UUUUUUUUU	S.	U
D6nU R                  R                  U5        U$ )a  Open the file and return a Rasterio dataset object.

If data has already been written, the file is opened in 'r'
mode. Otherwise, the file is opened in 'w' mode.

Parameters
----------
Note well that there is no `path` parameter: a `MemoryFile`
contains a single dataset and there is no need to specify a
path.

Other parameters are optional and have the same semantics as the
parameters of `rasterio.open()`.
I/O operation on closed file.r   
VSI path: driversharingzw+)	rD   widthheightcountcrs	transformdtypenodatarE   )r   r   r   
ValueErrorlenlogdebugpathr   get_writer_for_driver_envpush)r   rD   rF   rG   rH   rI   rJ   rK   rL   rE   kwargsmempathrdwriters                 r   r   MemoryFile.openu   s    "  		*;;<==t9q=II
7<<.12wQvQ&QB*62F # B$ 			r	r    c                     U $ Nr!   r   s    r   	__enter__MemoryFile.__enter__       r    c                 X    U R                   R                  5         U R                  5         g r[   )rS   closer   argss     r   __exit__MemoryFile.__exit__   s    		

r    r!   )NNNz.tif)	NNNNNNNNFr#   r$   r%   r&   r'   r=   r   r   r\   rc   r(   __classcell__r>   s   @r   r4   r4   @   s8    @
( IM>C, ,\ r    r4   c                   P   ^  \ rS rSrSrSU 4S jjr\S	S j5       rS rS r	Sr
U =r$ )
	_FilePath   zA BytesIO-like object, backed by a Python file object.

.. deprecated:: 1.4.0
   FilePath is supplanted by open's new opener keyword argument,
   and will be removed in 2.0.0.

c                 X   > [         R                  " S[        5        [        TU ]  XUS9  g)a.  Create a new wrapper around the provided file-like object.

Parameters
----------
filelike_obj : file-like object
    Open file-like object. Currently only reading is supported.
filename : str, optional
    An optional filename. A unique one will otherwise be generated.

Returns
-------
PythonVSIFile
z[FilePath is supplanted by open's new opener keyword argument, and will be removed in 2.0.0.)r8   r9   N)warningswarnr   r<   r=   )r   filelike_objr8   r9   r>   s       r   r=   _FilePath.__init__   s0     	i&	
 	H 	 	
r    c                     [        U R                  5      nU R                  (       a  [        S5      e[        R                  SUR                   35        [        U4XS.UD6$ )aH  Open the file and return a Rasterio dataset object.

The provided file-like object is assumed to be readable.
Writing is currently not supported.

Parameters are optional and have the same semantics as the
parameters of `rasterio.open()`.

Returns
-------
DatasetReader

Raises
------
IOError
    If the memory file is closed.

rA   rB   rC   )r   r   r   OSErrorrO   rP   rQ   r   )r   rD   rE   rU   rV   s        r   r   _FilePath.open   sS    (  		*;;9:: 			Jw||n-.WOVOOOr    c                     U $ r[   r!   r   s    r   r\   _FilePath.__enter__   r^   r    c                 $    U R                  5         g r[   )r`   ra   s     r   rc   _FilePath.__exit__   s    

r    r!   )NNNFre   rg   s   @r   ri   ri      s2    
, P P: r    ri   c                   D   ^  \ rS rSrSrSU 4S jjr\SS j5       rSrU =r	$ )ZipMemoryFile   zA read-only BytesIO-like object backed by an in-memory zip file.

This allows a zip file containing formatted files to be read
without I/O.
c                 "   > [         TU ]  USS9  g )Nzip)r:   r;   )r   r7   r>   s     r   r=   ZipMemoryFile.__init__   s    E2r    c                     [        SR                  U R                  UR                  S5      5      5      nU R                  (       a  [        S5      e[        U4X#S.UD6$ )a)  Open a dataset within the zipped stream.

Parameters
----------
path : str
    Path to a dataset in the zip file, relative to the root of the
    archive.

Other parameters are optional and have the same semantics as the
parameters of `rasterio.open()`.

Returns
-------
A Rasterio dataset object
z/vsizip{}/{}/rA   rC   )r   r   r   lstripr   rM   r   )r   rQ   rD   rE   rU   zippaths         r   r   ZipMemoryFile.open   sP    "   5 5diiSAQ RS;;<==WOVOOOr    r!   r[   rw   )
r#   r$   r%   r&   r'   r=   r   r   r(   rf   rg   s   @r   ry   ry      s#    3 P Pr    ry   c                     U (       d  [        S5      eSn[        U 5      (       a  [        nU$ [        U 5      (       a  [        nU$ )z=Return the writer class appropriate for the specified driver.z+'driver' is required to read/write dataset.N)rM   r   r*   r   r/   )rD   clss     r   rR   rR     sD    FGG
C   J 
 	'	'#Jr    c                 <    U(       d  [        U 5      n[        U5      $ )z=Return the writer class appropriate for the existing dataset.)r   rR   )rQ   rD   s     r   get_writer_for_pathr   "  s    #D) ((r    r[   )&r'   loggingrl   rasterio._baser   r   r   rasterio._ior   r   r   r	   rasterio.windowsr
   rasterio.envr   rasterio.errorsr   rasterio.transformr   rasterio._pathr   rasterio._filepathr   ImportErrorobject	getLoggerr#   rO   r   r*   r/   r4   ri   FilePathry   rR   r   r!   r    r   <module>r      s   
   X X  0 # 6 4 (/
 !F%'9;P FF%'9;P FF13HFi iX@ @F vHPJ PD	)U  Ls    B0 0B;:B;