GDAL 3.11.5__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (138) hide show
  1. gdal-3.11.5/PKG-INFO +253 -0
  2. gdal-3.11.5/README.rst +219 -0
  3. gdal-3.11.5/extensions/gdal_array_wrap.cpp +8724 -0
  4. gdal-3.11.5/extensions/gdal_wrap.cpp +67387 -0
  5. gdal-3.11.5/extensions/gdalconst_wrap.c +4052 -0
  6. gdal-3.11.5/extensions/gnm_wrap.cpp +7293 -0
  7. gdal-3.11.5/extensions/ogr_wrap.cpp +41876 -0
  8. gdal-3.11.5/extensions/osr_wrap.cpp +22798 -0
  9. gdal-3.11.5/gdal-utils/GDAL.egg-info/PKG-INFO +253 -0
  10. gdal-3.11.5/gdal-utils/GDAL.egg-info/SOURCES.txt +136 -0
  11. gdal-3.11.5/gdal-utils/GDAL.egg-info/dependency_links.txt +1 -0
  12. gdal-3.11.5/gdal-utils/GDAL.egg-info/entry_points.txt +19 -0
  13. gdal-3.11.5/gdal-utils/GDAL.egg-info/not-zip-safe +1 -0
  14. gdal-3.11.5/gdal-utils/GDAL.egg-info/requires.txt +3 -0
  15. gdal-3.11.5/gdal-utils/GDAL.egg-info/top_level.txt +2 -0
  16. gdal-3.11.5/gdal-utils/osgeo_utils/__init__.py +12 -0
  17. gdal-3.11.5/gdal-utils/osgeo_utils/auxiliary/__init__.py +0 -0
  18. gdal-3.11.5/gdal-utils/osgeo_utils/auxiliary/array_util.py +60 -0
  19. gdal-3.11.5/gdal-utils/osgeo_utils/auxiliary/base.py +108 -0
  20. gdal-3.11.5/gdal-utils/osgeo_utils/auxiliary/batch_creator.py +74 -0
  21. gdal-3.11.5/gdal-utils/osgeo_utils/auxiliary/color_palette.py +413 -0
  22. gdal-3.11.5/gdal-utils/osgeo_utils/auxiliary/color_table.py +133 -0
  23. gdal-3.11.5/gdal-utils/osgeo_utils/auxiliary/extent_util.py +134 -0
  24. gdal-3.11.5/gdal-utils/osgeo_utils/auxiliary/gdal_argparse.py +235 -0
  25. gdal-3.11.5/gdal-utils/osgeo_utils/auxiliary/numpy_util.py +57 -0
  26. gdal-3.11.5/gdal-utils/osgeo_utils/auxiliary/osr_util.py +132 -0
  27. gdal-3.11.5/gdal-utils/osgeo_utils/auxiliary/progress.py +73 -0
  28. gdal-3.11.5/gdal-utils/osgeo_utils/auxiliary/raster_creation.py +170 -0
  29. gdal-3.11.5/gdal-utils/osgeo_utils/auxiliary/rectangle.py +280 -0
  30. gdal-3.11.5/gdal-utils/osgeo_utils/auxiliary/util.py +464 -0
  31. gdal-3.11.5/gdal-utils/osgeo_utils/gdal2tiles.py +4665 -0
  32. gdal-3.11.5/gdal-utils/osgeo_utils/gdal2xyz.py +427 -0
  33. gdal-3.11.5/gdal-utils/osgeo_utils/gdal_calc.py +928 -0
  34. gdal-3.11.5/gdal-utils/osgeo_utils/gdal_edit.py +517 -0
  35. gdal-3.11.5/gdal-utils/osgeo_utils/gdal_fillnodata.py +277 -0
  36. gdal-3.11.5/gdal-utils/osgeo_utils/gdal_merge.py +660 -0
  37. gdal-3.11.5/gdal-utils/osgeo_utils/gdal_pansharpen.py +351 -0
  38. gdal-3.11.5/gdal-utils/osgeo_utils/gdal_polygonize.py +346 -0
  39. gdal-3.11.5/gdal-utils/osgeo_utils/gdal_proximity.py +227 -0
  40. gdal-3.11.5/gdal-utils/osgeo_utils/gdal_retile.py +1224 -0
  41. gdal-3.11.5/gdal-utils/osgeo_utils/gdal_sieve.py +206 -0
  42. gdal-3.11.5/gdal-utils/osgeo_utils/gdalattachpct.py +150 -0
  43. gdal-3.11.5/gdal-utils/osgeo_utils/gdalcompare.py +561 -0
  44. gdal-3.11.5/gdal-utils/osgeo_utils/gdalmove.py +291 -0
  45. gdal-3.11.5/gdal-utils/osgeo_utils/ogr_layer_algebra.py +563 -0
  46. gdal-3.11.5/gdal-utils/osgeo_utils/ogrmerge.py +1212 -0
  47. gdal-3.11.5/gdal-utils/osgeo_utils/pct2rgb.py +218 -0
  48. gdal-3.11.5/gdal-utils/osgeo_utils/rgb2pct.py +217 -0
  49. gdal-3.11.5/gdal-utils/osgeo_utils/samples/__init__.py +0 -0
  50. gdal-3.11.5/gdal-utils/osgeo_utils/samples/assemblepoly.py +119 -0
  51. gdal-3.11.5/gdal-utils/osgeo_utils/samples/build_jp2_from_xml.py +493 -0
  52. gdal-3.11.5/gdal-utils/osgeo_utils/samples/classify.py +67 -0
  53. gdal-3.11.5/gdal-utils/osgeo_utils/samples/crs2crs2grid.py +414 -0
  54. gdal-3.11.5/gdal-utils/osgeo_utils/samples/densify.py +502 -0
  55. gdal-3.11.5/gdal-utils/osgeo_utils/samples/dump_jp2.py +207 -0
  56. gdal-3.11.5/gdal-utils/osgeo_utils/samples/epsg_tr.py +274 -0
  57. gdal-3.11.5/gdal-utils/osgeo_utils/samples/esri2wkt.py +83 -0
  58. gdal-3.11.5/gdal-utils/osgeo_utils/samples/fft.py +134 -0
  59. gdal-3.11.5/gdal-utils/osgeo_utils/samples/fix_gpkg.py +71 -0
  60. gdal-3.11.5/gdal-utils/osgeo_utils/samples/gcps2ogr.py +71 -0
  61. gdal-3.11.5/gdal-utils/osgeo_utils/samples/gcps2vec.py +166 -0
  62. gdal-3.11.5/gdal-utils/osgeo_utils/samples/gcps2wld.py +54 -0
  63. gdal-3.11.5/gdal-utils/osgeo_utils/samples/gdal2grd.py +151 -0
  64. gdal-3.11.5/gdal-utils/osgeo_utils/samples/gdal_auth.py +121 -0
  65. gdal-3.11.5/gdal-utils/osgeo_utils/samples/gdal_cp.py +246 -0
  66. gdal-3.11.5/gdal-utils/osgeo_utils/samples/gdal_create_pdf.py +58 -0
  67. gdal-3.11.5/gdal-utils/osgeo_utils/samples/gdal_ls.py +279 -0
  68. gdal-3.11.5/gdal-utils/osgeo_utils/samples/gdal_lut.py +221 -0
  69. gdal-3.11.5/gdal-utils/osgeo_utils/samples/gdal_minmax_location.py +128 -0
  70. gdal-3.11.5/gdal-utils/osgeo_utils/samples/gdal_mkdir.py +56 -0
  71. gdal-3.11.5/gdal-utils/osgeo_utils/samples/gdal_remove_towgs84.py +104 -0
  72. gdal-3.11.5/gdal-utils/osgeo_utils/samples/gdal_rm.py +113 -0
  73. gdal-3.11.5/gdal-utils/osgeo_utils/samples/gdal_rmdir.py +62 -0
  74. gdal-3.11.5/gdal-utils/osgeo_utils/samples/gdal_vrtmerge.py +367 -0
  75. gdal-3.11.5/gdal-utils/osgeo_utils/samples/gdalbuildvrtofvrt.py +301 -0
  76. gdal-3.11.5/gdal-utils/osgeo_utils/samples/gdalchksum.py +89 -0
  77. gdal-3.11.5/gdal-utils/osgeo_utils/samples/gdalcopyproj.py +65 -0
  78. gdal-3.11.5/gdal-utils/osgeo_utils/samples/gdalfilter.py +176 -0
  79. gdal-3.11.5/gdal-utils/osgeo_utils/samples/gdalident.py +84 -0
  80. gdal-3.11.5/gdal-utils/osgeo_utils/samples/gdalimport.py +78 -0
  81. gdal-3.11.5/gdal-utils/osgeo_utils/samples/gdalinfo.py +617 -0
  82. gdal-3.11.5/gdal-utils/osgeo_utils/samples/gdallocationinfo.py +561 -0
  83. gdal-3.11.5/gdal-utils/osgeo_utils/samples/get_soundg.py +109 -0
  84. gdal-3.11.5/gdal-utils/osgeo_utils/samples/histrep.py +96 -0
  85. gdal-3.11.5/gdal-utils/osgeo_utils/samples/hsv_merge.py +235 -0
  86. gdal-3.11.5/gdal-utils/osgeo_utils/samples/jpeg_in_tiff_extract.py +298 -0
  87. gdal-3.11.5/gdal-utils/osgeo_utils/samples/load2odbc.py +181 -0
  88. gdal-3.11.5/gdal-utils/osgeo_utils/samples/loslas2ntv2.py +268 -0
  89. gdal-3.11.5/gdal-utils/osgeo_utils/samples/magphase.py +63 -0
  90. gdal-3.11.5/gdal-utils/osgeo_utils/samples/make_fuzzer_friendly_archive.py +38 -0
  91. gdal-3.11.5/gdal-utils/osgeo_utils/samples/mkgraticule.py +228 -0
  92. gdal-3.11.5/gdal-utils/osgeo_utils/samples/ogr2vrt.py +336 -0
  93. gdal-3.11.5/gdal-utils/osgeo_utils/samples/ogr_build_junction_table.py +214 -0
  94. gdal-3.11.5/gdal-utils/osgeo_utils/samples/ogr_dispatch.py +397 -0
  95. gdal-3.11.5/gdal-utils/osgeo_utils/samples/ogrinfo.py +557 -0
  96. gdal-3.11.5/gdal-utils/osgeo_utils/samples/ogrupdate.py +552 -0
  97. gdal-3.11.5/gdal-utils/osgeo_utils/samples/rel.py +241 -0
  98. gdal-3.11.5/gdal-utils/osgeo_utils/samples/tigerpoly.py +235 -0
  99. gdal-3.11.5/gdal-utils/osgeo_utils/samples/tile_extent_from_raster.py +102 -0
  100. gdal-3.11.5/gdal-utils/osgeo_utils/samples/tolatlong.py +103 -0
  101. gdal-3.11.5/gdal-utils/osgeo_utils/samples/val_repl.py +125 -0
  102. gdal-3.11.5/gdal-utils/osgeo_utils/samples/validate_cloud_optimized_geotiff.py +564 -0
  103. gdal-3.11.5/gdal-utils/osgeo_utils/samples/validate_geoparquet.py +535 -0
  104. gdal-3.11.5/gdal-utils/osgeo_utils/samples/validate_gpkg.py +3028 -0
  105. gdal-3.11.5/gdal-utils/osgeo_utils/samples/validate_jp2.py +1736 -0
  106. gdal-3.11.5/gdal-utils/osgeo_utils/samples/vec_tr.py +149 -0
  107. gdal-3.11.5/gdal-utils/osgeo_utils/samples/vec_tr_spat.py +140 -0
  108. gdal-3.11.5/gdal-utils/osgeo_utils/samples/wcs_virtds_params.py +218 -0
  109. gdal-3.11.5/gdal-utils/scripts/gdal2tiles.py +15 -0
  110. gdal-3.11.5/gdal-utils/scripts/gdal2xyz.py +12 -0
  111. gdal-3.11.5/gdal-utils/scripts/gdal_calc.py +12 -0
  112. gdal-3.11.5/gdal-utils/scripts/gdal_edit.py +12 -0
  113. gdal-3.11.5/gdal-utils/scripts/gdal_fillnodata.py +12 -0
  114. gdal-3.11.5/gdal-utils/scripts/gdal_merge.py +12 -0
  115. gdal-3.11.5/gdal-utils/scripts/gdal_pansharpen.py +12 -0
  116. gdal-3.11.5/gdal-utils/scripts/gdal_polygonize.py +12 -0
  117. gdal-3.11.5/gdal-utils/scripts/gdal_proximity.py +12 -0
  118. gdal-3.11.5/gdal-utils/scripts/gdal_retile.py +12 -0
  119. gdal-3.11.5/gdal-utils/scripts/gdal_sieve.py +12 -0
  120. gdal-3.11.5/gdal-utils/scripts/gdalattachpct.py +12 -0
  121. gdal-3.11.5/gdal-utils/scripts/gdalcompare.py +12 -0
  122. gdal-3.11.5/gdal-utils/scripts/gdalmove.py +12 -0
  123. gdal-3.11.5/gdal-utils/scripts/ogr_layer_algebra.py +12 -0
  124. gdal-3.11.5/gdal-utils/scripts/ogrmerge.py +12 -0
  125. gdal-3.11.5/gdal-utils/scripts/pct2rgb.py +12 -0
  126. gdal-3.11.5/gdal-utils/scripts/rgb2pct.py +12 -0
  127. gdal-3.11.5/osgeo/__init__.py +109 -0
  128. gdal-3.11.5/osgeo/gdal.py +11047 -0
  129. gdal-3.11.5/osgeo/gdal_array.py +912 -0
  130. gdal-3.11.5/osgeo/gdal_fsspec.py +236 -0
  131. gdal-3.11.5/osgeo/gdalconst.py +324 -0
  132. gdal-3.11.5/osgeo/gdalnumeric.py +7 -0
  133. gdal-3.11.5/osgeo/gnm.py +410 -0
  134. gdal-3.11.5/osgeo/ogr.py +7446 -0
  135. gdal-3.11.5/osgeo/osr.py +2473 -0
  136. gdal-3.11.5/pyproject.toml +44 -0
  137. gdal-3.11.5/setup.cfg +4 -0
  138. gdal-3.11.5/setup.py +480 -0
