Debian Codegraph @

django/contrib/gis/gdal/raster/const.py

raw
1 """
2 GDAL - Constant definitions
3 """
4
5 from ctypes import (
6 c_double,
7 c_float,
8 c_int8,
9 c_int16,
10 c_int32,
11 c_int64,
12 c_ubyte,
13 c_uint16,
14 c_uint32,
15 c_uint64,
16 )
17
18 # See https://gdal.org/api/raster_c_api.html#_CPPv412GDALDataType
19 GDAL_PIXEL_TYPES = {
20 0: "GDT_Unknown", # Unknown or unspecified type
21 1: "GDT_Byte", # Eight bit unsigned integer
22 2: "GDT_UInt16", # Sixteen bit unsigned integer
23 3: "GDT_Int16", # Sixteen bit signed integer
24 4: "GDT_UInt32", # Thirty-two bit unsigned integer
25 5: "GDT_Int32", # Thirty-two bit signed integer
26 6: "GDT_Float32", # Thirty-two bit floating point
27 7: "GDT_Float64", # Sixty-four bit floating point
28 8: "GDT_CInt16", # Complex Int16
29 9: "GDT_CInt32", # Complex Int32
30 10: "GDT_CFloat32", # Complex Float32
31 11: "GDT_CFloat64", # Complex Float64
32 12: "GDT_UInt64", # 64 bit unsigned integer (GDAL 3.5+).
33 13: "GDT_Int64", # 64 bit signed integer (GDAL 3.5+).
34 14: "GDT_Int8", # 8 bit signed integer (GDAL 3.7+).
35 }
36
37 # A list of gdal datatypes that are integers.
38 GDAL_INTEGER_TYPES = [1, 2, 3, 4, 5, 12, 13, 14]
39
40 # Lookup values to convert GDAL pixel type indices into ctypes objects.
41 # The GDAL band-io works with ctypes arrays to hold data to be written
42 # or to hold the space for data to be read into. The lookup below helps
43 # selecting the right ctypes object for a given gdal pixel type.
44 GDAL_TO_CTYPES = [
45 None,
46 c_ubyte,
47 c_uint16,
48 c_int16,
49 c_uint32,
50 c_int32,
51 c_float,
52 c_double,
53 None,
54 None,
55 None,
56 None,
57 c_uint64,
58 c_int64,
59 c_int8,
60 ]
61
62 # List of resampling algorithms that can be used to warp a GDALRaster.
63 GDAL_RESAMPLE_ALGORITHMS = {
64 "NearestNeighbour": 0,
65 "Bilinear": 1,
66 "Cubic": 2,
67 "CubicSpline": 3,
68 "Lanczos": 4,
69 "Average": 5,
70 "Mode": 6,
71 }
72
73 # See https://gdal.org/api/raster_c_api.html#_CPPv415GDALColorInterp
74 GDAL_COLOR_TYPES = {
75 0: "GCI_Undefined", # Undefined, default value, i.e. not known
76 1: "GCI_GrayIndex", # Grayscale
77 2: "GCI_PaletteIndex", # Paletted
78 3: "GCI_RedBand", # Red band of RGBA image
79 4: "GCI_GreenBand", # Green band of RGBA image
80 5: "GCI_BlueBand", # Blue band of RGBA image
81 6: "GCI_AlphaBand", # Alpha (0=transparent, 255=opaque)
82 7: "GCI_HueBand", # Hue band of HLS image
83 8: "GCI_SaturationBand", # Saturation band of HLS image
84 9: "GCI_LightnessBand", # Lightness band of HLS image
85 10: "GCI_CyanBand", # Cyan band of CMYK image
86 11: "GCI_MagentaBand", # Magenta band of CMYK image
87 12: "GCI_YellowBand", # Yellow band of CMYK image
88 13: "GCI_BlackBand", # Black band of CMLY image
89 14: "GCI_YCbCr_YBand", # Y Luminance
90 15: "GCI_YCbCr_CbBand", # Cb Chroma
91 16: "GCI_YCbCr_CrBand", # Cr Chroma, also GCI_Max
92 }
93
94 # GDAL virtual filesystems prefix.
95 VSI_FILESYSTEM_PREFIX = "/vsi"
96
97 # Fixed base path for buffer-based GDAL in-memory files.
98 VSI_MEM_FILESYSTEM_BASE_PATH = "/vsimem/"
99
100 # Should the memory file system take ownership of the buffer, freeing it when
101 # the file is deleted? (No, GDALRaster.__del__() will delete the buffer.)
102 VSI_TAKE_BUFFER_OWNERSHIP = False
103
104 # Should a VSI file be removed when retrieving its buffer?
105 VSI_DELETE_BUFFER_ON_READ = False