https://t.me/RX1948
Server : Apache
System : Linux iad1-shared-b8-43 6.6.49-grsec-jammy+ #10 SMP Thu Sep 12 23:23:08 UTC 2024 x86_64
User : dh_edsupp ( 6597262)
PHP Version : 8.2.26
Disable Function : NONE
Directory :  /lib/python3/dist-packages/django/contrib/gis/gdal/raster/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //lib/python3/dist-packages/django/contrib/gis/gdal/raster/__pycache__/band.cpython-310.pyc
o

3�a7 �@s�ddlmZmZmZmZddlmZddlmZ	ddl
mZddlm
Z
ddlmZddlmZmZmZmZGd	d
�d
e�ZGdd�de�Zd
S)�)�byref�c_double�c_int�c_void_p)�
GDALException)�raster)�GDALRasterBase)�numpy)�	force_str�)�GDAL_COLOR_TYPES�GDAL_INTEGER_TYPES�GDAL_PIXEL_TYPES�GDAL_TO_CTYPESc@s�eZdZdZdd�Zdd�Zedd��Zedd	��Zed
d��Z	edd
��Z
dZd#dd�Zedd��Z
edd��Zedd��Zedd��Zedd��Zejdd��Zd$dd�Zd$dd�Zd%d!d"�Zd S)&�GDALBandzQ
    Wrap a GDAL raster band, needs to be obtained from a GDALRaster object.
    cCs||_t�|j|�|_dS�N)�source�capi�get_ds_raster_band�_ptr)�selfr�index�r�E/usr/lib/python3/dist-packages/django/contrib/gis/gdal/raster/band.py�__init__szGDALBand.__init__cCs|j��d|_dS)z�
        Call the flush method on the Band's parent raster and force a refresh
        of the statistics attribute when requested the next time.
        TN)r�_flush�_stats_refresh�rrrrrs

zGDALBand._flushcCstt�|j��S)z<
        Return the description string of the band.
        )r
r�get_band_descriptionrrrrr�descriptionszGDALBand.descriptioncC�t�|j�S)z7
        Width (X axis) in pixels of the band.
        )r�get_band_xsizerrrrr�width%�zGDALBand.widthcCr )z8
        Height (Y axis) in pixels of the band.
        )r�get_band_ysizerrrrr�height,r#zGDALBand.heightcCs|j|jS)zA
        Return the total number of pixels in this band.
        )r"r%rrrr�pixel_count3r#zGDALBand.pixel_countFcCs�t�t�t�t�f\}}}}|jt|�t|�t|�t|�t|�t�t�g}|s*|jr.tj}n
d}	|�dt|	��tj	}z||�|j
|j
|j
|j
f}
WntyVd}
Ynwd|_|
S)a�
        Compute statistics on the pixel values of this band.

        The return value is a tuple with the following structure:
        (minimum, maximum, mean, standard deviation).

        If approximate=True, the statistics may be computed based on overviews
        or a subset of image tiles.

        If refresh=True, the statistics will be computed from the data directly,
        and the cache will be updated where applicable.

        For empty bands (where all pixel values are nodata), all statistics
        values are returned as None.

        For raster formats using Persistent Auxiliary Metadata (PAM) services,
        the statistics might be cached in an auxiliary file.
        T�)NNNNF)rrrrrrr�compute_band_statistics�insert�get_band_statistics�valuer)r�refresh�approximate�smin�smax�smean�sstd�
stats_args�func�force�resultrrr�
statistics<s"�
�zGDALBand.statisticscC�|��dS)z?
        Return the minimum pixel value for this band.
        r�r6rrrr�minjr#zGDALBand.mincCr7)z?
        Return the maximum pixel value for this band.
        rr8rrrr�maxqr#zGDALBand.maxcCr7)zC
        Return the mean of all pixel values of this band.
        r'r8rrrr�meanxr#z
GDALBand.meancCr7)zQ
        Return the standard deviation of all pixel values of this band.
        �r8rrrr�stdr#zGDALBand.stdcCs8t�}t�|j|�}|sd}|S|��tvrt|�}|S)zQ
        Return the nodata value for this band, or None if it isn't set.
        N)rr�get_band_nodata_valuer�datatyper
�int)r�
nodata_existsr+rrr�nodata_value�s�zGDALBand.nodata_valuecCsT|durtjstd��t�|j�nt|ttf�std��t�|j|�|��dS)z5
        Set the nodata value for this band.
        Nz-GDAL >= 2.1 required to delete nodata values.z%Nodata value must be numeric or None.)	r�delete_band_nodata_value�
ValueErrorr�
isinstancer@�float�set_band_nodata_valuer)rr+rrrrB�scC�t�|j�}|rt|}|S)z?
        Return the GDAL Pixel Datatype for this band.
        )r�get_band_datatyperr)r�	as_string�dtyperrrr?�szGDALBand.datatypecCrH)z3Return the GDAL color interpretation for this band.)r�get_band_color_interprr)rrJ�colorrrr�color_interp�szGDALBand.color_interpNc	Csd|pd}|p|j|d|j|df}|p|}tdd�|D��r%td��|d|jks3|d|jkr7td��t|��|d|d}|durOd}|�}nd}t|ttf�s`t	rft|t	j
�rf|�|�}n||�}t�
|j||d|d|d|dt|�|d|d|��dd�|dur�|r�t|�St	r�t	j|t	�|�d	��tt|���St|�S|��dS)
ae
        Read or writes pixel values for this band. Blocks of data can
        be accessed by specifying the width, height and offset of the
        desired block. The same specification can be used to update
        parts of a raster by providing an array of values.

        Allowed input data types are bytes, memoryview, list, tuple, and array.
        )rrrrcss�|]}|dkVqdS)rNr)�.0�xrrr�	<genexpr>�s�z GDALBand.data.<locals>.<genexpr>zOffset too big for this raster.zSize is larger than raster.N)rK)r"r%�anyrDrr?rE�bytes�
memoryviewr	�ndarray�from_buffer_copyr�band_iorr�
frombufferrK�reshape�tuple�reversed�listr)	r�data�offset�size�shape�
as_memoryview�ctypes_array�access_flag�
data_arrayrrrr]�s<	 �
��z
GDALBand.data)FF)F)NNNNF)�__name__�
__module__�__qualname__�__doc__rr�propertyrr"r%r&rr6r9r:r;r=rB�setterr?rNr]rrrrrs:




.







	rcs4eZdZ�fdd�Zdd�Zdd�Zdd�Z�ZS)	�BandListcs||_t���dSr)r�superr)rr��	__class__rrr�szBandList.__init__ccs,�tdt|�d�D]	}t|j|�Vq
dS)Nr)�range�lenrr)r�idxrrr�__iter__�s��zBandList.__iter__cCst�|jj�Sr)r�get_ds_raster_countrrrrrr�__len__�szBandList.__len__cCs.z	t|j|d�WStytd|��w)NrzUnable to get band index %d)rrr)rrrrr�__getitem__�s
�zBandList.__getitem__)rerfrgrrrrtru�
__classcell__rrrmrrk�s
rkN)�ctypesrrrr�django.contrib.gis.gdal.errorr�"django.contrib.gis.gdal.prototypesrr�#django.contrib.gis.gdal.raster.baser�django.contrib.gis.shortcutsr	�django.utils.encodingr
�constrr
rrrr\rkrrrr�<module>s_

https://t.me/RX1948 - 2025