gdal-3.11.5/PKG-INFO ADDED
@@ -0,0 +1,253 @@
1
+ Metadata-Version: 2.4
2
+ Name: GDAL
3
+ Version: 3.11.5
4
+ Summary: GDAL: Geospatial Data Abstraction Library
5
+ Home-page: http://www.gdal.org
6
+ Author: Frank Warmerdam, Howard Butler, Even Rouault
7
+ Author-email: warmerdam@pobox.com
8
+ Maintainer: GDAL contributors
9
+ Maintainer-email: GDAL contributors <gdal-dev@lists.osgeo.org>
10
+ License-Expression: MIT
11
+ Project-URL: Homepage, https://gdal.org
12
+ Project-URL: Documentation, https://gdal.org
13
+ Project-URL: Repository, https://github.com/OSGeo/GDAL.git
14
+ Project-URL: Changelog, https://github.com/OSGeo/gdal/blob/master/NEWS.md
15
+ Project-URL: Issues, https://github.com/OSGeo/gdal/issues
16
+ Keywords: gis,raster,vector
17
+ Classifier: Development Status :: 5 - Production/Stable
18
+ Classifier: Intended Audience :: Developers
19
+ Classifier: Intended Audience :: Science/Research
20
+ Classifier: Operating System :: OS Independent
21
+ Classifier: Programming Language :: Python :: 3
22
+ Classifier: Programming Language :: C
23
+ Classifier: Programming Language :: C++
24
+ Classifier: Topic :: Scientific/Engineering :: GIS
25
+ Classifier: Topic :: Scientific/Engineering :: Information Analysis
26
+ Requires-Python: >=3.8.0
27
+ Description-Content-Type: text/x-rst
28
+ Provides-Extra: numpy
29
+ Requires-Dist: numpy>1.0.0; extra == "numpy"
30
+ Dynamic: author-email
31
+ Dynamic: home-page
32
+ Dynamic: maintainer
33
+ Dynamic: requires-python
34
+
35
+
36
+ GDAL/OGR in Python
37
+ ==================
38
+
39
+ This Python package and extensions are a number of tools for programming and
40
+ manipulating the GDAL_ Geospatial Data Abstraction Library.
41
+ Generally speaking the classes and methods mostly
42
+ match those of the GDAL and OGR C++ classes. There is no Python specific
43
+ reference documentation, but the https://gdal.org/api/python_bindings.html#tutorials includes Python examples.
44
+
45
+ The GDAL Python package is built using `SWIG <https://www.swig.org>`__.
46
+ The GDAL project maintains these Python bindings for GDAL/OGR within
47
+ the gdal source tree.
48
+ The SWIG-generated files are not checked in and are not part of the
49
+ gdal release tarballs. The bindings are also made available via PyPi
50
+ where the swig-generated files are provided.
51
+
52
+ Building from source
53
+ --------------------
54
+
55
+ To build from source, there are multiple possible paths.
56
+
57
+ Dependencies
58
+ ~~~~~~~~~~~~
59
+
60
+ (As usual, when a package is listed one needs the parts used to build
61
+ programs against it, called -devel on many systems. This is not
62
+ special about gdal.)
63
+
64
+ * SWIG (4 or greater).
65
+
66
+ * libgdal (3.11.5 or greater).
67
+
68
+ * numpy (1.0.0 or greater). This is not force-required by the build,
69
+ but many examples and utilities will not work without it. At least
70
+ osgeo.gdal_array requires numpy at build time; building without
71
+ numpy and installing it later does not result in correct operation.
72
+ apparently not and in any case it is an unwarranted leap.
73
+
74
+ * setuptools (python)
75
+
76
+ * wheel (python)
77
+
78
+ Building when building the rest of GDAL
79
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
80
+
81
+ Python bindings are generated by default when building GDAL from source.
82
+ For more detail, see `Python bindings options <https://gdal.org/development/building_from_source.html#building-python-bindings>`__
83
+
84
+ Building just the bindings, from the full tree
85
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
86
+
87
+ Another is to use the gdal source distribution with an
88
+ already-installed gdal library and headers. To do this, one must
89
+ create a build directory and run cmake to generate build scripts. Then,
90
+ run ``cmake --build . --target python_generated_files``. Finally, in swig/python,
91
+ one can build using setup.py like any other distributed python module.
92
+
93
+ Building from the PyPi module file
94
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
95
+
96
+ The third is to obtain the PyPi-hosted module file, within which swig
97
+ has been run; this saves running cmake and generating bindings. See
98
+ HOWTO-RELEASE for how this is created. Because swig has been run, it
99
+ need not be installed.
100
+
101
+
102
+ Installation via packging systems
103
+ ---------------------------------
104
+
105
+ General
106
+ ~~~~~~~
107
+
108
+ Many packaging systems (on GNU/Linux, various BSDs) provide the
109
+ bindings as a package. Specific instruction are given in cases when
110
+ that hint might not be sufficient.
111
+
112
+ pip
113
+ ~~~
114
+
115
+ Due to the complex nature of GDAL and its components, different bindings may require additional packages and installation steps.
116
+ GDAL can be installed from the `Python Package Index <https://pypi.org/project/GDAL>`__:
117
+
118
+ ::
119
+
120
+ pip install gdal
121
+
122
+
123
+ In order to enable numpy-based raster support, libgdal and its development headers must be installed as well as the Python packages numpy, setuptools, and wheel.
124
+ To install the Python dependencies and build numpy-based raster support:
125
+
126
+
127
+ ::
128
+
129
+ pip install numpy>1.0.0 wheel setuptools>=67
130
+ pip install gdal[numpy]=="$(gdal-config --version).*"
131
+
132
+
133
+ Users can verify that numpy-based raster support has been installed with:
134
+
135
+ ::
136
+
137
+ python3 -c 'from osgeo import gdal_array'
138
+
139
+
140
+ If this command raises an ImportError, numpy-based raster support has not been properly installed:
141
+
142
+ ::
143
+
144
+ Traceback (most recent call last):
145
+ File "<string>", line 1, in <module>
146
+ File "/usr/local/lib/python3.12/dist-packages/osgeo/gdal_array.py", line 10, in <module>
147
+ from . import _gdal_array
148
+ ImportError: cannot import name '_gdal_array' from 'osgeo' (/usr/local/lib/python3.12/dist-packages/osgeo/__init__.py)
149
+
150
+
151
+ This is most often due to pip reusing a cached GDAL installation.
152
+ Verify that the necessary dependencies have been installed and then run the following to force a clean build:
153
+
154
+ ::
155
+
156
+ pip install --no-cache --force-reinstall gdal[numpy]=="$(gdal-config --version).*"
157
+
158
+
159
+ Potential issues with GDAL >= 3.9, Python >= 3.9 and NumPy 2.0 (pip)
160
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
161
+
162
+ The pyproject.toml file of GDAL 3.9 requires numpy >= 2.0.0rc1 (for Python >= 3.9)
163
+ at build time to be able to build bindings that are compatible of both NumPy 1
164
+ and NumPy 2.
165
+ If for some reason the numpy >= 2.0.0rc1 build dependency can not be installed,
166
+ it is possible to manually install the build requirements, and invoke ``pip install``
167
+ with the ``--no-build-isolation`` flag.
168
+
169
+ ::
170
+
171
+ pip install numpy==<required_version> wheel setuptools>=67
172
+ pip install gdal[numpy]=="$(gdal-config --version).*" --no-build-isolation
173
+
174
+
175
+ Conda
176
+ ~~~~~
177
+
178
+ GDAL can be quite complex to build and install, particularly on Windows and MacOS.
179
+ Pre built binaries are provided for the conda system:
180
+
181
+ https://docs.conda.io/en/latest/
182
+
183
+ By the conda-forge project:
184
+
185
+ https://conda-forge.org/
186
+
187
+ Once you have Anaconda or Miniconda installed, you should be able to install GDAL with:
188
+
189
+ ``conda install -c conda-forge gdal``
190
+
191
+
192
+
193
+ Usage
194
+ -----
195
+
196
+ Imports
197
+ ~~~~~~~
198
+
199
+ There are five major modules that are included with the GDAL_ Python bindings.::
200
+
201
+ >>> from osgeo import gdal
202
+ >>> from osgeo import ogr
203
+ >>> from osgeo import osr
204
+ >>> from osgeo import gdal_array
205
+ >>> from osgeo import gdalconst
206
+
207
+ API
208
+ ~~~
209
+
210
+ API documentation is available at https://gdal.org/api/python/osgeo.html
211
+
212
+ Numpy
213
+ -----
214
+
215
+ One advanced feature of the GDAL Python bindings not found in the other
216
+ language bindings is integration with the Python numerical array
217
+ facilities. The gdal.Dataset.ReadAsArray() method can be used to read raster
218
+ data as numerical arrays, ready to use with the Python numerical array
219
+ capabilities.
220
+
221
+ Tutorials
222
+ ---------
223
+
224
+ See https://gdal.org/api/python_bindings.html#tutorials
225
+
226
+ Gotchas
227
+ -------
228
+
229
+ Although GDAL's and OGR's Python bindings provide a fairly "Pythonic" wrapper around the underlying C++ code, there are several ways in which the Python bindings differ from typical Python libraries.
230
+ These differences can catch Python programmers by surprise and lead to unexpected results. These differences result from the complexity of developing a large, long-lived library while continuing to maintain
231
+ backward compatibility. They are being addressed over time, but until they are all gone, please review this list of https://gdal.org/api/python_gotchas.html
232
+
233
+ Examples
234
+ --------
235
+
236
+ * An assortment of other samples are available in the `Python github samples directory <https://github.com/OSGeo/gdal/tree/master/swig/python/gdal-utils/osgeo_utils/samples>`__
237
+ with some description in the https://gdal.org/api/python_bindings.html#examples.
238
+ * Several `GDAL utilities <https://github.com/OSGeo/gdal/tree/master/swig/python/gdal-utils/osgeo_utils/>`__
239
+ are implemented in Python and can be useful examples.
240
+ * The majority of GDAL regression tests are written in Python. They are available at
241
+ `https://github.com/OSGeo/gdal/tree/master/autotest <https://github.com/OSGeo/gdal/tree/master/autotest>`__
242
+
243
+ One example of GDAL/numpy integration is found in the `val_repl.py <https://github.com/OSGeo/gdal/tree/master/swig/python/gdal-utils/osgeo_utils/samples/val_repl.py>`__ script.
244
+
245
+ .. note::
246
+ **Performance Notes**
247
+
248
+ ReadAsArray expects to make an entire copy of a raster band or dataset
249
+ unless the data are explicitly subsetted as part of the function call. For
250
+ large data, this approach is expected to be prohibitively memory intensive.
251
+
252
+
253
+ .. _GDAL: https://gdal.org
gdal-3.11.5/README.rst ADDED
@@ -0,0 +1,219 @@
1
+
2
+ GDAL/OGR in Python
3
+ ==================
4
+
5
+ This Python package and extensions are a number of tools for programming and
6
+ manipulating the GDAL_ Geospatial Data Abstraction Library.
7
+ Generally speaking the classes and methods mostly
8
+ match those of the GDAL and OGR C++ classes. There is no Python specific
9
+ reference documentation, but the https://gdal.org/api/python_bindings.html#tutorials includes Python examples.
10
+
11
+ The GDAL Python package is built using `SWIG <https://www.swig.org>`__.
12
+ The GDAL project maintains these Python bindings for GDAL/OGR within
13
+ the gdal source tree.
14
+ The SWIG-generated files are not checked in and are not part of the
15
+ gdal release tarballs. The bindings are also made available via PyPi
16
+ where the swig-generated files are provided.
17
+
18
+ Building from source
19
+ --------------------
20
+
21
+ To build from source, there are multiple possible paths.
22
+
23
+ Dependencies
24
+ ~~~~~~~~~~~~
25
+
26
+ (As usual, when a package is listed one needs the parts used to build
27
+ programs against it, called -devel on many systems. This is not
28
+ special about gdal.)
29
+
30
+ * SWIG (4 or greater).
31
+
32
+ * libgdal (3.11.5 or greater).
33
+
34
+ * numpy (1.0.0 or greater). This is not force-required by the build,
35
+ but many examples and utilities will not work without it. At least
36
+ osgeo.gdal_array requires numpy at build time; building without
37
+ numpy and installing it later does not result in correct operation.
38
+ apparently not and in any case it is an unwarranted leap.
39
+
40
+ * setuptools (python)
41
+
42
+ * wheel (python)
43
+
44
+ Building when building the rest of GDAL
45
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
46
+
47
+ Python bindings are generated by default when building GDAL from source.
48
+ For more detail, see `Python bindings options <https://gdal.org/development/building_from_source.html#building-python-bindings>`__
49
+
50
+ Building just the bindings, from the full tree
51
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
52
+
53
+ Another is to use the gdal source distribution with an
54
+ already-installed gdal library and headers. To do this, one must
55
+ create a build directory and run cmake to generate build scripts. Then,
56
+ run ``cmake --build . --target python_generated_files``. Finally, in swig/python,
57
+ one can build using setup.py like any other distributed python module.
58
+
59
+ Building from the PyPi module file
60
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
61
+
62
+ The third is to obtain the PyPi-hosted module file, within which swig
63
+ has been run; this saves running cmake and generating bindings. See
64
+ HOWTO-RELEASE for how this is created. Because swig has been run, it
65
+ need not be installed.
66
+
67
+
68
+ Installation via packging systems
69
+ ---------------------------------
70
+
71
+ General
72
+ ~~~~~~~
73
+
74
+ Many packaging systems (on GNU/Linux, various BSDs) provide the
75
+ bindings as a package. Specific instruction are given in cases when
76
+ that hint might not be sufficient.
77
+
78
+ pip
79
+ ~~~
80
+
81
+ Due to the complex nature of GDAL and its components, different bindings may require additional packages and installation steps.
82
+ GDAL can be installed from the `Python Package Index <https://pypi.org/project/GDAL>`__:
83
+
84
+ ::
85
+
86
+ pip install gdal
87
+
88
+
89
+ In order to enable numpy-based raster support, libgdal and its development headers must be installed as well as the Python packages numpy, setuptools, and wheel.
90
+ To install the Python dependencies and build numpy-based raster support:
91
+
92
+
93
+ ::
94
+
95
+ pip install numpy>1.0.0 wheel setuptools>=67
96
+ pip install gdal[numpy]=="$(gdal-config --version).*"
97
+
98
+
99
+ Users can verify that numpy-based raster support has been installed with:
100
+
101
+ ::
102
+
103
+ python3 -c 'from osgeo import gdal_array'
104
+
105
+
106
+ If this command raises an ImportError, numpy-based raster support has not been properly installed:
107
+
108
+ ::
109
+
110
+ Traceback (most recent call last):
111
+ File "<string>", line 1, in <module>
112
+ File "/usr/local/lib/python3.12/dist-packages/osgeo/gdal_array.py", line 10, in <module>
113
+ from . import _gdal_array
114
+ ImportError: cannot import name '_gdal_array' from 'osgeo' (/usr/local/lib/python3.12/dist-packages/osgeo/__init__.py)
115
+
116
+
117
+ This is most often due to pip reusing a cached GDAL installation.
118
+ Verify that the necessary dependencies have been installed and then run the following to force a clean build:
119
+
120
+ ::
121
+
122
+ pip install --no-cache --force-reinstall gdal[numpy]=="$(gdal-config --version).*"
123
+
124
+
125
+ Potential issues with GDAL >= 3.9, Python >= 3.9 and NumPy 2.0 (pip)
126
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
127
+
128
+ The pyproject.toml file of GDAL 3.9 requires numpy >= 2.0.0rc1 (for Python >= 3.9)
129
+ at build time to be able to build bindings that are compatible of both NumPy 1
130
+ and NumPy 2.
131
+ If for some reason the numpy >= 2.0.0rc1 build dependency can not be installed,
132
+ it is possible to manually install the build requirements, and invoke ``pip install``
133
+ with the ``--no-build-isolation`` flag.
134
+
135
+ ::
136
+
137
+ pip install numpy==<required_version> wheel setuptools>=67
138
+ pip install gdal[numpy]=="$(gdal-config --version).*" --no-build-isolation
139
+
140
+
141
+ Conda
142
+ ~~~~~
143
+
144
+ GDAL can be quite complex to build and install, particularly on Windows and MacOS.
145
+ Pre built binaries are provided for the conda system:
146
+
147
+ https://docs.conda.io/en/latest/
148
+
149
+ By the conda-forge project:
150
+
151
+ https://conda-forge.org/
152
+
153
+ Once you have Anaconda or Miniconda installed, you should be able to install GDAL with:
154
+
155
+ ``conda install -c conda-forge gdal``
156
+
157
+
158
+
159
+ Usage
160
+ -----
161
+
162
+ Imports
163
+ ~~~~~~~
164
+
165
+ There are five major modules that are included with the GDAL_ Python bindings.::
166
+
167
+ >>> from osgeo import gdal
168
+ >>> from osgeo import ogr
169
+ >>> from osgeo import osr
170
+ >>> from osgeo import gdal_array
171
+ >>> from osgeo import gdalconst
172
+
173
+ API
174
+ ~~~
175
+
176
+ API documentation is available at https://gdal.org/api/python/osgeo.html
177
+
178
+ Numpy
179
+ -----
180
+
181
+ One advanced feature of the GDAL Python bindings not found in the other
182
+ language bindings is integration with the Python numerical array
183
+ facilities. The gdal.Dataset.ReadAsArray() method can be used to read raster
184
+ data as numerical arrays, ready to use with the Python numerical array
185
+ capabilities.
186
+
187
+ Tutorials
188
+ ---------
189
+
190
+ See https://gdal.org/api/python_bindings.html#tutorials
191
+
192
+ Gotchas
193
+ -------
194
+
195
+ Although GDAL's and OGR's Python bindings provide a fairly "Pythonic" wrapper around the underlying C++ code, there are several ways in which the Python bindings differ from typical Python libraries.
196
+ These differences can catch Python programmers by surprise and lead to unexpected results. These differences result from the complexity of developing a large, long-lived library while continuing to maintain
197
+ backward compatibility. They are being addressed over time, but until they are all gone, please review this list of https://gdal.org/api/python_gotchas.html
198
+
199
+ Examples
200
+ --------
201
+
202
+ * An assortment of other samples are available in the `Python github samples directory <https://github.com/OSGeo/gdal/tree/master/swig/python/gdal-utils/osgeo_utils/samples>`__
203
+ with some description in the https://gdal.org/api/python_bindings.html#examples.
204
+ * Several `GDAL utilities <https://github.com/OSGeo/gdal/tree/master/swig/python/gdal-utils/osgeo_utils/>`__
205
+ are implemented in Python and can be useful examples.
206
+ * The majority of GDAL regression tests are written in Python. They are available at
207
+ `https://github.com/OSGeo/gdal/tree/master/autotest <https://github.com/OSGeo/gdal/tree/master/autotest>`__
208
+
209
+ One example of GDAL/numpy integration is found in the `val_repl.py <https://github.com/OSGeo/gdal/tree/master/swig/python/gdal-utils/osgeo_utils/samples/val_repl.py>`__ script.
210
+
211
+ .. note::
212
+ **Performance Notes**
213
+
214
+ ReadAsArray expects to make an entire copy of a raster band or dataset
215
+ unless the data are explicitly subsetted as part of the function call. For
216
+ large data, this approach is expected to be prohibitively memory intensive.
217
+
218
+
219
+ .. _GDAL: https://gdal.org