b'\r\nGDAL/OGR in Python\r\n==================\r\n \r\nThis Python package and extensions are a number of tools for programming and \r\nmanipulating the GDAL_ Geospatial Data Abstraction Library.  Actually, it is \r\ntwo libraries -- GDAL for manipulating geospatial raster data and OGR for \r\nmanipulating geospatial vector data -- but we\'ll refer to the entire package \r\nas the GDAL library for the purposes of this document.\r\n\r\nThe GDAL project (primarily Even Rouault) maintains SWIG generated Python \r\nbindings for GDAL and OGR. Generally speaking the classes and methods mostly \r\nmatch those of the GDAL and OGR C++ classes. There is no Python specific \r\nreference documentation, but the `GDAL API Tutorial`_ includes Python examples.\r\n\r\nDependencies\r\n------------\r\n \r\n * libgdal (2.2.3 or greater) and header files (gdal-devel)\r\n * numpy (1.0.0 or greater) and header files (numpy-devel) (not explicitly \r\n   required, but many examples and utilities will not work without it)\r\n\r\nInstallation\r\n------------\r\n\r\nUnix\r\n~~~~~~~~~~~~~\r\n\r\nThe GDAL Python bindings support both distutils and setuptools, with a \r\npreference for using setuptools.  If setuptools can be imported, setup will \r\nuse that to build an egg by default.  If setuptools cannot be imported, a \r\nsimple distutils root install of the GDAL package (and no dependency \r\nchaining for numpy) will be made.  \r\n\r\neasy_install\r\n~~~~~~~~~~~~\r\n\r\nGDAL can be installed from the Python CheeseShop::\r\n\r\n  $ sudo easy_install GDAL\r\n\r\nIt may be necessary to have libgdal and its development headers installed \r\nif easy_install is expected to do a source build because no egg is available \r\nfor your specified platform and Python version.\r\n\r\nsetup.py\r\n~~~~~~~~~\r\n\r\nMost of setup.py\'s important variables are controlled with the setup.cfg \r\nfile.  In setup.cfg, you can modify pointers to include files and libraries.  \r\nThe most important option that will likely need to be modified is the \r\ngdal_config parameter.  If you installed GDAL from a package, the location \r\nof this program is likely /usr/bin/gdal-config, but it may be in another place \r\ndepending on how your packager arranged things.  \r\n\r\nAfter modifying the location of gdal-config, you can build and install \r\nwith the setup script::\r\n  \r\n  $ python setup.py build\r\n  $ python setup.py install\r\n\r\nIf you have setuptools installed, you can also generate an egg::\r\n  \r\n  $ python setup.py bdist_egg\r\n\r\nBuilding as part of the GDAL library source tree\r\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\r\n\r\nYou can also have the GDAL Python bindings built as part of a source \r\nbuild by specifying --with-python as part of your configure line::\r\n\r\n  $ ./configure --with-python\r\n\r\nUse the typical make and make install commands to complete the installation:: \r\n  \r\n  $ make\r\n  $ make install\r\n\r\nA note about setuptools\r\n.......................\r\n\r\n./configure attempts to detect if you have setuptools installed in the tree \r\nof the Python binary it was given (or detected on the execution path), and it \r\nwill use an egg build by default in that instance.  If you have a need to \r\nuse a distutils-only install, you will have to edit setup.py to ensure that \r\nthe HAVE_SETUPTOOLS variable is ultimately set to False and proceed with a \r\ntypical \'python setup.py install\' command.\r\n\r\nWindows\r\n~~~~~~~~~~~~\r\n\r\nYou will need the following items to complete an install of the GDAL Python\r\nbindings on Windows:\r\n\r\n* `GDAL Windows Binaries`_ Download the package that best matches your environment. \r\n\r\nAs explained in the README_EXE.txt file, after unzipping the GDAL binaries you \r\nwill need to modify your system path and variables. If you\'re not sure how to \r\ndo this, read the `Microsoft KnowledgeBase doc`_ \r\n\r\n1. Add the installation directory bin folder to your system PATH, remember \r\n   to put a semicolon in front of it before you add to the existing path.\r\n\r\n   ::\r\n  \r\n     C:\\gdalwin32-1.7\\bin\r\n\r\n2. Create a new user or system variable with the data folder from \r\n   your installation.\r\n\r\n   ::\r\n  \r\n     Name : GDAL_DATA\r\n     Path : C:\\gdalwin32-1.7\\data\r\n\r\nSkip down to the `Usage`_ section to test your install. Note, a reboot \r\nmay be required.\r\n\r\nSWIG\r\n----\r\n\r\nThe GDAL Python package is built using SWIG_. The earliest version of SWIG_ \r\nthat is supported to generate the wrapper code is 1.3.40.  It is possible \r\nthat usable bindings will build with a version earlier than 1.3.40, but no \r\ndevelopment efforts are targeted at versions below it.  You should not have \r\nto run SWIG in your development tree to generate the binding code, as it \r\nis usually included with the source.  However, if you do need to regenerate, \r\nyou can do so with the following make command from within the ./swig/python\r\ndirectory::\r\n\r\n  $ make generate\r\n\r\nTo ensure that all of the bindings are regenerated, you can clean the \r\nbindings code out before the generate command by issuing::\r\n\r\n  $ make veryclean\r\n\r\nUsage\r\n-----\r\n\r\nImports\r\n~~~~~~~\r\n\r\nThere are five major modules that are included with the GDAL_ Python bindings.::\r\n\r\n  >>> from osgeo import gdal\r\n  >>> from osgeo import ogr\r\n  >>> from osgeo import osr\r\n  >>> from osgeo import gdal_array\r\n  >>> from osgeo import gdalconst\r\n\r\nAdditionally, there are five compatibility modules that are included but \r\nprovide notices to state that they are deprecated and will be going away.  \r\nIf you are using GDAL 1.7 bindings, you should update your imports to utilize \r\nthe usage above, but the following will work until at least GDAL 2.1. ::\r\n\r\n  >>> import gdal\r\n  >>> import ogr\r\n  >>> import osr\r\n  >>> import gdalnumeric\r\n  >>> import gdalconst\r\n\r\nIf you have previous code that imported the global module and still need to \r\nsupport the old import, a simple try...except import can silence the \r\ndeprecation warning and keep things named essentially the same as before::\r\n\r\n  >>> try:\r\n  ...     from osgeo import gdal\r\n  ... except ImportError:\r\n  ...     import gdal\r\n\r\nDocstrings\r\n~~~~~~~~~~\r\n\r\nCurrently, only the OGR module has docstrings which are generated from the \r\nC/C++ API doxygen materials.  Some of the arguments and types might not \r\nmatch up exactly with what you are seeing from Python, but they should be \r\nenough to get you going.  Docstrings for GDAL and OSR are planned for a future \r\nrelease.\r\n\r\nNumpy/Numeric\r\n-------------\r\n\r\nOne advanced feature of the GDAL Python bindings not found in the other \r\nlanguage bindings (C#, Perl) is integration with the Python numerical array \r\nfacilities. The gdal.Dataset.ReadAsArray() method can be used to read raster \r\ndata as numerical arrays, ready to use with the Python numerical array \r\ncapabilities.\r\n\r\nThese facilities have evolved somewhat over time. In the past the package was \r\nknown as "Numeric" and imported using "import Numeric". A new generation is \r\nimported using "import numpy". Currently the old generation bindings only \r\nsupport the older Numeric package, and the new generation bindings only \r\nsupport the new generation numpy package. They are mostly compatible, and \r\nby importing gdalnumeric (or osgeo.gdal_array) you will get whichever is\r\nappropriate to the current bindings type.\r\n\r\nExamples\r\n~~~~~~~~\r\n\r\nOne example of GDAL/numpy integration is found in the `val_repl.py`_ script.\r\n\r\nPerformance Notes\r\n~~~~~~~~~~~~~~~~~\r\n\r\nReadAsArray expects to make an entire copy of a raster band or dataset unless \r\nthe data are explicitly subsetted as part of the function call. For large \r\ndata, this approach is expected to be prohibitively memory intensive.\r\n\r\n.. _GDAL API Tutorial: http://www.gdal.org/gdal_tutorial.html\r\n.. _GDAL Windows Binaries: http://gisinternals.com/sdk/\r\n.. _Microsoft Knowledge Base doc: http://support.microsoft.com/kb/310519\r\n.. _Python Cheeseshop: http://pypi.python.org/pypi/GDAL/\r\n.. _val_repl.py: http://trac.osgeo.org/gdal/browser/trunk/gdal/swig/python/samples/val_repl.py\r\n.. _GDAL: http://www.gdal.org\r\n.. _SWIG: http://www.swig.org\r\n'


