You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

const.py 2.8KB

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