__init__.py 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. """
  2. This module houses ctypes interfaces for GDAL objects. The following GDAL
  3. objects are supported:
  4. CoordTransform: Used for coordinate transformations from one spatial
  5. reference system to another.
  6. Driver: Wraps an OGR data source driver.
  7. DataSource: Wrapper for the OGR data source object, supports
  8. OGR-supported data sources.
  9. Envelope: A ctypes structure for bounding boxes (GDAL library
  10. not required).
  11. OGRGeometry: Object for accessing OGR Geometry functionality.
  12. OGRGeomType: A class for representing the different OGR Geometry
  13. types (GDAL library not required).
  14. SpatialReference: Represents OSR Spatial Reference objects.
  15. The GDAL library will be imported from the system path using the default
  16. library name for the current OS. The default library path may be overridden
  17. by setting `GDAL_LIBRARY_PATH` in your settings with the path to the GDAL C
  18. library on your system.
  19. GDAL links to a large number of external libraries that consume RAM when
  20. loaded. Thus, it may desirable to disable GDAL on systems with limited
  21. RAM resources -- this may be accomplished by setting `GDAL_LIBRARY_PATH`
  22. to a non-existent file location (e.g., `GDAL_LIBRARY_PATH='/null/path'`;
  23. setting to None/False/'' will not work as a string must be given).
  24. """
  25. from django.contrib.gis.gdal.error import (check_err, GDALException,
  26. OGRException, OGRIndexError, SRSException) # NOQA
  27. from django.contrib.gis.gdal.geomtype import OGRGeomType # NOQA
  28. __all__ = [
  29. 'check_err', 'GDALException', 'OGRException', 'OGRIndexError',
  30. 'SRSException', 'OGRGeomType', 'HAS_GDAL',
  31. ]
  32. # Attempting to import objects that depend on the GDAL library. The
  33. # HAS_GDAL flag will be set to True if the library is present on
  34. # the system.
  35. try:
  36. from django.contrib.gis.gdal.driver import Driver # NOQA
  37. from django.contrib.gis.gdal.datasource import DataSource # NOQA
  38. from django.contrib.gis.gdal.libgdal import gdal_version, gdal_full_version, GDAL_VERSION # NOQA
  39. from django.contrib.gis.gdal.raster.source import GDALRaster # NOQA
  40. from django.contrib.gis.gdal.srs import SpatialReference, CoordTransform # NOQA
  41. from django.contrib.gis.gdal.geometries import OGRGeometry # NOQA
  42. HAS_GDAL = True
  43. __all__ += [
  44. 'Driver', 'DataSource', 'gdal_version', 'gdal_full_version',
  45. 'GDAL_VERSION', 'SpatialReference', 'CoordTransform', 'OGRGeometry',
  46. ]
  47. except GDALException:
  48. HAS_GDAL = False
  49. try:
  50. from django.contrib.gis.gdal.envelope import Envelope
  51. __all__ += ['Envelope']
  52. except ImportError:
  53. # No ctypes, but don't raise an exception.
  54. pass