const.py 3.2 KB

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