1
2
3
4
5
6
7 from sys import version_info as _swig_python_version_info
8 if _swig_python_version_info < (2, 7, 0):
9 raise RuntimeError("Python 2.7 or later required")
10
11
12 if __package__ or "." in __name__:
13 from . import _gdal
14 else:
15 import _gdal
16
17 try:
18 import builtins as __builtin__
19 except ImportError:
20 import __builtin__
23 try:
24 strthis = "proxy of " + self.this.__repr__()
25 except __builtin__.Exception:
26 strthis = ""
27 return "<%s.%s; %s >" % (self.__class__.__module__, self.__class__.__name__, strthis,)
28
31 def set_instance_attr(self, name, value):
32 if name == "thisown":
33 self.this.own(value)
34 elif name == "this":
35 set(self, name, value)
36 elif hasattr(self, name) and isinstance(getattr(type(self), name), property):
37 set(self, name, value)
38 else:
39 raise AttributeError("You cannot add instance attributes to %s" % self)
40 return set_instance_attr
41
44 def set_class_attr(cls, name, value):
45 if hasattr(cls, name) and not isinstance(getattr(cls, name), property):
46 set(cls, name, value)
47 else:
48 raise AttributeError("You cannot add class attributes to %s" % cls)
49 return set_class_attr
50
56 return wrapper
57
62
63
64
65
66
67 have_warned = 0
69 global have_warned
70
71 if have_warned == 1:
72 return
73
74 have_warned = 1
75 if sub_package is None or sub_package == 'utils':
76 sub_package = 'osgeo_utils'
77 if new_module is None:
78 new_module = module
79 new_module = '{}.{}'.format(sub_package, new_module)
80
81 from warnings import warn
82 warn('{}.py was placed in a namespace, it is now available as {}' .format(module, new_module),
83 DeprecationWarning)
84
85
86 from osgeo.gdalconst import *
87 from osgeo import gdalconst
88
89
90 import sys
91 byteorders = {"little": "<",
92 "big": ">"}
93 array_modes = { gdalconst.GDT_Int16: ("%si2" % byteorders[sys.byteorder]),
94 gdalconst.GDT_UInt16: ("%su2" % byteorders[sys.byteorder]),
95 gdalconst.GDT_Int32: ("%si4" % byteorders[sys.byteorder]),
96 gdalconst.GDT_UInt32: ("%su4" % byteorders[sys.byteorder]),
97 gdalconst.GDT_Float32: ("%sf4" % byteorders[sys.byteorder]),
98 gdalconst.GDT_Float64: ("%sf8" % byteorders[sys.byteorder]),
99 gdalconst.GDT_CFloat32: ("%sf4" % byteorders[sys.byteorder]),
100 gdalconst.GDT_CFloat64: ("%sf8" % byteorders[sys.byteorder]),
101 gdalconst.GDT_Byte: ("%st8" % byteorders[sys.byteorder]),
102 }
105 src_ds = Open(src_filename)
106 if src_ds is None or src_ds == 'NULL':
107 return 1
108
109 ct = ColorTable()
110 err = ComputeMedianCutPCT(src_ds.GetRasterBand(1),
111 src_ds.GetRasterBand(2),
112 src_ds.GetRasterBand(3),
113 256, ct)
114 if err != 0:
115 return err
116
117 gtiff_driver = GetDriverByName('GTiff')
118 if gtiff_driver is None:
119 return 1
120
121 dst_ds = gtiff_driver.Create(dst_filename,
122 src_ds.RasterXSize, src_ds.RasterYSize)
123 dst_ds.GetRasterBand(1).SetRasterColorTable(ct)
124
125 err = DitherRGB2PCT(src_ds.GetRasterBand(1),
126 src_ds.GetRasterBand(2),
127 src_ds.GetRasterBand(3),
128 dst_ds.GetRasterBand(1),
129 ct)
130 dst_ds = None
131 src_ds = None
132
133 return 0
134
135 -def listdir(path, recursionLevel = -1, options = []):
136 """ Iterate over a directory.
137
138 recursionLevel = -1 means unlimited level of recursion.
139 """
140 dir = OpenDir(path, recursionLevel, options)
141 if not dir:
142 raise OSError(path + ' does not exist')
143 try:
144 while True:
145 entry = GetNextDirEntry(dir)
146 if not entry:
147 break
148 yield entry
149 finally:
150 CloseDir(dir)
151
156
160
164
166 r"""VSIFReadL(unsigned int nMembSize, unsigned int nMembCount, VSILFILE fp) -> unsigned int"""
167 return _gdal.VSIFReadL(*args)
168
172
173
174 -def InfoOptions(options=None, format='text', deserialize=True,
175 computeMinMax=False, reportHistograms=False, reportProj4=False,
176 stats=False, approxStats=False, computeChecksum=False,
177 showGCPs=True, showMetadata=True, showRAT=True, showColorTable=True,
178 listMDD=False, showFileList=True, allMetadata=False,
179 extraMDDomains=None, wktFormat=None):
180 """ Create a InfoOptions() object that can be passed to gdal.Info()
181 options can be be an array of strings, a string or let empty and filled from other keywords."""
182
183 options = [] if options is None else options
184
185 if isinstance(options, str):
186 new_options = ParseCommandLine(options)
187 format = 'text'
188 if '-json' in new_options:
189 format = 'json'
190 else:
191 new_options = options
192 if format == 'json':
193 new_options += ['-json']
194 if '-json' in new_options:
195 format = 'json'
196 if computeMinMax:
197 new_options += ['-mm']
198 if reportHistograms:
199 new_options += ['-hist']
200 if reportProj4:
201 new_options += ['-proj4']
202 if stats:
203 new_options += ['-stats']
204 if approxStats:
205 new_options += ['-approx_stats']
206 if computeChecksum:
207 new_options += ['-checksum']
208 if not showGCPs:
209 new_options += ['-nogcp']
210 if not showMetadata:
211 new_options += ['-nomd']
212 if not showRAT:
213 new_options += ['-norat']
214 if not showColorTable:
215 new_options += ['-noct']
216 if listMDD:
217 new_options += ['-listmdd']
218 if not showFileList:
219 new_options += ['-nofl']
220 if allMetadata:
221 new_options += ['-mdd', 'all']
222 if wktFormat:
223 new_options += ['-wkt_format', wktFormat]
224 if extraMDDomains is not None:
225 for mdd in extraMDDomains:
226 new_options += ['-mdd', mdd]
227
228 return (GDALInfoOptions(new_options), format, deserialize)
229
230 -def Info(ds, **kwargs):
231 """ Return information on a dataset.
232 Arguments are :
233 ds --- a Dataset object or a filename
234 Keyword arguments are :
235 options --- return of gdal.InfoOptions(), string or array of strings
236 other keywords arguments of gdal.InfoOptions()
237 If options is provided as a gdal.InfoOptions() object, other keywords are ignored. """
238 if 'options' not in kwargs or isinstance(kwargs['options'], (list, str)):
239 (opts, format, deserialize) = InfoOptions(**kwargs)
240 else:
241 (opts, format, deserialize) = kwargs['options']
242 if isinstance(ds, str):
243 ds = Open(ds)
244 ret = InfoInternal(ds, opts)
245 if format == 'json' and deserialize:
246 import json
247 ret = json.loads(ret)
248 return ret
249
250
251 -def MultiDimInfoOptions(options=None, detailed=False, array=None, arrayoptions=None, limit=None, as_text=False):
252 """ Create a MultiDimInfoOptions() object that can be passed to gdal.MultiDimInfo()
253 options can be be an array of strings, a string or let empty and filled from other keywords."""
254
255 options = [] if options is None else options
256
257 if isinstance(options, str):
258 new_options = ParseCommandLine(options)
259 else:
260 new_options = options
261 if detailed:
262 new_options += ['-detailed']
263 if array:
264 new_options += ['-array', array]
265 if limit:
266 new_options += ['-limit', str(limit)]
267 if arrayoptions:
268 for option in arrayoptions:
269 new_options += ['-arrayoption', option]
270
271 return GDALMultiDimInfoOptions(new_options), as_text
272
274 """ Return information on a dataset.
275 Arguments are :
276 ds --- a Dataset object or a filename
277 Keyword arguments are :
278 options --- return of gdal.MultiDimInfoOptions(), string or array of strings
279 other keywords arguments of gdal.MultiDimInfoOptions()
280 If options is provided as a gdal.MultiDimInfoOptions() object, other keywords are ignored. """
281 if 'options' not in kwargs or isinstance(kwargs['options'], (list, str)):
282 opts, as_text = MultiDimInfoOptions(**kwargs)
283 else:
284 opts = kwargs['options']
285 as_text = True
286 if isinstance(ds, str):
287 ds = OpenEx(ds, OF_VERBOSE_ERROR | OF_MULTIDIM_RASTER)
288 ret = MultiDimInfoInternal(ds, opts)
289 if not as_text:
290 import json
291 ret = json.loads(ret)
292 return ret
293
296 return x if isinstance(x, str) else '%.18g' % x
297
298 -def TranslateOptions(options=None, format=None,
299 outputType = gdalconst.GDT_Unknown, bandList=None, maskBand=None,
300 width = 0, height = 0, widthPct = 0.0, heightPct = 0.0,
301 xRes = 0.0, yRes = 0.0,
302 creationOptions=None, srcWin=None, projWin=None, projWinSRS=None, strict = False,
303 unscale = False, scaleParams=None, exponents=None,
304 outputBounds=None, metadataOptions=None,
305 outputSRS=None, nogcp=False, GCPs=None,
306 noData=None, rgbExpand=None,
307 stats = False, rat = True, resampleAlg=None,
308 callback=None, callback_data=None):
309 """ Create a TranslateOptions() object that can be passed to gdal.Translate()
310 Keyword arguments are :
311 options --- can be be an array of strings, a string or let empty and filled from other keywords.
312 format --- output format ("GTiff", etc...)
313 outputType --- output type (gdalconst.GDT_Byte, etc...)
314 bandList --- array of band numbers (index start at 1)
315 maskBand --- mask band to generate or not ("none", "auto", "mask", 1, ...)
316 width --- width of the output raster in pixel
317 height --- height of the output raster in pixel
318 widthPct --- width of the output raster in percentage (100 = original width)
319 heightPct --- height of the output raster in percentage (100 = original height)
320 xRes --- output horizontal resolution
321 yRes --- output vertical resolution
322 creationOptions --- list of creation options
323 srcWin --- subwindow in pixels to extract: [left_x, top_y, width, height]
324 projWin --- subwindow in projected coordinates to extract: [ulx, uly, lrx, lry]
325 projWinSRS --- SRS in which projWin is expressed
326 strict --- strict mode
327 unscale --- unscale values with scale and offset metadata
328 scaleParams --- list of scale parameters, each of the form [src_min,src_max] or [src_min,src_max,dst_min,dst_max]
329 exponents --- list of exponentiation parameters
330 outputBounds --- assigned output bounds: [ulx, uly, lrx, lry]
331 metadataOptions --- list of metadata options
332 outputSRS --- assigned output SRS
333 nogcp --- ignore GCP in the raster
334 GCPs --- list of GCPs
335 noData --- nodata value (or "none" to unset it)
336 rgbExpand --- Color palette expansion mode: "gray", "rgb", "rgba"
337 stats --- whether to calculate statistics
338 rat --- whether to write source RAT
339 resampleAlg --- resampling mode
340 callback --- callback method
341 callback_data --- user data for callback
342 """
343 options = [] if options is None else options
344
345 if isinstance(options, str):
346 new_options = ParseCommandLine(options)
347 else:
348 new_options = options
349 if format is not None:
350 new_options += ['-of', format]
351 if outputType != gdalconst.GDT_Unknown:
352 new_options += ['-ot', GetDataTypeName(outputType)]
353 if maskBand != None:
354 new_options += ['-mask', str(maskBand)]
355 if bandList != None:
356 for b in bandList:
357 new_options += ['-b', str(b)]
358 if width != 0 or height != 0:
359 new_options += ['-outsize', str(width), str(height)]
360 elif widthPct != 0 and heightPct != 0:
361 new_options += ['-outsize', str(widthPct) + '%%', str(heightPct) + '%%']
362 if creationOptions is not None:
363 if isinstance(creationOptions, str):
364 new_options += ['-co', creationOptions]
365 else:
366 for opt in creationOptions:
367 new_options += ['-co', opt]
368 if srcWin is not None:
369 new_options += ['-srcwin', _strHighPrec(srcWin[0]), _strHighPrec(srcWin[1]), _strHighPrec(srcWin[2]), _strHighPrec(srcWin[3])]
370 if strict:
371 new_options += ['-strict']
372 if unscale:
373 new_options += ['-unscale']
374 if scaleParams:
375 for scaleParam in scaleParams:
376 new_options += ['-scale']
377 for v in scaleParam:
378 new_options += [str(v)]
379 if exponents:
380 for exponent in exponents:
381 new_options += ['-exponent', _strHighPrec(exponent)]
382 if outputBounds is not None:
383 new_options += ['-a_ullr', _strHighPrec(outputBounds[0]), _strHighPrec(outputBounds[1]), _strHighPrec(outputBounds[2]), _strHighPrec(outputBounds[3])]
384 if metadataOptions is not None:
385 if isinstance(metadataOptions, str):
386 new_options += ['-mo', metadataOptions]
387 else:
388 for opt in metadataOptions:
389 new_options += ['-mo', opt]
390 if outputSRS is not None:
391 new_options += ['-a_srs', str(outputSRS)]
392 if nogcp:
393 new_options += ['-nogcp']
394 if GCPs is not None:
395 for gcp in GCPs:
396 new_options += ['-gcp', _strHighPrec(gcp.GCPPixel), _strHighPrec(gcp.GCPLine), _strHighPrec(gcp.GCPX), str(gcp.GCPY), _strHighPrec(gcp.GCPZ)]
397 if projWin is not None:
398 new_options += ['-projwin', _strHighPrec(projWin[0]), _strHighPrec(projWin[1]), _strHighPrec(projWin[2]), _strHighPrec(projWin[3])]
399 if projWinSRS is not None:
400 new_options += ['-projwin_srs', str(projWinSRS)]
401 if noData is not None:
402 new_options += ['-a_nodata', _strHighPrec(noData)]
403 if rgbExpand is not None:
404 new_options += ['-expand', str(rgbExpand)]
405 if stats:
406 new_options += ['-stats']
407 if not rat:
408 new_options += ['-norat']
409 if resampleAlg is not None:
410 if resampleAlg == gdalconst.GRA_NearestNeighbour:
411 new_options += ['-r', 'near']
412 elif resampleAlg == gdalconst.GRA_Bilinear:
413 new_options += ['-r', 'bilinear']
414 elif resampleAlg == gdalconst.GRA_Cubic:
415 new_options += ['-r', 'cubic']
416 elif resampleAlg == gdalconst.GRA_CubicSpline:
417 new_options += ['-r', 'cubicspline']
418 elif resampleAlg == gdalconst.GRA_Lanczos:
419 new_options += ['-r', 'lanczos']
420 elif resampleAlg == gdalconst.GRA_Average:
421 new_options += ['-r', 'average']
422 elif resampleAlg == gdalconst.GRA_RMS:
423 new_options += ['-r', 'rms']
424 elif resampleAlg == gdalconst.GRA_Mode:
425 new_options += ['-r', 'mode']
426 else:
427 new_options += ['-r', str(resampleAlg)]
428 if xRes != 0 and yRes != 0:
429 new_options += ['-tr', _strHighPrec(xRes), _strHighPrec(yRes)]
430
431 return (GDALTranslateOptions(new_options), callback, callback_data)
432
434 """ Convert a dataset.
435 Arguments are :
436 destName --- Output dataset name
437 srcDS --- a Dataset object or a filename
438 Keyword arguments are :
439 options --- return of gdal.TranslateOptions(), string or array of strings
440 other keywords arguments of gdal.TranslateOptions()
441 If options is provided as a gdal.TranslateOptions() object, other keywords are ignored. """
442
443 if 'options' not in kwargs or isinstance(kwargs['options'], (list, str)):
444 (opts, callback, callback_data) = TranslateOptions(**kwargs)
445 else:
446 (opts, callback, callback_data) = kwargs['options']
447 if isinstance(srcDS, str):
448 srcDS = Open(srcDS)
449
450 return TranslateInternal(destName, srcDS, opts, callback, callback_data)
451
452 -def WarpOptions(options=None, format=None,
453 outputBounds=None,
454 outputBoundsSRS=None,
455 xRes=None, yRes=None, targetAlignedPixels = False,
456 width = 0, height = 0,
457 srcSRS=None, dstSRS=None,
458 coordinateOperation=None,
459 srcAlpha = False, dstAlpha = False,
460 warpOptions=None, errorThreshold=None,
461 warpMemoryLimit=None, creationOptions=None, outputType = gdalconst.GDT_Unknown,
462 workingType = gdalconst.GDT_Unknown, resampleAlg=None,
463 srcNodata=None, dstNodata=None, multithread = False,
464 tps = False, rpc = False, geoloc = False, polynomialOrder=None,
465 transformerOptions=None, cutlineDSName=None,
466 cutlineLayer=None, cutlineWhere=None, cutlineSQL=None, cutlineBlend=None, cropToCutline = False,
467 copyMetadata = True, metadataConflictValue=None,
468 setColorInterpretation = False,
469 overviewLevel = 'AUTO',
470 callback=None, callback_data=None):
471 """ Create a WarpOptions() object that can be passed to gdal.Warp()
472 Keyword arguments are :
473 options --- can be be an array of strings, a string or let empty and filled from other keywords.
474 format --- output format ("GTiff", etc...)
475 outputBounds --- output bounds as (minX, minY, maxX, maxY) in target SRS
476 outputBoundsSRS --- SRS in which output bounds are expressed, in the case they are not expressed in dstSRS
477 xRes, yRes --- output resolution in target SRS
478 targetAlignedPixels --- whether to force output bounds to be multiple of output resolution
479 width --- width of the output raster in pixel
480 height --- height of the output raster in pixel
481 srcSRS --- source SRS
482 dstSRS --- output SRS
483 coordinateOperation -- coordinate operation as a PROJ string or WKT string
484 srcAlpha --- whether to force the last band of the input dataset to be considered as an alpha band
485 dstAlpha --- whether to force the creation of an output alpha band
486 outputType --- output type (gdalconst.GDT_Byte, etc...)
487 workingType --- working type (gdalconst.GDT_Byte, etc...)
488 warpOptions --- list of warping options
489 errorThreshold --- error threshold for approximation transformer (in pixels)
490 warpMemoryLimit --- size of working buffer in MB
491 resampleAlg --- resampling mode
492 creationOptions --- list of creation options
493 srcNodata --- source nodata value(s)
494 dstNodata --- output nodata value(s)
495 multithread --- whether to multithread computation and I/O operations
496 tps --- whether to use Thin Plate Spline GCP transformer
497 rpc --- whether to use RPC transformer
498 geoloc --- whether to use GeoLocation array transformer
499 polynomialOrder --- order of polynomial GCP interpolation
500 transformerOptions --- list of transformer options
501 cutlineDSName --- cutline dataset name
502 cutlineLayer --- cutline layer name
503 cutlineWhere --- cutline WHERE clause
504 cutlineSQL --- cutline SQL statement
505 cutlineBlend --- cutline blend distance in pixels
506 cropToCutline --- whether to use cutline extent for output bounds
507 copyMetadata --- whether to copy source metadata
508 metadataConflictValue --- metadata data conflict value
509 setColorInterpretation --- whether to force color interpretation of input bands to output bands
510 overviewLevel --- To specify which overview level of source files must be used
511 callback --- callback method
512 callback_data --- user data for callback
513 """
514 options = [] if options is None else options
515
516 if isinstance(options, str):
517 new_options = ParseCommandLine(options)
518 else:
519 new_options = options
520 if format is not None:
521 new_options += ['-of', format]
522 if outputType != gdalconst.GDT_Unknown:
523 new_options += ['-ot', GetDataTypeName(outputType)]
524 if workingType != gdalconst.GDT_Unknown:
525 new_options += ['-wt', GetDataTypeName(workingType)]
526 if outputBounds is not None:
527 new_options += ['-te', _strHighPrec(outputBounds[0]), _strHighPrec(outputBounds[1]), _strHighPrec(outputBounds[2]), _strHighPrec(outputBounds[3])]
528 if outputBoundsSRS is not None:
529 new_options += ['-te_srs', str(outputBoundsSRS)]
530 if xRes is not None and yRes is not None:
531 new_options += ['-tr', _strHighPrec(xRes), _strHighPrec(yRes)]
532 if width != 0 or height != 0:
533 new_options += ['-ts', str(width), str(height)]
534 if srcSRS is not None:
535 new_options += ['-s_srs', str(srcSRS)]
536 if dstSRS is not None:
537 new_options += ['-t_srs', str(dstSRS)]
538 if coordinateOperation is not None:
539 new_options += ['-ct', coordinateOperation]
540 if targetAlignedPixels:
541 new_options += ['-tap']
542 if srcAlpha:
543 new_options += ['-srcalpha']
544 if dstAlpha:
545 new_options += ['-dstalpha']
546 if warpOptions is not None:
547 for opt in warpOptions:
548 new_options += ['-wo', str(opt)]
549 if errorThreshold is not None:
550 new_options += ['-et', _strHighPrec(errorThreshold)]
551 if resampleAlg is not None:
552 if resampleAlg == gdalconst.GRIORA_NearestNeighbour:
553 new_options += ['-r', 'near']
554 elif resampleAlg == gdalconst.GRIORA_Bilinear:
555 new_options += ['-rb']
556 elif resampleAlg == gdalconst.GRIORA_Cubic:
557 new_options += ['-rc']
558 elif resampleAlg == gdalconst.GRIORA_CubicSpline:
559 new_options += ['-rcs']
560 elif resampleAlg == gdalconst.GRIORA_Lanczos:
561 new_options += ['-r', 'lanczos']
562 elif resampleAlg == gdalconst.GRIORA_Average:
563 new_options += ['-r', 'average']
564 elif resampleAlg == gdalconst.GRIORA_RMS:
565 new_options += ['-r', 'rms']
566 elif resampleAlg == gdalconst.GRIORA_Mode:
567 new_options += ['-r', 'mode']
568 elif resampleAlg == gdalconst.GRIORA_Gauss:
569 new_options += ['-r', 'gauss']
570 else:
571 new_options += ['-r', str(resampleAlg)]
572 if warpMemoryLimit is not None:
573 new_options += ['-wm', str(warpMemoryLimit)]
574 if creationOptions is not None:
575 for opt in creationOptions:
576 new_options += ['-co', opt]
577 if srcNodata is not None:
578 new_options += ['-srcnodata', str(srcNodata)]
579 if dstNodata is not None:
580 new_options += ['-dstnodata', str(dstNodata)]
581 if multithread:
582 new_options += ['-multi']
583 if tps:
584 new_options += ['-tps']
585 if rpc:
586 new_options += ['-rpc']
587 if geoloc:
588 new_options += ['-geoloc']
589 if polynomialOrder is not None:
590 new_options += ['-order', str(polynomialOrder)]
591 if transformerOptions is not None:
592 for opt in transformerOptions:
593 new_options += ['-to', opt]
594 if cutlineDSName is not None:
595 new_options += ['-cutline', str(cutlineDSName)]
596 if cutlineLayer is not None:
597 new_options += ['-cl', str(cutlineLayer)]
598 if cutlineWhere is not None:
599 new_options += ['-cwhere', str(cutlineWhere)]
600 if cutlineSQL is not None:
601 new_options += ['-csql', str(cutlineSQL)]
602 if cutlineBlend is not None:
603 new_options += ['-cblend', str(cutlineBlend)]
604 if cropToCutline:
605 new_options += ['-crop_to_cutline']
606 if not copyMetadata:
607 new_options += ['-nomd']
608 if metadataConflictValue:
609 new_options += ['-cvmd', str(metadataConflictValue)]
610 if setColorInterpretation:
611 new_options += ['-setci']
612
613 if overviewLevel is None or isinstance(overviewLevel, str):
614 pass
615 elif isinstance(overviewLevel, int):
616 if overviewLevel < 0:
617 overviewLevel = 'AUTO' + str(overviewLevel)
618 else:
619 overviewLevel = str(overviewLevel)
620 else:
621 overviewLevel = None
622
623 if overviewLevel:
624 new_options += ['-ovr', overviewLevel]
625
626 return (GDALWarpAppOptions(new_options), callback, callback_data)
627
628 -def Warp(destNameOrDestDS, srcDSOrSrcDSTab, **kwargs):
629 """ Warp one or several datasets.
630 Arguments are :
631 destNameOrDestDS --- Output dataset name or object
632 srcDSOrSrcDSTab --- an array of Dataset objects or filenames, or a Dataset object or a filename
633 Keyword arguments are :
634 options --- return of gdal.WarpOptions(), string or array of strings
635 other keywords arguments of gdal.WarpOptions()
636 If options is provided as a gdal.WarpOptions() object, other keywords are ignored. """
637
638 if 'options' not in kwargs or isinstance(kwargs['options'], (list, str)):
639 (opts, callback, callback_data) = WarpOptions(**kwargs)
640 else:
641 (opts, callback, callback_data) = kwargs['options']
642 if isinstance(srcDSOrSrcDSTab, str):
643 srcDSTab = [Open(srcDSOrSrcDSTab)]
644 elif isinstance(srcDSOrSrcDSTab, list):
645 srcDSTab = []
646 for elt in srcDSOrSrcDSTab:
647 if isinstance(elt, str):
648 srcDSTab.append(Open(elt))
649 else:
650 srcDSTab.append(elt)
651 else:
652 srcDSTab = [srcDSOrSrcDSTab]
653
654 if isinstance(destNameOrDestDS, str):
655 return wrapper_GDALWarpDestName(destNameOrDestDS, srcDSTab, opts, callback, callback_data)
656 else:
657 return wrapper_GDALWarpDestDS(destNameOrDestDS, srcDSTab, opts, callback, callback_data)
658
659
660 -def VectorTranslateOptions(options=None, format=None,
661 accessMode=None,
662 srcSRS=None, dstSRS=None, reproject=True,
663 coordinateOperation=None,
664 SQLStatement=None, SQLDialect=None, where=None, selectFields=None,
665 addFields=False,
666 forceNullable=False,
667 emptyStrAsNull=False,
668 spatFilter=None, spatSRS=None,
669 datasetCreationOptions=None,
670 layerCreationOptions=None,
671 layers=None,
672 layerName=None,
673 geometryType=None,
674 dim=None,
675 segmentizeMaxDist= None,
676 makeValid=False,
677 zField=None,
678 resolveDomains=False,
679 skipFailures=False,
680 limit=None,
681 callback=None, callback_data=None):
682 """ Create a VectorTranslateOptions() object that can be passed to gdal.VectorTranslate()
683 Keyword arguments are :
684 options --- can be be an array of strings, a string or let empty and filled from other keywords.
685 format --- output format ("ESRI Shapefile", etc...)
686 accessMode --- None for creation, 'update', 'append', 'overwrite'
687 srcSRS --- source SRS
688 dstSRS --- output SRS (with reprojection if reproject = True)
689 coordinateOperation -- coordinate operation as a PROJ string or WKT string
690 reproject --- whether to do reprojection
691 SQLStatement --- SQL statement to apply to the source dataset
692 SQLDialect --- SQL dialect ('OGRSQL', 'SQLITE', ...)
693 where --- WHERE clause to apply to source layer(s)
694 selectFields --- list of fields to select
695 addFields --- whether to add new fields found in source layers (to be used with accessMode == 'append')
696 forceNullable --- whether to drop NOT NULL constraints on newly created fields
697 emptyStrAsNull --- whether to treat empty string values as NULL
698 spatFilter --- spatial filter as (minX, minY, maxX, maxY) bounding box
699 spatSRS --- SRS in which the spatFilter is expressed. If not specified, it is assumed to be the one of the layer(s)
700 datasetCreationOptions --- list of dataset creation options
701 layerCreationOptions --- list of layer creation options
702 layers --- list of layers to convert
703 layerName --- output layer name
704 geometryType --- output layer geometry type ('POINT', ....)
705 dim --- output dimension ('XY', 'XYZ', 'XYM', 'XYZM', 'layer_dim')
706 segmentizeMaxDist --- maximum distance between consecutive nodes of a line geometry
707 makeValid --- run MakeValid() on geometries
708 zField --- name of field to use to set the Z component of geometries
709 resolveDomains --- whether to create an additional field for each field associated with a coded field domain.
710 skipFailures --- whether to skip failures
711 limit -- maximum number of features to read per layer
712 callback --- callback method
713 callback_data --- user data for callback
714 """
715 options = [] if options is None else options
716
717 if isinstance(options, str):
718 new_options = ParseCommandLine(options)
719 else:
720 new_options = options
721 if format is not None:
722 new_options += ['-f', format]
723 if srcSRS is not None:
724 new_options += ['-s_srs', str(srcSRS)]
725 if dstSRS is not None:
726 if reproject:
727 new_options += ['-t_srs', str(dstSRS)]
728 else:
729 new_options += ['-a_srs', str(dstSRS)]
730 if coordinateOperation is not None:
731 new_options += ['-ct', coordinateOperation]
732 if SQLStatement is not None:
733 new_options += ['-sql', str(SQLStatement)]
734 if SQLDialect is not None:
735 new_options += ['-dialect', str(SQLDialect)]
736 if where is not None:
737 new_options += ['-where', str(where)]
738 if accessMode is not None:
739 if accessMode == 'update':
740 new_options += ['-update']
741 elif accessMode == 'append':
742 new_options += ['-append']
743 elif accessMode == 'overwrite':
744 new_options += ['-overwrite']
745 else:
746 raise Exception('unhandled accessMode')
747 if addFields:
748 new_options += ['-addfields']
749 if forceNullable:
750 new_options += ['-forceNullable']
751 if emptyStrAsNull:
752 new_options += ['-emptyStrAsNull']
753 if selectFields is not None:
754 val = ''
755 for item in selectFields:
756 if val:
757 val += ','
758 val += item
759 new_options += ['-select', val]
760 if datasetCreationOptions is not None:
761 for opt in datasetCreationOptions:
762 new_options += ['-dsco', opt]
763 if layerCreationOptions is not None:
764 for opt in layerCreationOptions:
765 new_options += ['-lco', opt]
766 if layers is not None:
767 if isinstance(layers, str):
768 new_options += [layers]
769 else:
770 for lyr in layers:
771 new_options += [lyr]
772 if segmentizeMaxDist is not None:
773 new_options += ['-segmentize', str(segmentizeMaxDist)]
774 if makeValid:
775 new_options += ['-makevalid']
776 if spatFilter is not None:
777 new_options += ['-spat', str(spatFilter[0]), str(spatFilter[1]), str(spatFilter[2]), str(spatFilter[3])]
778 if spatSRS is not None:
779 new_options += ['-spat_srs', str(spatSRS)]
780 if layerName is not None:
781 new_options += ['-nln', layerName]
782 if geometryType is not None:
783 if isinstance(geometryType, str):
784 new_options += ['-nlt', geometryType]
785 else:
786 for opt in geometryType:
787 new_options += ['-nlt', opt]
788 if dim is not None:
789 new_options += ['-dim', dim]
790 if zField is not None:
791 new_options += ['-zfield', zField]
792 if resolveDomains:
793 new_options += ['-resolveDomains']
794 if skipFailures:
795 new_options += ['-skip']
796 if limit is not None:
797 new_options += ['-limit', str(limit)]
798 if callback is not None:
799 new_options += ['-progress']
800
801 return (GDALVectorTranslateOptions(new_options), callback, callback_data)
802
804 """ Convert one vector dataset
805 Arguments are :
806 destNameOrDestDS --- Output dataset name or object
807 srcDS --- a Dataset object or a filename
808 Keyword arguments are :
809 options --- return of gdal.VectorTranslateOptions(), string or array of strings
810 other keywords arguments of gdal.VectorTranslateOptions()
811 If options is provided as a gdal.VectorTranslateOptions() object, other keywords are ignored. """
812
813 if 'options' not in kwargs or isinstance(kwargs['options'], (list, str)):
814 (opts, callback, callback_data) = VectorTranslateOptions(**kwargs)
815 else:
816 (opts, callback, callback_data) = kwargs['options']
817 if isinstance(srcDS, str):
818 srcDS = OpenEx(srcDS, gdalconst.OF_VECTOR)
819
820 if isinstance(destNameOrDestDS, str):
821 return wrapper_GDALVectorTranslateDestName(destNameOrDestDS, srcDS, opts, callback, callback_data)
822 else:
823 return wrapper_GDALVectorTranslateDestDS(destNameOrDestDS, srcDS, opts, callback, callback_data)
824
825 -def DEMProcessingOptions(options=None, colorFilename=None, format=None,
826 creationOptions=None, computeEdges=False, alg=None, band=1,
827 zFactor=None, scale=None, azimuth=None, altitude=None,
828 combined=False, multiDirectional=False, igor=False,
829 slopeFormat=None, trigonometric=False, zeroForFlat=False,
830 addAlpha=None, colorSelection=None,
831 callback=None, callback_data=None):
832 """ Create a DEMProcessingOptions() object that can be passed to gdal.DEMProcessing()
833 Keyword arguments are :
834 options --- can be be an array of strings, a string or let empty and filled from other keywords.
835 colorFilename --- (mandatory for "color-relief") name of file that contains palette definition for the "color-relief" processing.
836 format --- output format ("GTiff", etc...)
837 creationOptions --- list of creation options
838 computeEdges --- whether to compute values at raster edges.
839 alg --- 'Horn' (default) or 'ZevenbergenThorne' for hillshade, slope or aspect. 'Wilson' (default) or 'Riley' for TRI
840 band --- source band number to use
841 zFactor --- (hillshade only) vertical exaggeration used to pre-multiply the elevations.
842 scale --- ratio of vertical units to horizontal.
843 azimuth --- (hillshade only) azimuth of the light, in degrees. 0 if it comes from the top of the raster, 90 from the east, ... The default value, 315, should rarely be changed as it is the value generally used to generate shaded maps.
844 altitude ---(hillshade only) altitude of the light, in degrees. 90 if the light comes from above the DEM, 0 if it is raking light.
845 combined --- (hillshade only) whether to compute combined shading, a combination of slope and oblique shading. Only one of combined, multiDirectional and igor can be specified.
846 multiDirectional --- (hillshade only) whether to compute multi-directional shading. Only one of combined, multiDirectional and igor can be specified.
847 igor --- (hillshade only) whether to use Igor's hillshading from Maperitive. Only one of combined, multiDirectional and igor can be specified.
848 slopeformat --- (slope only) "degree" or "percent".
849 trigonometric --- (aspect only) whether to return trigonometric angle instead of azimuth. Thus 0deg means East, 90deg North, 180deg West, 270deg South.
850 zeroForFlat --- (aspect only) whether to return 0 for flat areas with slope=0, instead of -9999.
851 addAlpha --- adds an alpha band to the output file (only for processing = 'color-relief')
852 colorSelection --- (color-relief only) Determines how color entries are selected from an input value. Can be "nearest_color_entry", "exact_color_entry" or "linear_interpolation". Defaults to "linear_interpolation"
853 callback --- callback method
854 callback_data --- user data for callback
855 """
856 options = [] if options is None else options
857
858 if isinstance(options, str):
859 new_options = ParseCommandLine(options)
860 else:
861 new_options = options
862 if format is not None:
863 new_options += ['-of', format]
864 if creationOptions is not None:
865 for opt in creationOptions:
866 new_options += ['-co', opt]
867 if computeEdges:
868 new_options += ['-compute_edges']
869 if alg:
870 new_options += ['-alg', alg]
871 new_options += ['-b', str(band)]
872 if zFactor is not None:
873 new_options += ['-z', str(zFactor)]
874 if scale is not None:
875 new_options += ['-s', str(scale)]
876 if azimuth is not None:
877 new_options += ['-az', str(azimuth)]
878 if altitude is not None:
879 new_options += ['-alt', str(altitude)]
880 if combined:
881 new_options += ['-combined']
882 if multiDirectional:
883 new_options += ['-multidirectional']
884 if igor:
885 new_options += ['-igor']
886 if slopeFormat == 'percent':
887 new_options += ['-p']
888 if trigonometric:
889 new_options += ['-trigonometric']
890 if zeroForFlat:
891 new_options += ['-zero_for_flat']
892 if colorSelection is not None:
893 if colorSelection == 'nearest_color_entry':
894 new_options += ['-nearest_color_entry']
895 elif colorSelection == 'exact_color_entry':
896 new_options += ['-exact_color_entry']
897 elif colorSelection == 'linear_interpolation':
898 pass
899 else:
900 raise ValueError("Unsupported value for colorSelection")
901 if addAlpha:
902 new_options += ['-alpha']
903
904 return (GDALDEMProcessingOptions(new_options), colorFilename, callback, callback_data)
905
907 """ Apply a DEM processing.
908 Arguments are :
909 destName --- Output dataset name
910 srcDS --- a Dataset object or a filename
911 processing --- one of "hillshade", "slope", "aspect", "color-relief", "TRI", "TPI", "Roughness"
912 Keyword arguments are :
913 options --- return of gdal.DEMProcessingOptions(), string or array of strings
914 other keywords arguments of gdal.DEMProcessingOptions()
915 If options is provided as a gdal.DEMProcessingOptions() object, other keywords are ignored. """
916
917 if 'options' not in kwargs or isinstance(kwargs['options'], (list, str)):
918 (opts, colorFilename, callback, callback_data) = DEMProcessingOptions(**kwargs)
919 else:
920 (opts, colorFilename, callback, callback_data) = kwargs['options']
921 if isinstance(srcDS, str):
922 srcDS = Open(srcDS)
923
924 return DEMProcessingInternal(destName, srcDS, processing, colorFilename, opts, callback, callback_data)
925
926
927 -def NearblackOptions(options=None, format=None,
928 creationOptions=None, white = False, colors=None,
929 maxNonBlack=None, nearDist=None, setAlpha = False, setMask = False,
930 callback=None, callback_data=None):
931 """ Create a NearblackOptions() object that can be passed to gdal.Nearblack()
932 Keyword arguments are :
933 options --- can be be an array of strings, a string or let empty and filled from other keywords.
934 format --- output format ("GTiff", etc...)
935 creationOptions --- list of creation options
936 white --- whether to search for nearly white (255) pixels instead of nearly black pixels.
937 colors --- list of colors to search for, e.g. ((0,0,0),(255,255,255)). The pixels that are considered as the collar are set to 0
938 maxNonBlack --- number of non-black (or other searched colors specified with white / colors) pixels that can be encountered before the giving up search inwards. Defaults to 2.
939 nearDist --- select how far from black, white or custom colors the pixel values can be and still considered near black, white or custom color. Defaults to 15.
940 setAlpha --- adds an alpha band to the output file.
941 setMask --- adds a mask band to the output file.
942 callback --- callback method
943 callback_data --- user data for callback
944 """
945 options = [] if options is None else options
946
947 if isinstance(options, str):
948 new_options = ParseCommandLine(options)
949 else:
950 new_options = options
951 if format is not None:
952 new_options += ['-of', format]
953 if creationOptions is not None:
954 for opt in creationOptions:
955 new_options += ['-co', opt]
956 if white:
957 new_options += ['-white']
958 if colors is not None:
959 for color in colors:
960 color_str = ''
961 for cpt in color:
962 if color_str != '':
963 color_str += ','
964 color_str += str(cpt)
965 new_options += ['-color', color_str]
966 if maxNonBlack is not None:
967 new_options += ['-nb', str(maxNonBlack)]
968 if nearDist is not None:
969 new_options += ['-near', str(nearDist)]
970 if setAlpha:
971 new_options += ['-setalpha']
972 if setMask:
973 new_options += ['-setmask']
974
975 return (GDALNearblackOptions(new_options), callback, callback_data)
976
977 -def Nearblack(destNameOrDestDS, srcDS, **kwargs):
978 """ Convert nearly black/white borders to exact value.
979 Arguments are :
980 destNameOrDestDS --- Output dataset name or object
981 srcDS --- a Dataset object or a filename
982 Keyword arguments are :
983 options --- return of gdal.NearblackOptions(), string or array of strings
984 other keywords arguments of gdal.NearblackOptions()
985 If options is provided as a gdal.NearblackOptions() object, other keywords are ignored. """
986
987 if 'options' not in kwargs or isinstance(kwargs['options'], (list, str)):
988 (opts, callback, callback_data) = NearblackOptions(**kwargs)
989 else:
990 (opts, callback, callback_data) = kwargs['options']
991 if isinstance(srcDS, str):
992 srcDS = OpenEx(srcDS)
993
994 if isinstance(destNameOrDestDS, str):
995 return wrapper_GDALNearblackDestName(destNameOrDestDS, srcDS, opts, callback, callback_data)
996 else:
997 return wrapper_GDALNearblackDestDS(destNameOrDestDS, srcDS, opts, callback, callback_data)
998
999
1000 -def GridOptions(options=None, format=None,
1001 outputType=gdalconst.GDT_Unknown,
1002 width=0, height=0,
1003 creationOptions=None,
1004 outputBounds=None,
1005 outputSRS=None,
1006 noData=None,
1007 algorithm=None,
1008 layers=None,
1009 SQLStatement=None,
1010 where=None,
1011 spatFilter=None,
1012 zfield=None,
1013 z_increase=None,
1014 z_multiply=None,
1015 callback=None, callback_data=None):
1016 """ Create a GridOptions() object that can be passed to gdal.Grid()
1017 Keyword arguments are :
1018 options --- can be be an array of strings, a string or let empty and filled from other keywords.
1019 format --- output format ("GTiff", etc...)
1020 outputType --- output type (gdalconst.GDT_Byte, etc...)
1021 width --- width of the output raster in pixel
1022 height --- height of the output raster in pixel
1023 creationOptions --- list of creation options
1024 outputBounds --- assigned output bounds: [ulx, uly, lrx, lry]
1025 outputSRS --- assigned output SRS
1026 noData --- nodata value
1027 algorithm --- e.g "invdist:power=2.0:smoothing=0.0:radius1=0.0:radius2=0.0:angle=0.0:max_points=0:min_points=0:nodata=0.0"
1028 layers --- list of layers to convert
1029 SQLStatement --- SQL statement to apply to the source dataset
1030 where --- WHERE clause to apply to source layer(s)
1031 spatFilter --- spatial filter as (minX, minY, maxX, maxY) bounding box
1032 zfield --- Identifies an attribute field on the features to be used to get a Z value from. This value overrides Z value read from feature geometry record.
1033 z_increase --- Addition to the attribute field on the features to be used to get a Z value from. The addition should be the same unit as Z value. The result value will be Z value + Z increase value. The default value is 0.
1034 z_multiply - Multiplication ratio for Z field. This can be used for shift from e.g. foot to meters or from elevation to deep. The result value will be (Z value + Z increase value) * Z multiply value. The default value is 1.
1035 callback --- callback method
1036 callback_data --- user data for callback
1037 """
1038 options = [] if options is None else options
1039
1040 if isinstance(options, str):
1041 new_options = ParseCommandLine(options)
1042 else:
1043 new_options = options
1044 if format is not None:
1045 new_options += ['-of', format]
1046 if outputType != gdalconst.GDT_Unknown:
1047 new_options += ['-ot', GetDataTypeName(outputType)]
1048 if width != 0 or height != 0:
1049 new_options += ['-outsize', str(width), str(height)]
1050 if creationOptions is not None:
1051 for opt in creationOptions:
1052 new_options += ['-co', opt]
1053 if outputBounds is not None:
1054 new_options += ['-txe', _strHighPrec(outputBounds[0]), _strHighPrec(outputBounds[2]), '-tye', _strHighPrec(outputBounds[1]), _strHighPrec(outputBounds[3])]
1055 if outputSRS is not None:
1056 new_options += ['-a_srs', str(outputSRS)]
1057 if algorithm is not None:
1058 new_options += ['-a', algorithm]
1059 if layers is not None:
1060 if isinstance(layers, (tuple, list)):
1061 for layer in layers:
1062 new_options += ['-l', layer]
1063 else:
1064 new_options += ['-l', layers]
1065 if SQLStatement is not None:
1066 new_options += ['-sql', str(SQLStatement)]
1067 if where is not None:
1068 new_options += ['-where', str(where)]
1069 if zfield is not None:
1070 new_options += ['-zfield', zfield]
1071 if z_increase is not None:
1072 new_options += ['-z_increase', str(z_increase)]
1073 if z_multiply is not None:
1074 new_options += ['-z_multiply', str(z_multiply)]
1075 if spatFilter is not None:
1076 new_options += ['-spat', str(spatFilter[0]), str(spatFilter[1]), str(spatFilter[2]), str(spatFilter[3])]
1077
1078 return (GDALGridOptions(new_options), callback, callback_data)
1079
1080 -def Grid(destName, srcDS, **kwargs):
1081 """ Create raster from the scattered data.
1082 Arguments are :
1083 destName --- Output dataset name
1084 srcDS --- a Dataset object or a filename
1085 Keyword arguments are :
1086 options --- return of gdal.GridOptions(), string or array of strings
1087 other keywords arguments of gdal.GridOptions()
1088 If options is provided as a gdal.GridOptions() object, other keywords are ignored. """
1089
1090 if 'options' not in kwargs or isinstance(kwargs['options'], (list, str)):
1091 (opts, callback, callback_data) = GridOptions(**kwargs)
1092 else:
1093 (opts, callback, callback_data) = kwargs['options']
1094 if isinstance(srcDS, str):
1095 srcDS = OpenEx(srcDS, gdalconst.OF_VECTOR)
1096
1097 return GridInternal(destName, srcDS, opts, callback, callback_data)
1098
1099 -def RasterizeOptions(options=None, format=None,
1100 outputType=gdalconst.GDT_Unknown,
1101 creationOptions=None, noData=None, initValues=None,
1102 outputBounds=None, outputSRS=None,
1103 transformerOptions=None,
1104 width=None, height=None,
1105 xRes=None, yRes=None, targetAlignedPixels=False,
1106 bands=None, inverse=False, allTouched=False,
1107 burnValues=None, attribute=None, useZ=False, layers=None,
1108 SQLStatement=None, SQLDialect=None, where=None, optim=None,
1109 add=None,
1110 callback=None, callback_data=None):
1111 """ Create a RasterizeOptions() object that can be passed to gdal.Rasterize()
1112 Keyword arguments are :
1113 options --- can be be an array of strings, a string or let empty and filled from other keywords.
1114 format --- output format ("GTiff", etc...)
1115 outputType --- output type (gdalconst.GDT_Byte, etc...)
1116 creationOptions --- list of creation options
1117 outputBounds --- assigned output bounds: [minx, miny, maxx, maxy]
1118 outputSRS --- assigned output SRS
1119 transformerOptions --- list of transformer options
1120 width --- width of the output raster in pixel
1121 height --- height of the output raster in pixel
1122 xRes, yRes --- output resolution in target SRS
1123 targetAlignedPixels --- whether to force output bounds to be multiple of output resolution
1124 noData --- nodata value
1125 initValues --- Value or list of values to pre-initialize the output image bands with. However, it is not marked as the nodata value in the output file. If only one value is given, the same value is used in all the bands.
1126 bands --- list of output bands to burn values into
1127 inverse --- whether to invert rasterization, i.e. burn the fixed burn value, or the burn value associated with the first feature into all parts of the image not inside the provided a polygon.
1128 allTouched -- whether to enable the ALL_TOUCHED rasterization option so that all pixels touched by lines or polygons will be updated, not just those on the line render path, or whose center point is within the polygon.
1129 burnValues -- list of fixed values to burn into each band for all objects. Excusive with attribute.
1130 attribute --- identifies an attribute field on the features to be used for a burn-in value. The value will be burned into all output bands. Excusive with burnValues.
1131 useZ --- whether to indicate that a burn value should be extracted from the "Z" values of the feature. These values are added to the burn value given by burnValues or attribute if provided. As of now, only points and lines are drawn in 3D.
1132 layers --- list of layers from the datasource that will be used for input features.
1133 SQLStatement --- SQL statement to apply to the source dataset
1134 SQLDialect --- SQL dialect ('OGRSQL', 'SQLITE', ...)
1135 where --- WHERE clause to apply to source layer(s)
1136 optim --- optimization mode ('RASTER', 'VECTOR')
1137 add --- set to True to use additive mode instead of replace when burning values
1138 callback --- callback method
1139 callback_data --- user data for callback
1140 """
1141 options = [] if options is None else options
1142
1143 if isinstance(options, str):
1144 new_options = ParseCommandLine(options)
1145 else:
1146 new_options = options
1147 if format is not None:
1148 new_options += ['-of', format]
1149 if outputType != gdalconst.GDT_Unknown:
1150 new_options += ['-ot', GetDataTypeName(outputType)]
1151 if creationOptions is not None:
1152 for opt in creationOptions:
1153 new_options += ['-co', opt]
1154 if bands is not None:
1155 for b in bands:
1156 new_options += ['-b', str(b)]
1157 if noData is not None:
1158 new_options += ['-a_nodata', str(noData)]
1159 if initValues is not None:
1160 if isinstance(initValues, (tuple, list)):
1161 for val in initValues:
1162 new_options += ['-init', str(val)]
1163 else:
1164 new_options += ['-init', str(initValues)]
1165 if outputBounds is not None:
1166 new_options += ['-te', _strHighPrec(outputBounds[0]), _strHighPrec(outputBounds[1]), _strHighPrec(outputBounds[2]), _strHighPrec(outputBounds[3])]
1167 if outputSRS is not None:
1168 new_options += ['-a_srs', str(outputSRS)]
1169 if transformerOptions is not None:
1170 for opt in transformerOptions:
1171 new_options += ['-to', opt]
1172 if width is not None and height is not None:
1173 new_options += ['-ts', str(width), str(height)]
1174 if xRes is not None and yRes is not None:
1175 new_options += ['-tr', _strHighPrec(xRes), _strHighPrec(yRes)]
1176 if targetAlignedPixels:
1177 new_options += ['-tap']
1178 if inverse:
1179 new_options += ['-i']
1180 if allTouched:
1181 new_options += ['-at']
1182 if burnValues is not None:
1183 if attribute is not None:
1184 raise Exception('burnValues and attribute option are exclusive.')
1185 if isinstance(burnValues, (tuple, list)):
1186 for val in burnValues:
1187 new_options += ['-burn', str(val)]
1188 else:
1189 new_options += ['-burn', str(burnValues)]
1190 if attribute is not None:
1191 new_options += ['-a', attribute]
1192 if useZ:
1193 new_options += ['-3d']
1194 if layers is not None:
1195 if isinstance(layers, ((tuple, list))):
1196 for layer in layers:
1197 new_options += ['-l', layer]
1198 else:
1199 new_options += ['-l', layers]
1200 if SQLStatement is not None:
1201 new_options += ['-sql', str(SQLStatement)]
1202 if SQLDialect is not None:
1203 new_options += ['-dialect', str(SQLDialect)]
1204 if where is not None:
1205 new_options += ['-where', str(where)]
1206 if optim is not None:
1207 new_options += ['-optim', str(optim)]
1208 if add:
1209 new_options += ['-add']
1210
1211 return (GDALRasterizeOptions(new_options), callback, callback_data)
1212
1213 -def Rasterize(destNameOrDestDS, srcDS, **kwargs):
1214 """ Burns vector geometries into a raster
1215 Arguments are :
1216 destNameOrDestDS --- Output dataset name or object
1217 srcDS --- a Dataset object or a filename
1218 Keyword arguments are :
1219 options --- return of gdal.RasterizeOptions(), string or array of strings
1220 other keywords arguments of gdal.RasterizeOptions()
1221 If options is provided as a gdal.RasterizeOptions() object, other keywords are ignored. """
1222
1223 if 'options' not in kwargs or isinstance(kwargs['options'], (list, str)):
1224 (opts, callback, callback_data) = RasterizeOptions(**kwargs)
1225 else:
1226 (opts, callback, callback_data) = kwargs['options']
1227 if isinstance(srcDS, str):
1228 srcDS = OpenEx(srcDS, gdalconst.OF_VECTOR)
1229
1230 if isinstance(destNameOrDestDS, str):
1231 return wrapper_GDALRasterizeDestName(destNameOrDestDS, srcDS, opts, callback, callback_data)
1232 else:
1233 return wrapper_GDALRasterizeDestDS(destNameOrDestDS, srcDS, opts, callback, callback_data)
1234
1235
1236 -def BuildVRTOptions(options=None,
1237 resolution=None,
1238 outputBounds=None,
1239 xRes=None, yRes=None,
1240 targetAlignedPixels=None,
1241 separate=None,
1242 bandList=None,
1243 addAlpha=None,
1244 resampleAlg=None,
1245 outputSRS=None,
1246 allowProjectionDifference=None,
1247 srcNodata=None,
1248 VRTNodata=None,
1249 hideNodata=None,
1250 callback=None, callback_data=None):
1251 """ Create a BuildVRTOptions() object that can be passed to gdal.BuildVRT()
1252 Keyword arguments are :
1253 options --- can be be an array of strings, a string or let empty and filled from other keywords..
1254 resolution --- 'highest', 'lowest', 'average', 'user'.
1255 outputBounds --- output bounds as (minX, minY, maxX, maxY) in target SRS.
1256 xRes, yRes --- output resolution in target SRS.
1257 targetAlignedPixels --- whether to force output bounds to be multiple of output resolution.
1258 separate --- whether each source file goes into a separate stacked band in the VRT band.
1259 bandList --- array of band numbers (index start at 1).
1260 addAlpha --- whether to add an alpha mask band to the VRT when the source raster have none.
1261 resampleAlg --- resampling mode.
1262 outputSRS --- assigned output SRS.
1263 allowProjectionDifference --- whether to accept input datasets have not the same projection. Note: they will *not* be reprojected.
1264 srcNodata --- source nodata value(s).
1265 VRTNodata --- nodata values at the VRT band level.
1266 hideNodata --- whether to make the VRT band not report the NoData value.
1267 callback --- callback method.
1268 callback_data --- user data for callback.
1269 """
1270 options = [] if options is None else options
1271
1272 if isinstance(options, str):
1273 new_options = ParseCommandLine(options)
1274 else:
1275 new_options = options
1276 if resolution is not None:
1277 new_options += ['-resolution', str(resolution)]
1278 if outputBounds is not None:
1279 new_options += ['-te', _strHighPrec(outputBounds[0]), _strHighPrec(outputBounds[1]), _strHighPrec(outputBounds[2]), _strHighPrec(outputBounds[3])]
1280 if xRes is not None and yRes is not None:
1281 new_options += ['-tr', _strHighPrec(xRes), _strHighPrec(yRes)]
1282 if targetAlignedPixels:
1283 new_options += ['-tap']
1284 if separate:
1285 new_options += ['-separate']
1286 if bandList != None:
1287 for b in bandList:
1288 new_options += ['-b', str(b)]
1289 if addAlpha:
1290 new_options += ['-addalpha']
1291 if resampleAlg is not None:
1292 if resampleAlg == gdalconst.GRIORA_NearestNeighbour:
1293 new_options += ['-r', 'near']
1294 elif resampleAlg == gdalconst.GRIORA_Bilinear:
1295 new_options += ['-rb']
1296 elif resampleAlg == gdalconst.GRIORA_Cubic:
1297 new_options += ['-rc']
1298 elif resampleAlg == gdalconst.GRIORA_CubicSpline:
1299 new_options += ['-rcs']
1300 elif resampleAlg == gdalconst.GRIORA_Lanczos:
1301 new_options += ['-r', 'lanczos']
1302 elif resampleAlg == gdalconst.GRIORA_Average:
1303 new_options += ['-r', 'average']
1304 elif resampleAlg == gdalconst.GRIORA_RMS:
1305 new_options += ['-r', 'rms']
1306 elif resampleAlg == gdalconst.GRIORA_Mode:
1307 new_options += ['-r', 'mode']
1308 elif resampleAlg == gdalconst.GRIORA_Gauss:
1309 new_options += ['-r', 'gauss']
1310 else:
1311 new_options += ['-r', str(resampleAlg)]
1312 if outputSRS is not None:
1313 new_options += ['-a_srs', str(outputSRS)]
1314 if allowProjectionDifference:
1315 new_options += ['-allow_projection_difference']
1316 if srcNodata is not None:
1317 new_options += ['-srcnodata', str(srcNodata)]
1318 if VRTNodata is not None:
1319 new_options += ['-vrtnodata', str(VRTNodata)]
1320 if hideNodata:
1321 new_options += ['-hidenodata']
1322
1323 return (GDALBuildVRTOptions(new_options), callback, callback_data)
1324
1325 -def BuildVRT(destName, srcDSOrSrcDSTab, **kwargs):
1326 """ Build a VRT from a list of datasets.
1327 Arguments are :
1328 destName --- Output dataset name
1329 srcDSOrSrcDSTab --- an array of Dataset objects or filenames, or a Dataset object or a filename
1330 Keyword arguments are :
1331 options --- return of gdal.BuildVRTOptions(), string or array of strings
1332 other keywords arguments of gdal.BuildVRTOptions()
1333 If options is provided as a gdal.BuildVRTOptions() object, other keywords are ignored. """
1334
1335 if 'options' not in kwargs or isinstance(kwargs['options'], (list, str)):
1336 (opts, callback, callback_data) = BuildVRTOptions(**kwargs)
1337 else:
1338 (opts, callback, callback_data) = kwargs['options']
1339
1340 srcDSTab = []
1341 srcDSNamesTab = []
1342 if isinstance(srcDSOrSrcDSTab, str):
1343 srcDSNamesTab = [srcDSOrSrcDSTab]
1344 elif isinstance(srcDSOrSrcDSTab, list):
1345 for elt in srcDSOrSrcDSTab:
1346 if isinstance(elt, str):
1347 srcDSNamesTab.append(elt)
1348 else:
1349 srcDSTab.append(elt)
1350 if srcDSTab and srcDSNamesTab:
1351 raise Exception('Mix of names and dataset objects not supported')
1352 else:
1353 srcDSTab = [srcDSOrSrcDSTab]
1354
1355 if srcDSTab:
1356 return BuildVRTInternalObjects(destName, srcDSTab, opts, callback, callback_data)
1357 else:
1358 return BuildVRTInternalNames(destName, srcDSNamesTab, opts, callback, callback_data)
1359
1360
1361 -def MultiDimTranslateOptions(options=None, format=None, creationOptions=None,
1362 arraySpecs=None, groupSpecs=None, subsetSpecs=None, scaleAxesSpecs=None,
1363 callback=None, callback_data=None):
1364 """ Create a MultiDimTranslateOptions() object that can be passed to gdal.MultiDimTranslate()
1365 Keyword arguments are :
1366 options --- can be be an array of strings, a string or let empty and filled from other keywords.
1367 format --- output format ("GTiff", etc...)
1368 creationOptions --- list of creation options
1369 arraySpecs -- list of array specifications, each of them being an array name or "name={src_array_name},dstname={dst_name},transpose=[1,0],view=[:,::-1]"
1370 groupSpecs -- list of group specifications, each of them being a group name or "name={src_array_name},dstname={dst_name},recursive=no"
1371 subsetSpecs -- list of subset specifications, each of them being like "{dim_name}({min_val},{max_val})" or "{dim_name}({slice_va})"
1372 scaleAxesSpecs -- list of dimension scaling specifications, each of them being like "{dim_name}({scale_factor})"
1373 callback --- callback method
1374 callback_data --- user data for callback
1375 """
1376 options = [] if options is None else options
1377
1378 if isinstance(options, str):
1379 new_options = ParseCommandLine(options)
1380 else:
1381 new_options = options
1382 if format is not None:
1383 new_options += ['-of', format]
1384 if creationOptions is not None:
1385 for opt in creationOptions:
1386 new_options += ['-co', opt]
1387 if arraySpecs is not None:
1388 for s in arraySpecs:
1389 new_options += ['-array', s]
1390 if groupSpecs is not None:
1391 for s in groupSpecs:
1392 new_options += ['-group', s]
1393 if subsetSpecs is not None:
1394 for s in subsetSpecs:
1395 new_options += ['-subset', s]
1396 if scaleAxesSpecs is not None:
1397 for s in scaleAxesSpecs:
1398 new_options += ['-scaleaxes', s]
1399
1400 return (GDALMultiDimTranslateOptions(new_options), callback, callback_data)
1401
1403 """ MultiDimTranslate one or several datasets.
1404 Arguments are :
1405 destName --- Output dataset name
1406 srcDSOrSrcDSTab --- an array of Dataset objects or filenames, or a Dataset object or a filename
1407 Keyword arguments are :
1408 options --- return of gdal.MultiDimTranslateOptions(), string or array of strings
1409 other keywords arguments of gdal.MultiDimTranslateOptions()
1410 If options is provided as a gdal.MultiDimTranslateOptions() object, other keywords are ignored. """
1411
1412 if 'options' not in kwargs or isinstance(kwargs['options'], (list, str)):
1413 (opts, callback, callback_data) = MultiDimTranslateOptions(**kwargs)
1414 else:
1415 (opts, callback, callback_data) = kwargs['options']
1416 if isinstance(srcDSOrSrcDSTab, str):
1417 srcDSTab = [OpenEx(srcDSOrSrcDSTab, OF_VERBOSE_ERROR | OF_RASTER | OF_MULTIDIM_RASTER)]
1418 elif isinstance(srcDSOrSrcDSTab, list):
1419 srcDSTab = []
1420 for elt in srcDSOrSrcDSTab:
1421 if isinstance(elt, str):
1422 srcDSTab.append(OpenEx(elt, OF_VERBOSE_ERROR | OF_RASTER | OF_MULTIDIM_RASTER))
1423 else:
1424 srcDSTab.append(elt)
1425 else:
1426 srcDSTab = [srcDSOrSrcDSTab]
1427
1428 return wrapper_GDALMultiDimTranslateDestName(destName, srcDSTab, opts, callback, callback_data)
1429
1440
1465
1466
1467
1468 -def Debug(*args):
1469 r"""Debug(char const * msg_class, char const * message)"""
1470 return _gdal.Debug(*args)
1471
1473 r"""SetErrorHandler(CPLErrorHandler pfnErrorHandler=0) -> CPLErr"""
1474 return _gdal.SetErrorHandler(*args)
1475
1479
1481 r"""PushErrorHandler(CPLErrorHandler pfnErrorHandler=0) -> CPLErr"""
1482 return _gdal.PushErrorHandler(*args)
1483
1487
1489 r"""Error(CPLErr msg_class=CE_Failure, int err_code=0, char const * msg="error")"""
1490 return _gdal.Error(*args)
1491
1495
1497 r"""GOA2GetRefreshToken(char const * pszAuthToken, char const * pszScope) -> retStringAndCPLFree *"""
1498 return _gdal.GOA2GetRefreshToken(*args)
1499
1501 r"""GOA2GetAccessToken(char const * pszRefreshToken, char const * pszScope) -> retStringAndCPLFree *"""
1502 return _gdal.GOA2GetAccessToken(*args)
1503
1507
1509 r"""EscapeString(int len, int scheme=CPLES_SQL) -> retStringAndCPLFree *"""
1510 return _gdal.EscapeString(*args, **kwargs)
1511
1515
1519
1523
1527
1531
1535
1539
1543
1547
1551
1553 r"""FindFile(char const * pszClass, char const * utf8_path) -> char const *"""
1554 return _gdal.FindFile(*args)
1555
1557 r"""ReadDir(char const * utf8_path, int nMaxFiles=0) -> char **"""
1558 return _gdal.ReadDir(*args)
1559
1561 r"""ReadDirRecursive(char const * utf8_path) -> char **"""
1562 return _gdal.ReadDirRecursive(*args)
1563
1565 r"""OpenDir(char const * utf8_path, int nRecurseDepth=-1, char ** options=None) -> VSIDIR *"""
1566 return _gdal.OpenDir(*args)
1567 -class DirEntry(object):
1568 r"""Proxy of C++ DirEntry class."""
1569
1570 thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
1571 __repr__ = _swig_repr
1572 name = property(_gdal.DirEntry_name_get, doc=r"""name : p.char""")
1573 mode = property(_gdal.DirEntry_mode_get, doc=r"""mode : int""")
1574 size = property(_gdal.DirEntry_size_get, doc=r"""size : GIntBig""")
1575 mtime = property(_gdal.DirEntry_mtime_get, doc=r"""mtime : GIntBig""")
1576 modeKnown = property(_gdal.DirEntry_modeKnown_get, doc=r"""modeKnown : bool""")
1577 sizeKnown = property(_gdal.DirEntry_sizeKnown_get, doc=r"""sizeKnown : bool""")
1578 mtimeKnown = property(_gdal.DirEntry_mtimeKnown_get, doc=r"""mtimeKnown : bool""")
1579 extra = property(_gdal.DirEntry_extra_get, doc=r"""extra : p.p.char""")
1580
1581 - def __init__(self, *args):
1582 r"""__init__(DirEntry self, DirEntry entryIn) -> DirEntry"""
1583 _gdal.DirEntry_swiginit(self, _gdal.new_DirEntry(*args))
1584 __swig_destroy__ = _gdal.delete_DirEntry
1585
1586 - def IsDirectory(self, *args):
1587 r"""IsDirectory(DirEntry self) -> bool"""
1588 return _gdal.DirEntry_IsDirectory(self, *args)
1589
1590
1591 _gdal.DirEntry_swigregister(DirEntry)
1592
1593
1594 -def GetNextDirEntry(*args):
1595 r"""GetNextDirEntry(VSIDIR * dir) -> DirEntry"""
1596 return _gdal.GetNextDirEntry(*args)
1597
1599 r"""CloseDir(VSIDIR * dir)"""
1600 return _gdal.CloseDir(*args)
1601
1603 r"""SetConfigOption(char const * pszKey, char const * pszValue)"""
1604 return _gdal.SetConfigOption(*args)
1605
1607 r"""GetConfigOption(char const * pszKey, char const * pszDefault=None) -> char const *"""
1608 return _gdal.GetConfigOption(*args)
1609
1611 r"""CPLBinaryToHex(int nBytes) -> retStringAndCPLFree *"""
1612 return _gdal.CPLBinaryToHex(*args)
1613
1615 r"""CPLHexToBinary(char const * pszHex, int * pnBytes) -> GByte *"""
1616 return _gdal.CPLHexToBinary(*args)
1617
1619 r"""FileFromMemBuffer(char const * utf8_path, GIntBig nBytes)"""
1620 return _gdal.FileFromMemBuffer(*args)
1621
1623 r"""Unlink(char const * utf8_path) -> VSI_RETVAL"""
1624 return _gdal.Unlink(*args)
1625
1627 r"""UnlinkBatch(char ** files) -> bool"""
1628 return _gdal.UnlinkBatch(*args)
1629
1633
1635 r"""Mkdir(char const * utf8_path, int mode) -> VSI_RETVAL"""
1636 return _gdal.Mkdir(*args)
1637
1639 r"""Rmdir(char const * utf8_path) -> VSI_RETVAL"""
1640 return _gdal.Rmdir(*args)
1641
1643 r"""MkdirRecursive(char const * utf8_path, int mode) -> VSI_RETVAL"""
1644 return _gdal.MkdirRecursive(*args)
1645
1647 r"""RmdirRecursive(char const * utf8_path) -> VSI_RETVAL"""
1648 return _gdal.RmdirRecursive(*args)
1649
1651 r"""Rename(char const * pszOld, char const * pszNew) -> VSI_RETVAL"""
1652 return _gdal.Rename(*args)
1653
1654 -def Sync(*args, **kwargs):
1655 r"""Sync(char const * pszSource, char const * pszTarget, char ** options=None, GDALProgressFunc callback=0, void * callback_data=None) -> bool"""
1656 return _gdal.Sync(*args, **kwargs)
1657
1659 r"""GetActualURL(char const * utf8_path) -> char const *"""
1660 return _gdal.GetActualURL(*args)
1661
1663 r"""GetSignedURL(char const * utf8_path, char ** options=None) -> retStringAndCPLFree *"""
1664 return _gdal.GetSignedURL(*args)
1665
1669
1674 r"""Proxy of C++ VSILFILE class."""
1675
1676 thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
1677
1679 raise AttributeError("No constructor defined")
1680 __repr__ = _swig_repr
1681
1682
1683 _gdal.VSILFILE_swigregister(VSILFILE)
1684
1685 VSI_STAT_EXISTS_FLAG = _gdal.VSI_STAT_EXISTS_FLAG
1686
1687 VSI_STAT_NATURE_FLAG = _gdal.VSI_STAT_NATURE_FLAG
1688
1689 VSI_STAT_SIZE_FLAG = _gdal.VSI_STAT_SIZE_FLAG
1692 r"""Proxy of C++ StatBuf class."""
1693
1694 thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
1695 __repr__ = _swig_repr
1696 mode = property(_gdal.StatBuf_mode_get, doc=r"""mode : int""")
1697 size = property(_gdal.StatBuf_size_get, doc=r"""size : GIntBig""")
1698 mtime = property(_gdal.StatBuf_mtime_get, doc=r"""mtime : GIntBig""")
1699
1701 r"""__init__(StatBuf self, StatBuf psStatBuf) -> StatBuf"""
1702 _gdal.StatBuf_swiginit(self, _gdal.new_StatBuf(*args))
1703 __swig_destroy__ = _gdal.delete_StatBuf
1704
1706 r"""IsDirectory(StatBuf self) -> int"""
1707 return _gdal.StatBuf_IsDirectory(self, *args)
1708
1709
1710 _gdal.StatBuf_swigregister(StatBuf)
1714 r"""VSIStatL(char const * utf8_path, int nFlags=0) -> int"""
1715 return _gdal.VSIStatL(*args)
1716
1720
1724
1726 r"""VSIFOpenL(char const * utf8_path, char const * pszMode) -> VSILFILE"""
1727 return _gdal.VSIFOpenL(*args)
1728
1730 r"""VSIFOpenExL(char const * utf8_path, char const * pszMode, int bSetError=FALSE, char ** options=None) -> VSILFILE"""
1731 return _gdal.VSIFOpenExL(*args)
1732
1734 r"""VSIFEofL(VSILFILE fp) -> int"""
1735 return _gdal.VSIFEofL(*args)
1736
1738 r"""VSIFFlushL(VSILFILE fp) -> int"""
1739 return _gdal.VSIFFlushL(*args)
1740
1742 r"""VSIFCloseL(VSILFILE fp) -> VSI_RETVAL"""
1743 return _gdal.VSIFCloseL(*args)
1744
1746 r"""VSIFSeekL(VSILFILE fp, GIntBig offset, int whence) -> int"""
1747 return _gdal.VSIFSeekL(*args)
1748
1750 r"""VSIFTellL(VSILFILE fp) -> GIntBig"""
1751 return _gdal.VSIFTellL(*args)
1752
1754 r"""VSIFTruncateL(VSILFILE fp, GIntBig length) -> int"""
1755 return _gdal.VSIFTruncateL(*args)
1756
1760 VSI_RANGE_STATUS_UNKNOWN = _gdal.VSI_RANGE_STATUS_UNKNOWN
1761
1762 VSI_RANGE_STATUS_DATA = _gdal.VSI_RANGE_STATUS_DATA
1763
1764 VSI_RANGE_STATUS_HOLE = _gdal.VSI_RANGE_STATUS_HOLE
1768 r"""VSIFGetRangeStatusL(VSILFILE fp, GIntBig offset, GIntBig length) -> int"""
1769 return _gdal.VSIFGetRangeStatusL(*args)
1770
1772 r"""VSIFWriteL(int nLen, int size, int memb, VSILFILE fp) -> int"""
1773 return _gdal.VSIFWriteL(*args)
1774
1778
1782
1786
1790
1792 r"""ParseCommandLine(char const * utf8_path) -> char **"""
1793 return _gdal.ParseCommandLine(*args)
1795 r"""Proxy of C++ GDALMajorObjectShadow class."""
1796
1797 thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
1798
1800 raise AttributeError("No constructor defined")
1801 __repr__ = _swig_repr
1802
1804 r"""GetDescription(MajorObject self) -> char const *"""
1805 return _gdal.MajorObject_GetDescription(self, *args)
1806
1808 r"""SetDescription(MajorObject self, char const * pszNewDesc)"""
1809 return _gdal.MajorObject_SetDescription(self, *args)
1810
1812 r"""GetMetadataDomainList(MajorObject self) -> char **"""
1813 return _gdal.MajorObject_GetMetadataDomainList(self, *args)
1814
1818
1822
1829
1833
1837
1842
1843
1844
1845 _gdal.MajorObject_swigregister(MajorObject)
1846
1847 -class Driver(MajorObject):
1848 r"""Proxy of C++ GDALDriverShadow class."""
1849
1850 thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
1851
1853 raise AttributeError("No constructor defined")
1854 __repr__ = _swig_repr
1855 ShortName = property(_gdal.Driver_ShortName_get, doc=r"""ShortName : p.q(const).char""")
1856 LongName = property(_gdal.Driver_LongName_get, doc=r"""LongName : p.q(const).char""")
1857 HelpTopic = property(_gdal.Driver_HelpTopic_get, doc=r"""HelpTopic : p.q(const).char""")
1858
1859 - def Create(self, *args, **kwargs):
1860 r"""Create(Driver self, char const * utf8_path, int xsize, int ysize, int bands=1, GDALDataType eType=GDT_Byte, char ** options=None) -> Dataset"""
1861 return _gdal.Driver_Create(self, *args, **kwargs)
1862
1864 r"""CreateMultiDimensional(Driver self, char const * utf8_path, char ** root_group_options=None, char ** options=None) -> Dataset"""
1865 return _gdal.Driver_CreateMultiDimensional(self, *args, **kwargs)
1866
1868 r"""CreateCopy(Driver self, char const * utf8_path, Dataset src, int strict=1, char ** options=None, GDALProgressFunc callback=0, void * callback_data=None) -> Dataset"""
1869 return _gdal.Driver_CreateCopy(self, *args, **kwargs)
1870
1872 r"""Delete(Driver self, char const * utf8_path) -> CPLErr"""
1873 return _gdal.Driver_Delete(self, *args)
1874
1876 r"""Rename(Driver self, char const * newName, char const * oldName) -> CPLErr"""
1877 return _gdal.Driver_Rename(self, *args)
1878
1880 r"""CopyFiles(Driver self, char const * newName, char const * oldName) -> CPLErr"""
1881 return _gdal.Driver_CopyFiles(self, *args)
1882
1884 r"""Register(Driver self) -> int"""
1885 return _gdal.Driver_Register(self, *args)
1886
1888 r"""Deregister(Driver self)"""
1889 return _gdal.Driver_Deregister(self, *args)
1890
1891
1892 _gdal.Driver_swigregister(Driver)
1893
1894 from . import ogr
1895 from . import osr
1896 -class ColorEntry(object):
1897 r"""Proxy of C++ GDALColorEntry class."""
1898
1899 thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
1900
1901 - def __init__(self, *args, **kwargs):
1902 raise AttributeError("No constructor defined")
1903 __repr__ = _swig_repr
1904 c1 = property(_gdal.ColorEntry_c1_get, _gdal.ColorEntry_c1_set, doc=r"""c1 : short""")
1905 c2 = property(_gdal.ColorEntry_c2_get, _gdal.ColorEntry_c2_set, doc=r"""c2 : short""")
1906 c3 = property(_gdal.ColorEntry_c3_get, _gdal.ColorEntry_c3_set, doc=r"""c3 : short""")
1907 c4 = property(_gdal.ColorEntry_c4_get, _gdal.ColorEntry_c4_set, doc=r"""c4 : short""")
1908
1909
1910 _gdal.ColorEntry_swigregister(ColorEntry)
1911
1912 -class GCP(object):
1913 r"""Proxy of C++ GDAL_GCP class."""
1914
1915 thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
1916 __repr__ = _swig_repr
1917 GCPX = property(_gdal.GCP_GCPX_get, _gdal.GCP_GCPX_set, doc=r"""GCPX : double""")
1918 GCPY = property(_gdal.GCP_GCPY_get, _gdal.GCP_GCPY_set, doc=r"""GCPY : double""")
1919 GCPZ = property(_gdal.GCP_GCPZ_get, _gdal.GCP_GCPZ_set, doc=r"""GCPZ : double""")
1920 GCPPixel = property(_gdal.GCP_GCPPixel_get, _gdal.GCP_GCPPixel_set, doc=r"""GCPPixel : double""")
1921 GCPLine = property(_gdal.GCP_GCPLine_get, _gdal.GCP_GCPLine_set, doc=r"""GCPLine : double""")
1922 Info = property(_gdal.GCP_Info_get, _gdal.GCP_Info_set, doc=r"""Info : p.char""")
1923 Id = property(_gdal.GCP_Id_get, _gdal.GCP_Id_set, doc=r"""Id : p.char""")
1924
1926 r"""__init__(GCP self, double x=0.0, double y=0.0, double z=0.0, double pixel=0.0, double line=0.0, char const * info="", char const * id="") -> GCP"""
1927 _gdal.GCP_swiginit(self, _gdal.new_GCP(*args))
1928 __swig_destroy__ = _gdal.delete_GCP
1929
1931 str = '%s (%.2fP,%.2fL) -> (%.7fE,%.7fN,%.2f) %s '\
1932 % (self.Id, self.GCPPixel, self.GCPLine,
1933 self.GCPX, self.GCPY, self.GCPZ, self.Info )
1934 return str
1935
1937 base = [gdalconst.CXT_Element,'GCP']
1938 base.append([gdalconst.CXT_Attribute,'Id',[gdalconst.CXT_Text,self.Id]])
1939 pixval = '%0.15E' % self.GCPPixel
1940 lineval = '%0.15E' % self.GCPLine
1941 xval = '%0.15E' % self.GCPX
1942 yval = '%0.15E' % self.GCPY
1943 zval = '%0.15E' % self.GCPZ
1944 base.append([gdalconst.CXT_Attribute,'Pixel',[gdalconst.CXT_Text,pixval]])
1945 base.append([gdalconst.CXT_Attribute,'Line',[gdalconst.CXT_Text,lineval]])
1946 base.append([gdalconst.CXT_Attribute,'X',[gdalconst.CXT_Text,xval]])
1947 base.append([gdalconst.CXT_Attribute,'Y',[gdalconst.CXT_Text,yval]])
1948 if with_Z:
1949 base.append([gdalconst.CXT_Attribute,'Z',[gdalconst.CXT_Text,zval]])
1950 return base
1951
1952
1953
1954 _gdal.GCP_swigregister(GCP)
1960
1964
1968
1972
1976
1980
1984
1988
1992
1996
2000
2004
2008
2012
2017 r"""Proxy of C++ CPLVirtualMemShadow class."""
2018
2019 thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
2020
2022 raise AttributeError("No constructor defined")
2023 __repr__ = _swig_repr
2024 __swig_destroy__ = _gdal.delete_VirtualMem
2025
2027 r"""GetAddr(VirtualMem self)"""
2028 return _gdal.VirtualMem_GetAddr(self, *args)
2029
2030 - def Pin(self, *args):
2031 r"""Pin(VirtualMem self, size_t start_offset=0, size_t nsize=0, int bWriteOp=0)"""
2032 return _gdal.VirtualMem_Pin(self, *args)
2033
2034
2035 _gdal.VirtualMem_swigregister(VirtualMem)
2038 r"""Proxy of C++ GDALAsyncReaderShadow class."""
2039
2040 thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
2041
2043 raise AttributeError("No constructor defined")
2044 __repr__ = _swig_repr
2045 __swig_destroy__ = _gdal.delete_AsyncReader
2046
2048 r"""GetNextUpdatedRegion(AsyncReader self, double timeout) -> GDALAsyncStatusType"""
2049 return _gdal.AsyncReader_GetNextUpdatedRegion(self, *args)
2050
2052 r"""GetBuffer(AsyncReader self)"""
2053 return _gdal.AsyncReader_GetBuffer(self, *args)
2054
2056 r"""LockBuffer(AsyncReader self, double timeout) -> int"""
2057 return _gdal.AsyncReader_LockBuffer(self, *args)
2058
2060 r"""UnlockBuffer(AsyncReader self)"""
2061 return _gdal.AsyncReader_UnlockBuffer(self, *args)
2062
2063
2064 _gdal.AsyncReader_swigregister(AsyncReader)
2067 r"""Proxy of C++ GDALDatasetShadow class."""
2068
2069 thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
2070
2072 raise AttributeError("No constructor defined")
2073 __repr__ = _swig_repr
2074 RasterXSize = property(_gdal.Dataset_RasterXSize_get, doc=r"""RasterXSize : int""")
2075 RasterYSize = property(_gdal.Dataset_RasterYSize_get, doc=r"""RasterYSize : int""")
2076 RasterCount = property(_gdal.Dataset_RasterCount_get, doc=r"""RasterCount : int""")
2077 __swig_destroy__ = _gdal.delete_Dataset
2078
2080 r"""GetDriver(Dataset self) -> Driver"""
2081 return _gdal.Dataset_GetDriver(self, *args)
2082
2084 r"""GetRasterBand(Dataset self, int nBand) -> Band"""
2085 return _gdal.Dataset_GetRasterBand(self, *args)
2086
2088 r"""GetRootGroup(Dataset self) -> Group"""
2089 return _gdal.Dataset_GetRootGroup(self, *args)
2090
2092 r"""GetProjection(Dataset self) -> char const *"""
2093 return _gdal.Dataset_GetProjection(self, *args)
2094
2096 r"""GetProjectionRef(Dataset self) -> char const *"""
2097 return _gdal.Dataset_GetProjectionRef(self, *args)
2098
2100 r"""GetSpatialRef(Dataset self) -> SpatialReference"""
2101 return _gdal.Dataset_GetSpatialRef(self, *args)
2102
2104 r"""SetProjection(Dataset self, char const * prj) -> CPLErr"""
2105 return _gdal.Dataset_SetProjection(self, *args)
2106
2108 r"""SetSpatialRef(Dataset self, SpatialReference srs) -> CPLErr"""
2109 return _gdal.Dataset_SetSpatialRef(self, *args)
2110
2114
2118
2120 r"""BuildOverviews(Dataset self, char const * resampling="NEAREST", int overviewlist=0, GDALProgressFunc callback=0, void * callback_data=None) -> int"""
2121 return _gdal.Dataset_BuildOverviews(self, *args, **kwargs)
2122
2124 r"""GetGCPCount(Dataset self) -> int"""
2125 return _gdal.Dataset_GetGCPCount(self, *args)
2126
2128 r"""GetGCPProjection(Dataset self) -> char const *"""
2129 return _gdal.Dataset_GetGCPProjection(self, *args)
2130
2132 r"""GetGCPSpatialRef(Dataset self) -> SpatialReference"""
2133 return _gdal.Dataset_GetGCPSpatialRef(self, *args)
2134
2136 r"""GetGCPs(Dataset self)"""
2137 return _gdal.Dataset_GetGCPs(self, *args)
2138
2140 r"""_SetGCPs(Dataset self, int nGCPs, char const * pszGCPProjection) -> CPLErr"""
2141 return _gdal.Dataset__SetGCPs(self, *args)
2142
2144 r"""_SetGCPs2(Dataset self, int nGCPs, SpatialReference hSRS) -> CPLErr"""
2145 return _gdal.Dataset__SetGCPs2(self, *args)
2146
2148 r"""FlushCache(Dataset self)"""
2149 return _gdal.Dataset_FlushCache(self, *args)
2150
2151 - def AddBand(self, *args, **kwargs):
2152 r"""AddBand(Dataset self, GDALDataType datatype=GDT_Byte, char ** options=None) -> CPLErr"""
2153 return _gdal.Dataset_AddBand(self, *args, **kwargs)
2154
2156 r"""CreateMaskBand(Dataset self, int nFlags) -> CPLErr"""
2157 return _gdal.Dataset_CreateMaskBand(self, *args)
2158
2160 r"""GetFileList(Dataset self) -> char **"""
2161 return _gdal.Dataset_GetFileList(self, *args)
2162
2164 r"""WriteRaster(Dataset self, int xoff, int yoff, int xsize, int ysize, GIntBig buf_len, int * buf_xsize=None, int * buf_ysize=None, GDALDataType * buf_type=None, int band_list=0, GIntBig * buf_pixel_space=None, GIntBig * buf_line_space=None, GIntBig * buf_band_space=None) -> CPLErr"""
2165 return _gdal.Dataset_WriteRaster(self, *args, **kwargs)
2166
2168 r"""AdviseRead(Dataset self, int xoff, int yoff, int xsize, int ysize, int * buf_xsize=None, int * buf_ysize=None, GDALDataType * buf_type=None, int band_list=0, char ** options=None) -> CPLErr"""
2169 return _gdal.Dataset_AdviseRead(self, *args)
2170
2172 r"""BeginAsyncReader(Dataset self, int xOff, int yOff, int xSize, int ySize, int buf_len, int buf_xsize, int buf_ysize, GDALDataType bufType=(GDALDataType) 0, int band_list=0, int nPixelSpace=0, int nLineSpace=0, int nBandSpace=0, char ** options=None) -> AsyncReader"""
2173 return _gdal.Dataset_BeginAsyncReader(self, *args, **kwargs)
2174
2176 r"""EndAsyncReader(Dataset self, AsyncReader ario)"""
2177 return _gdal.Dataset_EndAsyncReader(self, *args)
2178
2180 r"""GetVirtualMem(Dataset self, GDALRWFlag eRWFlag, int nXOff, int nYOff, int nXSize, int nYSize, int nBufXSize, int nBufYSize, GDALDataType eBufType, int band_list, int bIsBandSequential, size_t nCacheSize, size_t nPageSizeHint, char ** options=None) -> VirtualMem"""
2181 return _gdal.Dataset_GetVirtualMem(self, *args, **kwargs)
2182
2184 r"""GetTiledVirtualMem(Dataset self, GDALRWFlag eRWFlag, int nXOff, int nYOff, int nXSize, int nYSize, int nTileXSize, int nTileYSize, GDALDataType eBufType, int band_list, GDALTileOrganization eTileOrganization, size_t nCacheSize, char ** options=None) -> VirtualMem"""
2185 return _gdal.Dataset_GetTiledVirtualMem(self, *args, **kwargs)
2186
2188 r"""CreateLayer(Dataset self, char const * name, SpatialReference srs=None, OGRwkbGeometryType geom_type=wkbUnknown, char ** options=None) -> Layer"""
2189 return _gdal.Dataset_CreateLayer(self, *args, **kwargs)
2190
2192 r"""CopyLayer(Dataset self, Layer src_layer, char const * new_name, char ** options=None) -> Layer"""
2193 return _gdal.Dataset_CopyLayer(self, *args, **kwargs)
2194
2196 r"""DeleteLayer(Dataset self, int index) -> OGRErr"""
2197 return _gdal.Dataset_DeleteLayer(self, *args)
2198
2200 r"""GetLayerCount(Dataset self) -> int"""
2201 return _gdal.Dataset_GetLayerCount(self, *args)
2202
2204 r"""GetLayerByIndex(Dataset self, int index=0) -> Layer"""
2205 return _gdal.Dataset_GetLayerByIndex(self, *args)
2206
2208 r"""GetLayerByName(Dataset self, char const * layer_name) -> Layer"""
2209 return _gdal.Dataset_GetLayerByName(self, *args)
2210
2212 r"""ResetReading(Dataset self)"""
2213 return _gdal.Dataset_ResetReading(self, *args)
2214
2216 r"""GetNextFeature(Dataset self, bool include_layer=True, bool include_pct=False, GDALProgressFunc callback=0, void * callback_data=None) -> Feature"""
2217 return _gdal.Dataset_GetNextFeature(self, *args, **kwargs)
2218
2220 r"""TestCapability(Dataset self, char const * cap) -> bool"""
2221 return _gdal.Dataset_TestCapability(self, *args)
2222
2224 r"""ExecuteSQL(Dataset self, char const * statement, Geometry spatialFilter=None, char const * dialect="") -> Layer"""
2225 return _gdal.Dataset_ExecuteSQL(self, *args, **kwargs)
2226
2228 r"""ReleaseResultSet(Dataset self, Layer layer)"""
2229 return _gdal.Dataset_ReleaseResultSet(self, *args)
2230
2232 r"""GetStyleTable(Dataset self) -> StyleTable"""
2233 return _gdal.Dataset_GetStyleTable(self, *args)
2234
2236 r"""SetStyleTable(Dataset self, StyleTable table)"""
2237 return _gdal.Dataset_SetStyleTable(self, *args)
2238
2240 r"""AbortSQL(Dataset self) -> OGRErr"""
2241 return _gdal.Dataset_AbortSQL(self, *args)
2242
2244 r"""StartTransaction(Dataset self, int force=FALSE) -> OGRErr"""
2245 return _gdal.Dataset_StartTransaction(self, *args, **kwargs)
2246
2248 r"""CommitTransaction(Dataset self) -> OGRErr"""
2249 return _gdal.Dataset_CommitTransaction(self, *args)
2250
2252 r"""RollbackTransaction(Dataset self) -> OGRErr"""
2253 return _gdal.Dataset_RollbackTransaction(self, *args)
2254
2256 r"""ClearStatistics(Dataset self)"""
2257 return _gdal.Dataset_ClearStatistics(self, *args)
2258
2259 - def GetFieldDomain(self, *args):
2260 r"""GetFieldDomain(Dataset self, char const * name) -> FieldDomain"""
2261 return _gdal.Dataset_GetFieldDomain(self, *args)
2262
2263 - def AddFieldDomain(self, *args):
2264 r"""AddFieldDomain(Dataset self, FieldDomain fieldDomain) -> bool"""
2265 return _gdal.Dataset_AddFieldDomain(self, *args)
2266
2268 r"""ReadRaster1(Dataset self, double xoff, double yoff, double xsize, double ysize, int * buf_xsize=None, int * buf_ysize=None, GDALDataType * buf_type=None, int band_list=0, GIntBig * buf_pixel_space=None, GIntBig * buf_line_space=None, GIntBig * buf_band_space=None, GDALRIOResampleAlg resample_alg=GRIORA_NearestNeighbour, GDALProgressFunc callback=0, void * callback_data=None, void * inputOutputBuf=None) -> CPLErr"""
2269 return _gdal.Dataset_ReadRaster1(self, *args, **kwargs)
2270
2271
2272 - def ReadAsArray(self, xoff=0, yoff=0, xsize=None, ysize=None, buf_obj=None,
2273 buf_xsize=None, buf_ysize=None, buf_type=None,
2274 resample_alg=gdalconst.GRIORA_NearestNeighbour,
2275 callback=None,
2276 callback_data=None,
2277 interleave='band',
2278 band_list=None):
2279 """ Reading a chunk of a GDAL band into a numpy array. The optional (buf_xsize,buf_ysize,buf_type)
2280 parameters should generally not be specified if buf_obj is specified. The array is returned"""
2281
2282 from osgeo import gdal_array
2283 return gdal_array.DatasetReadAsArray(self, xoff, yoff, xsize, ysize, buf_obj,
2284 buf_xsize, buf_ysize, buf_type,
2285 resample_alg=resample_alg,
2286 callback=callback,
2287 callback_data=callback_data,
2288 interleave=interleave,
2289 band_list=band_list)
2290
2297 from osgeo import gdal_array
2298
2299 return gdal_array.DatasetWriteArray(self, array, xoff, yoff,
2300 band_list=band_list,
2301 interleave=interleave,
2302 resample_alg=resample_alg,
2303 callback=callback,
2304 callback_data=callback_data)
2305
2306 - def WriteRaster(self, xoff, yoff, xsize, ysize,
2307 buf_string,
2308 buf_xsize=None, buf_ysize=None, buf_type=None,
2309 band_list=None,
2310 buf_pixel_space=None, buf_line_space=None, buf_band_space=None ):
2311
2312 if buf_xsize is None:
2313 buf_xsize = xsize
2314 if buf_ysize is None:
2315 buf_ysize = ysize
2316 if band_list is None:
2317 band_list = list(range(1, self.RasterCount + 1))
2318
2319
2320
2321 if type(buf_string).__name__ == 'ndarray' and \
2322 buf_xsize == xsize and buf_ysize == ysize and buf_type is None and \
2323 buf_pixel_space is None and buf_line_space is None and buf_band_space is None:
2324 return self.WriteArray(buf_string, xoff=xoff, yoff=yoff,
2325 band_list=band_list)
2326 if buf_type is None:
2327 buf_type = self.GetRasterBand(1).DataType
2328
2329 return _gdal.Dataset_WriteRaster(self,
2330 xoff, yoff, xsize, ysize,
2331 buf_string, buf_xsize, buf_ysize, buf_type, band_list,
2332 buf_pixel_space, buf_line_space, buf_band_space )
2333
2334 - def ReadRaster(self, xoff=0, yoff=0, xsize=None, ysize=None,
2335 buf_xsize=None, buf_ysize=None, buf_type=None,
2336 band_list=None,
2337 buf_pixel_space=None, buf_line_space=None, buf_band_space=None,
2338 resample_alg=gdalconst.GRIORA_NearestNeighbour,
2339 callback=None,
2340 callback_data=None,
2341 buf_obj=None):
2342
2343 if xsize is None:
2344 xsize = self.RasterXSize
2345 if ysize is None:
2346 ysize = self.RasterYSize
2347 if band_list is None:
2348 band_list = list(range(1, self.RasterCount + 1))
2349 if buf_xsize is None:
2350 buf_xsize = xsize
2351 if buf_ysize is None:
2352 buf_ysize = ysize
2353
2354 if buf_type is None:
2355 buf_type = self.GetRasterBand(1).DataType;
2356
2357 return _gdal.Dataset_ReadRaster1(self, xoff, yoff, xsize, ysize,
2358 buf_xsize, buf_ysize, buf_type,
2359 band_list, buf_pixel_space, buf_line_space, buf_band_space,
2360 resample_alg, callback, callback_data, buf_obj )
2361
2362 - def GetVirtualMemArray(self, eAccess=gdalconst.GF_Read, xoff=0, yoff=0,
2363 xsize=None, ysize=None, bufxsize=None, bufysize=None,
2364 datatype=None, band_list=None, band_sequential = True,
2365 cache_size = 10 * 1024 * 1024, page_size_hint = 0,
2366 options=None):
2367 """Return a NumPy array for the dataset, seen as a virtual memory mapping.
2368 If there are several bands and band_sequential = True, an element is
2369 accessed with array[band][y][x].
2370 If there are several bands and band_sequential = False, an element is
2371 accessed with array[y][x][band].
2372 If there is only one band, an element is accessed with array[y][x].
2373 Any reference to the array must be dropped before the last reference to the
2374 related dataset is also dropped.
2375 """
2376 from osgeo import gdal_array
2377 if xsize is None:
2378 xsize = self.RasterXSize
2379 if ysize is None:
2380 ysize = self.RasterYSize
2381 if bufxsize is None:
2382 bufxsize = self.RasterXSize
2383 if bufysize is None:
2384 bufysize = self.RasterYSize
2385 if datatype is None:
2386 datatype = self.GetRasterBand(1).DataType
2387 if band_list is None:
2388 band_list = list(range(1, self.RasterCount + 1))
2389 if options is None:
2390 virtualmem = self.GetVirtualMem(eAccess, xoff, yoff, xsize, ysize, bufxsize, bufysize, datatype, band_list, band_sequential, cache_size, page_size_hint)
2391 else:
2392 virtualmem = self.GetVirtualMem(eAccess, xoff, yoff, xsize, ysize, bufxsize, bufysize, datatype, band_list, band_sequential, cache_size, page_size_hint, options)
2393 return gdal_array.VirtualMemGetArray( virtualmem )
2394
2395 - def GetTiledVirtualMemArray(self, eAccess=gdalconst.GF_Read, xoff=0, yoff=0,
2396 xsize=None, ysize=None, tilexsize=256, tileysize=256,
2397 datatype=None, band_list=None, tile_organization=gdalconst.GTO_BSQ,
2398 cache_size = 10 * 1024 * 1024, options=None):
2399 """Return a NumPy array for the dataset, seen as a virtual memory mapping with
2400 a tile organization.
2401 If there are several bands and tile_organization = gdal.GTO_TIP, an element is
2402 accessed with array[tiley][tilex][y][x][band].
2403 If there are several bands and tile_organization = gdal.GTO_BIT, an element is
2404 accessed with array[tiley][tilex][band][y][x].
2405 If there are several bands and tile_organization = gdal.GTO_BSQ, an element is
2406 accessed with array[band][tiley][tilex][y][x].
2407 If there is only one band, an element is accessed with array[tiley][tilex][y][x].
2408 Any reference to the array must be dropped before the last reference to the
2409 related dataset is also dropped.
2410 """
2411 from osgeo import gdal_array
2412 if xsize is None:
2413 xsize = self.RasterXSize
2414 if ysize is None:
2415 ysize = self.RasterYSize
2416 if datatype is None:
2417 datatype = self.GetRasterBand(1).DataType
2418 if band_list is None:
2419 band_list = list(range(1, self.RasterCount + 1))
2420 if options is None:
2421 virtualmem = self.GetTiledVirtualMem(eAccess,xoff,yoff,xsize,ysize,tilexsize,tileysize,datatype,band_list,tile_organization,cache_size)
2422 else:
2423 virtualmem = self.GetTiledVirtualMem(eAccess,xoff,yoff,xsize,ysize,tilexsize,tileysize,datatype,band_list,tile_organization,cache_size, options)
2424 return gdal_array.VirtualMemGetArray( virtualmem )
2425
2427 sd_list = []
2428
2429 sd = self.GetMetadata('SUBDATASETS')
2430 if sd is None:
2431 return sd_list
2432
2433 i = 1
2434 while 'SUBDATASET_'+str(i)+'_NAME' in sd:
2435 sd_list.append((sd['SUBDATASET_'+str(i)+'_NAME'],
2436 sd['SUBDATASET_'+str(i)+'_DESC']))
2437 i = i + 1
2438 return sd_list
2439
2440 - def BeginAsyncReader(self, xoff, yoff, xsize, ysize, buf_obj=None, buf_xsize=None, buf_ysize=None, buf_type=None, band_list=None, options=None):
2441 if band_list is None:
2442 band_list = list(range(1, self.RasterCount + 1))
2443 if buf_xsize is None:
2444 buf_xsize = 0;
2445 if buf_ysize is None:
2446 buf_ysize = 0;
2447 if buf_type is None:
2448 buf_type = gdalconst.GDT_Byte
2449
2450 if buf_xsize <= 0:
2451 buf_xsize = xsize
2452 if buf_ysize <= 0:
2453 buf_ysize = ysize
2454 options = [] if options is None else options
2455
2456 if buf_obj is None:
2457 from sys import version_info
2458 nRequiredSize = int(buf_xsize * buf_ysize * len(band_list) * (_gdal.GetDataTypeSize(buf_type) / 8))
2459 if version_info >= (3, 0, 0):
2460 buf_obj_ar = [None]
2461 exec("buf_obj_ar[0] = b' ' * nRequiredSize")
2462 buf_obj = buf_obj_ar[0]
2463 else:
2464 buf_obj = ' ' * nRequiredSize
2465 return _gdal.Dataset_BeginAsyncReader(self, xoff, yoff, xsize, ysize, buf_obj, buf_xsize, buf_ysize, buf_type, band_list, 0, 0, 0, options)
2466
2468 """Return the layer given an index or a name"""
2469 if isinstance(iLayer, str):
2470 return self.GetLayerByName(str(iLayer))
2471 elif isinstance(iLayer, int):
2472 return self.GetLayerByIndex(iLayer)
2473 else:
2474 raise TypeError("Input %s is not of String or Int type" % type(iLayer))
2475
2477 """Deletes the layer given an index or layer name"""
2478 if isinstance(value, str):
2479 for i in range(self.GetLayerCount()):
2480 name = self.GetLayer(i).GetName()
2481 if name == value:
2482 return _gdal.Dataset_DeleteLayer(self, i)
2483 raise ValueError("Layer %s not found to delete" % value)
2484 elif isinstance(value, int):
2485 return _gdal.Dataset_DeleteLayer(self, value)
2486 else:
2487 raise TypeError("Input %s is not of String or Int type" % type(value))
2488
2489 - def SetGCPs(self, gcps, wkt_or_spatial_ref):
2490 if isinstance(wkt_or_spatial_ref, str):
2491 return self._SetGCPs(gcps, wkt_or_spatial_ref)
2492 else:
2493 return self._SetGCPs2(gcps, wkt_or_spatial_ref)
2494
2495
2496
2497 _gdal.Dataset_swigregister(Dataset)
2498
2499 -class Group(object):
2500 r"""Proxy of C++ GDALGroupHS class."""
2501
2502 thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
2503
2505 raise AttributeError("No constructor defined")
2506 __repr__ = _swig_repr
2507 __swig_destroy__ = _gdal.delete_Group
2508
2510 r"""GetName(Group self) -> char const *"""
2511 return _gdal.Group_GetName(self, *args)
2512
2514 r"""GetFullName(Group self) -> char const *"""
2515 return _gdal.Group_GetFullName(self, *args)
2516
2518 r"""GetMDArrayNames(Group self, char ** options=None) -> char **"""
2519 return _gdal.Group_GetMDArrayNames(self, *args)
2520
2522 r"""OpenMDArray(Group self, char const * name, char ** options=None) -> MDArray"""
2523 return _gdal.Group_OpenMDArray(self, *args)
2524
2526 r"""OpenMDArrayFromFullname(Group self, char const * name, char ** options=None) -> MDArray"""
2527 return _gdal.Group_OpenMDArrayFromFullname(self, *args)
2528
2530 r"""ResolveMDArray(Group self, char const * name, char const * starting_point, char ** options=None) -> MDArray"""
2531 return _gdal.Group_ResolveMDArray(self, *args)
2532
2534 r"""GetGroupNames(Group self, char ** options=None) -> char **"""
2535 return _gdal.Group_GetGroupNames(self, *args)
2536
2538 r"""OpenGroup(Group self, char const * name, char ** options=None) -> Group"""
2539 return _gdal.Group_OpenGroup(self, *args)
2540
2542 r"""OpenGroupFromFullname(Group self, char const * name, char ** options=None) -> Group"""
2543 return _gdal.Group_OpenGroupFromFullname(self, *args)
2544
2546 r"""GetDimensions(Group self, char ** options=None)"""
2547 return _gdal.Group_GetDimensions(self, *args)
2548
2550 r"""GetAttribute(Group self, char const * name) -> Attribute"""
2551 return _gdal.Group_GetAttribute(self, *args)
2552
2554 r"""GetAttributes(Group self, char ** options=None)"""
2555 return _gdal.Group_GetAttributes(self, *args)
2556
2558 r"""GetStructuralInfo(Group self) -> char **"""
2559 return _gdal.Group_GetStructuralInfo(self, *args)
2560
2562 r"""CreateGroup(Group self, char const * name, char ** options=None) -> Group"""
2563 return _gdal.Group_CreateGroup(self, *args)
2564
2566 r"""CreateDimension(Group self, char const * name, char const * type, char const * direction, unsigned long long size, char ** options=None) -> Dimension"""
2567 return _gdal.Group_CreateDimension(self, *args)
2568
2570 r"""CreateMDArray(Group self, char const * name, int nDimensions, ExtendedDataType data_type, char ** options=None) -> MDArray"""
2571 return _gdal.Group_CreateMDArray(self, *args)
2572
2574 r"""CreateAttribute(Group self, char const * name, int nDimensions, ExtendedDataType data_type, char ** options=None) -> Attribute"""
2575 return _gdal.Group_CreateAttribute(self, *args)
2576
2577
2578 _gdal.Group_swigregister(Group)
2581 r"""Proxy of C++ Statistics class."""
2582
2583 thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
2584 __repr__ = _swig_repr
2585 min = property(_gdal.Statistics_min_get, doc=r"""min : double""")
2586 max = property(_gdal.Statistics_max_get, doc=r"""max : double""")
2587 mean = property(_gdal.Statistics_mean_get, doc=r"""mean : double""")
2588 std_dev = property(_gdal.Statistics_std_dev_get, doc=r"""std_dev : double""")
2589 valid_count = property(_gdal.Statistics_valid_count_get, doc=r"""valid_count : GIntBig""")
2590 __swig_destroy__ = _gdal.delete_Statistics
2591
2593 r"""__init__(Statistics self) -> Statistics"""
2594 _gdal.Statistics_swiginit(self, _gdal.new_Statistics(*args))
2595
2596
2597 _gdal.Statistics_swigregister(Statistics)
2600 r"""Proxy of C++ GDALMDArrayHS class."""
2601
2602 thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
2603
2605 raise AttributeError("No constructor defined")
2606 __repr__ = _swig_repr
2607 __swig_destroy__ = _gdal.delete_MDArray
2608
2610 r"""GetName(MDArray self) -> char const *"""
2611 return _gdal.MDArray_GetName(self, *args)
2612
2614 r"""GetFullName(MDArray self) -> char const *"""
2615 return _gdal.MDArray_GetFullName(self, *args)
2616
2618 r"""GetTotalElementsCount(MDArray self) -> unsigned long long"""
2619 return _gdal.MDArray_GetTotalElementsCount(self, *args)
2620
2622 r"""GetDimensionCount(MDArray self) -> size_t"""
2623 return _gdal.MDArray_GetDimensionCount(self, *args)
2624
2626 r"""GetDimensions(MDArray self)"""
2627 return _gdal.MDArray_GetDimensions(self, *args)
2628
2630 r"""GetBlockSize(MDArray self)"""
2631 return _gdal.MDArray_GetBlockSize(self, *args)
2632
2634 r"""GetProcessingChunkSize(MDArray self, size_t nMaxChunkMemory)"""
2635 return _gdal.MDArray_GetProcessingChunkSize(self, *args)
2636
2638 r"""GetDataType(MDArray self) -> ExtendedDataType"""
2639 return _gdal.MDArray_GetDataType(self, *args)
2640
2642 r"""GetStructuralInfo(MDArray self) -> char **"""
2643 return _gdal.MDArray_GetStructuralInfo(self, *args)
2644
2645 - def Read(self, *args):
2646 r"""Read(MDArray self, int nDims1, int nDims2, int nDims3, int nDims4, ExtendedDataType buffer_datatype) -> CPLErr"""
2647 return _gdal.MDArray_Read(self, *args)
2648
2650 r"""WriteStringArray(MDArray self, int nDims1, int nDims2, int nDims3, ExtendedDataType buffer_datatype, char ** options) -> CPLErr"""
2651 return _gdal.MDArray_WriteStringArray(self, *args)
2652
2653 - def Write(self, *args):
2654 r"""Write(MDArray self, int nDims1, int nDims2, int nDims3, int nDims4, ExtendedDataType buffer_datatype, GIntBig buf_len) -> CPLErr"""
2655 return _gdal.MDArray_Write(self, *args)
2656
2658 r"""AdviseRead(MDArray self, int nDims1, int nDims2) -> CPLErr"""
2659 return _gdal.MDArray_AdviseRead(self, *args)
2660
2662 r"""GetAttribute(MDArray self, char const * name) -> Attribute"""
2663 return _gdal.MDArray_GetAttribute(self, *args)
2664
2666 r"""GetAttributes(MDArray self, char ** options=None)"""
2667 return _gdal.MDArray_GetAttributes(self, *args)
2668
2670 r"""CreateAttribute(MDArray self, char const * name, int nDimensions, ExtendedDataType data_type, char ** options=None) -> Attribute"""
2671 return _gdal.MDArray_CreateAttribute(self, *args)
2672
2674 r"""GetNoDataValueAsRaw(MDArray self) -> CPLErr"""
2675 return _gdal.MDArray_GetNoDataValueAsRaw(self, *args)
2676
2678 r"""GetNoDataValueAsDouble(MDArray self)"""
2679 return _gdal.MDArray_GetNoDataValueAsDouble(self, *args)
2680
2682 r"""SetNoDataValueDouble(MDArray self, double d) -> CPLErr"""
2683 return _gdal.MDArray_SetNoDataValueDouble(self, *args)
2684
2686 r"""SetNoDataValueRaw(MDArray self, GIntBig nLen) -> CPLErr"""
2687 return _gdal.MDArray_SetNoDataValueRaw(self, *args)
2688
2690 r"""DeleteNoDataValue(MDArray self) -> CPLErr"""
2691 return _gdal.MDArray_DeleteNoDataValue(self, *args)
2692
2694 r"""GetOffset(MDArray self)"""
2695 return _gdal.MDArray_GetOffset(self, *args)
2696
2698 r"""GetOffsetStorageType(MDArray self) -> GDALDataType"""
2699 return _gdal.MDArray_GetOffsetStorageType(self, *args)
2700
2702 r"""GetScale(MDArray self)"""
2703 return _gdal.MDArray_GetScale(self, *args)
2704
2706 r"""GetScaleStorageType(MDArray self) -> GDALDataType"""
2707 return _gdal.MDArray_GetScaleStorageType(self, *args)
2708
2710 r"""SetOffset(MDArray self, double val, GDALDataType storageType=GDT_Unknown) -> CPLErr"""
2711 return _gdal.MDArray_SetOffset(self, *args, **kwargs)
2712
2714 r"""SetScale(MDArray self, double val, GDALDataType storageType=GDT_Unknown) -> CPLErr"""
2715 return _gdal.MDArray_SetScale(self, *args, **kwargs)
2716
2718 r"""SetUnit(MDArray self, char const * unit) -> CPLErr"""
2719 return _gdal.MDArray_SetUnit(self, *args)
2720
2722 r"""GetUnit(MDArray self) -> char const *"""
2723 return _gdal.MDArray_GetUnit(self, *args)
2724
2726 r"""SetSpatialRef(MDArray self, SpatialReference srs) -> OGRErr"""
2727 return _gdal.MDArray_SetSpatialRef(self, *args)
2728
2730 r"""GetSpatialRef(MDArray self) -> SpatialReference"""
2731 return _gdal.MDArray_GetSpatialRef(self, *args)
2732
2734 r"""GetView(MDArray self, char const * viewExpr) -> MDArray"""
2735 return _gdal.MDArray_GetView(self, *args)
2736
2738 r"""Transpose(MDArray self, int nList) -> MDArray"""
2739 return _gdal.MDArray_Transpose(self, *args)
2740
2742 r"""GetUnscaled(MDArray self) -> MDArray"""
2743 return _gdal.MDArray_GetUnscaled(self, *args)
2744
2746 r"""GetMask(MDArray self, char ** options=None) -> MDArray"""
2747 return _gdal.MDArray_GetMask(self, *args)
2748
2750 r"""AsClassicDataset(MDArray self, size_t iXDim, size_t iYDim) -> Dataset"""
2751 return _gdal.MDArray_AsClassicDataset(self, *args)
2752
2754 r"""GetStatistics(MDArray self, Dataset ds=None, bool approx_ok=FALSE, bool force=TRUE, GDALProgressFunc callback=0, void * callback_data=None) -> Statistics"""
2755 return _gdal.MDArray_GetStatistics(self, *args, **kwargs)
2756
2758 r"""ComputeStatistics(MDArray self, Dataset ds=None, bool approx_ok=FALSE, GDALProgressFunc callback=0, void * callback_data=None) -> Statistics"""
2759 return _gdal.MDArray_ComputeStatistics(self, *args, **kwargs)
2760
2761 - def Read(self,
2762 array_start_idx = None,
2763 count = None,
2764 array_step = None,
2765 buffer_stride = None,
2766 buffer_datatype = None):
2767 if not array_start_idx:
2768 array_start_idx = [0] * self.GetDimensionCount()
2769 if not count:
2770 count = [ dim.GetSize() for dim in self.GetDimensions() ]
2771 if not array_step:
2772 array_step = [1] * self.GetDimensionCount()
2773 if not buffer_stride:
2774 stride = 1
2775 buffer_stride = []
2776
2777
2778 for cnt in reversed(count):
2779 buffer_stride.append(stride)
2780 stride *= cnt
2781 buffer_stride.reverse()
2782 if not buffer_datatype:
2783 buffer_datatype = self.GetDataType()
2784 return _gdal.MDArray_Read(self, array_start_idx, count, array_step, buffer_stride, buffer_datatype)
2785
2786 - def ReadAsArray(self,
2787 array_start_idx = None,
2788 count = None,
2789 array_step = None,
2790 buffer_datatype = None,
2791 buf_obj = None):
2795
2796 - def AdviseRead(self, array_start_idx = None, count = None):
2802
2804
2805 def stringify(v):
2806 if v == Ellipsis:
2807 return '...'
2808 if isinstance(v, slice):
2809 return ':'.join([str(x) if x is not None else '' for x in (v.start, v.stop, v.step)])
2810 if isinstance(v, str):
2811 return v
2812 if isinstance(v, (int, type(12345678901234))):
2813 return str(v)
2814 try:
2815 import numpy as np
2816 if v == np.newaxis:
2817 return 'newaxis'
2818 except:
2819 pass
2820
2821 return str(v)
2822
2823 if isinstance(item, str):
2824 return self.GetView('["' + item.replace('\\', '\\\\').replace('"', '\\"') + '"]')
2825 elif isinstance(item, slice):
2826 return self.GetView('[' + stringify(item) + ']')
2827 elif isinstance(item, tuple):
2828 return self.GetView('[' + ','.join([stringify(x) for x in item]) + ']')
2829 else:
2830 return self.GetView('[' + stringify(item) + ']')
2831
2832 - def Write(self,
2833 buffer,
2834 array_start_idx = None,
2835 count = None,
2836 array_step = None,
2837 buffer_stride = None,
2838 buffer_datatype = None):
2839
2840 dimCount = self.GetDimensionCount()
2841
2842
2843
2844 if type(buffer).__name__ == 'ndarray' and \
2845 count is None and buffer_stride is None and buffer_datatype is None:
2846 return self.WriteArray(buffer, array_start_idx=array_start_idx, array_step=array_step)
2847
2848
2849 if dimCount == 1 and type(buffer).__name__ == 'array' and \
2850 count is None and buffer_stride is None and buffer_datatype is None:
2851 map_typecode_itemsize_to_gdal = {
2852 ('B',1): GDT_Byte,
2853 ('h',2): GDT_Int16,
2854 ('H',2): GDT_UInt16,
2855 ('i',4): GDT_Int32,
2856 ('I',4): GDT_UInt32,
2857 ('l',4): GDT_Int32,
2858
2859
2860
2861 ('f', 4): GDT_Float32,
2862 ('d', 8): GDT_Float64
2863 }
2864 key = (buffer.typecode, buffer.itemsize)
2865 if key not in map_typecode_itemsize_to_gdal:
2866 raise Exception("unhandled type for buffer of type array")
2867 buffer_datatype = ExtendedDataType.Create(map_typecode_itemsize_to_gdal[key])
2868
2869
2870 elif dimCount == 1 and type(buffer) == type([]) and len(buffer) != 0 \
2871 and self.GetDataType().GetClass() != GEDTC_STRING:
2872 buffer_datatype = GDT_Int32
2873 for v in buffer:
2874 if isinstance(v, int):
2875 if v >= (1 << 31) or v < -(1 << 31):
2876 buffer_datatype = GDT_Float64
2877 elif isinstance(v, float):
2878 buffer_datatype = GDT_Float64
2879 else:
2880 raise ValueError('Only lists with integer or float elements are supported')
2881 import array
2882 buffer = array.array('d' if buffer_datatype == GDT_Float64 else 'i', buffer)
2883 buffer_datatype = ExtendedDataType.Create(buffer_datatype)
2884
2885 if not buffer_datatype:
2886 buffer_datatype = self.GetDataType()
2887
2888 is_1d_string = self.GetDataType().GetClass() == GEDTC_STRING and buffer_datatype.GetClass() == GEDTC_STRING and dimCount == 1
2889
2890 if not array_start_idx:
2891 array_start_idx = [0] * dimCount
2892
2893 if not count:
2894 if is_1d_string:
2895 assert type(buffer) == type([])
2896 count = [ len(buffer) ]
2897 else:
2898 count = [ dim.GetSize() for dim in self.GetDimensions() ]
2899
2900 if not array_step:
2901 array_step = [1] * dimCount
2902
2903 if not buffer_stride:
2904 stride = 1
2905 buffer_stride = []
2906
2907
2908 for cnt in reversed(count):
2909 buffer_stride.append(stride)
2910 stride *= cnt
2911 buffer_stride.reverse()
2912
2913 if is_1d_string:
2914 return _gdal.MDArray_WriteStringArray(self, array_start_idx, count, array_step, buffer_datatype, buffer)
2915
2916 return _gdal.MDArray_Write(self, array_start_idx, count, array_step, buffer_stride, buffer_datatype, buffer)
2917
2918 - def WriteArray(self, array,
2919 array_start_idx = None,
2920 array_step = None):
2924
2925 - def ReadAsMaskedArray(self,
2926 array_start_idx = None,
2927 count = None,
2928 array_step = None):
2929 """ Return a numpy masked array of ReadAsArray() with GetMask() """
2930 import numpy
2931 mask = self.GetMask()
2932 if mask is not None:
2933 array = self.ReadAsArray(array_start_idx, count, array_step)
2934 mask_array = mask.ReadAsArray(array_start_idx, count, array_step)
2935 bool_array = ~mask_array.astype(bool)
2936 return numpy.ma.array(array, mask=bool_array)
2937 else:
2938 return numpy.ma.array(self.ReadAsArray(array_start_idx, count, array_step), mask=None)
2939
2941 """ Return the shape of the array """
2942 if not self.GetDimensionCount():
2943 return None
2944 shp = ()
2945 for dim in self.GetDimensions():
2946 shp += (dim.GetSize(),)
2947 return shp
2948
2949 shape = property(fget=GetShape, doc='Returns the shape of the array.')
2950
2951
2952
2953
2954 _gdal.MDArray_swigregister(MDArray)
2957 r"""Proxy of C++ GDALAttributeHS class."""
2958
2959 thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
2960
2962 raise AttributeError("No constructor defined")
2963 __repr__ = _swig_repr
2964 __swig_destroy__ = _gdal.delete_Attribute
2965
2967 r"""GetName(Attribute self) -> char const *"""
2968 return _gdal.Attribute_GetName(self, *args)
2969
2971 r"""GetFullName(Attribute self) -> char const *"""
2972 return _gdal.Attribute_GetFullName(self, *args)
2973
2975 r"""GetTotalElementsCount(Attribute self) -> unsigned long long"""
2976 return _gdal.Attribute_GetTotalElementsCount(self, *args)
2977
2979 r"""GetDimensionCount(Attribute self) -> size_t"""
2980 return _gdal.Attribute_GetDimensionCount(self, *args)
2981
2983 r"""GetDimensionsSize(Attribute self)"""
2984 return _gdal.Attribute_GetDimensionsSize(self, *args)
2985
2987 r"""GetDataType(Attribute self) -> ExtendedDataType"""
2988 return _gdal.Attribute_GetDataType(self, *args)
2989
2991 r"""ReadAsRaw(Attribute self) -> CPLErr"""
2992 return _gdal.Attribute_ReadAsRaw(self, *args)
2993
2995 r"""ReadAsString(Attribute self) -> char const *"""
2996 return _gdal.Attribute_ReadAsString(self, *args)
2997
2999 r"""ReadAsInt(Attribute self) -> int"""
3000 return _gdal.Attribute_ReadAsInt(self, *args)
3001
3003 r"""ReadAsDouble(Attribute self) -> double"""
3004 return _gdal.Attribute_ReadAsDouble(self, *args)
3005
3007 r"""ReadAsStringArray(Attribute self) -> char **"""
3008 return _gdal.Attribute_ReadAsStringArray(self, *args)
3009
3011 r"""ReadAsIntArray(Attribute self)"""
3012 return _gdal.Attribute_ReadAsIntArray(self, *args)
3013
3015 r"""ReadAsDoubleArray(Attribute self)"""
3016 return _gdal.Attribute_ReadAsDoubleArray(self, *args)
3017
3019 r"""WriteRaw(Attribute self, GIntBig nLen) -> CPLErr"""
3020 return _gdal.Attribute_WriteRaw(self, *args)
3021
3023 r"""WriteString(Attribute self, char const * val) -> CPLErr"""
3024 return _gdal.Attribute_WriteString(self, *args)
3025
3027 r"""WriteStringArray(Attribute self, char ** vals) -> CPLErr"""
3028 return _gdal.Attribute_WriteStringArray(self, *args)
3029
3031 r"""WriteInt(Attribute self, int val) -> CPLErr"""
3032 return _gdal.Attribute_WriteInt(self, *args)
3033
3035 r"""WriteDouble(Attribute self, double val) -> CPLErr"""
3036 return _gdal.Attribute_WriteDouble(self, *args)
3037
3039 r"""WriteDoubleArray(Attribute self, int nList) -> CPLErr"""
3040 return _gdal.Attribute_WriteDoubleArray(self, *args)
3041
3042
3062
3084
3085
3086
3087
3088 _gdal.Attribute_swigregister(Attribute)
3091 r"""Proxy of C++ GDALDimensionHS class."""
3092
3093 thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
3094
3096 raise AttributeError("No constructor defined")
3097 __repr__ = _swig_repr
3098 __swig_destroy__ = _gdal.delete_Dimension
3099
3101 r"""GetName(Dimension self) -> char const *"""
3102 return _gdal.Dimension_GetName(self, *args)
3103
3105 r"""GetFullName(Dimension self) -> char const *"""
3106 return _gdal.Dimension_GetFullName(self, *args)
3107
3109 r"""GetType(Dimension self) -> char const *"""
3110 return _gdal.Dimension_GetType(self, *args)
3111
3113 r"""GetDirection(Dimension self) -> char const *"""
3114 return _gdal.Dimension_GetDirection(self, *args)
3115
3117 r"""GetSize(Dimension self) -> unsigned long long"""
3118 return _gdal.Dimension_GetSize(self, *args)
3119
3121 r"""GetIndexingVariable(Dimension self) -> MDArray"""
3122 return _gdal.Dimension_GetIndexingVariable(self, *args)
3123
3125 r"""SetIndexingVariable(Dimension self, MDArray array) -> bool"""
3126 return _gdal.Dimension_SetIndexingVariable(self, *args)
3127
3128
3129 _gdal.Dimension_swigregister(Dimension)
3130
3131 GEDTC_NUMERIC = _gdal.GEDTC_NUMERIC
3132
3133 GEDTC_STRING = _gdal.GEDTC_STRING
3134
3135 GEDTC_COMPOUND = _gdal.GEDTC_COMPOUND
3138 r"""Proxy of C++ GDALExtendedDataTypeHS class."""
3139
3140 thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
3141
3143 raise AttributeError("No constructor defined")
3144 __repr__ = _swig_repr
3145 __swig_destroy__ = _gdal.delete_ExtendedDataType
3146
3147 @staticmethod
3151
3152 @staticmethod
3156
3157 @staticmethod
3161
3163 r"""GetName(ExtendedDataType self) -> char const *"""
3164 return _gdal.ExtendedDataType_GetName(self, *args)
3165
3167 r"""GetClass(ExtendedDataType self) -> GDALExtendedDataTypeClass"""
3168 return _gdal.ExtendedDataType_GetClass(self, *args)
3169
3171 r"""GetNumericDataType(ExtendedDataType self) -> GDALDataType"""
3172 return _gdal.ExtendedDataType_GetNumericDataType(self, *args)
3173
3175 r"""GetSize(ExtendedDataType self) -> size_t"""
3176 return _gdal.ExtendedDataType_GetSize(self, *args)
3177
3179 r"""GetMaxStringLength(ExtendedDataType self) -> size_t"""
3180 return _gdal.ExtendedDataType_GetMaxStringLength(self, *args)
3181
3183 r"""GetComponents(ExtendedDataType self)"""
3184 return _gdal.ExtendedDataType_GetComponents(self, *args)
3185
3187 r"""CanConvertTo(ExtendedDataType self, ExtendedDataType other) -> bool"""
3188 return _gdal.ExtendedDataType_CanConvertTo(self, *args)
3189
3191 r"""Equals(ExtendedDataType self, ExtendedDataType other) -> bool"""
3192 return _gdal.ExtendedDataType_Equals(self, *args)
3193
3194
3196 return self.Equals(other)
3197
3199 return not self.__eq__(other)
3200
3201
3202
3203 _gdal.ExtendedDataType_swigregister(ExtendedDataType)
3208
3212
3216
3218 r"""Proxy of C++ GDALEDTComponentHS class."""
3219
3220 thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
3221
3223 raise AttributeError("No constructor defined")
3224 __repr__ = _swig_repr
3225 __swig_destroy__ = _gdal.delete_EDTComponent
3226
3227 @staticmethod
3229 r"""Create(char const * name, size_t offset, ExtendedDataType type) -> EDTComponent"""
3230 return _gdal.EDTComponent_Create(*args)
3231
3233 r"""GetName(EDTComponent self) -> char const *"""
3234 return _gdal.EDTComponent_GetName(self, *args)
3235
3237 r"""GetOffset(EDTComponent self) -> size_t"""
3238 return _gdal.EDTComponent_GetOffset(self, *args)
3239
3241 r"""GetType(EDTComponent self) -> ExtendedDataType"""
3242 return _gdal.EDTComponent_GetType(self, *args)
3243
3244
3245 _gdal.EDTComponent_swigregister(EDTComponent)
3248 r"""EDTComponent_Create(char const * name, size_t offset, ExtendedDataType type) -> EDTComponent"""
3249 return _gdal.EDTComponent_Create(*args)
3250
3251 -class Band(MajorObject):
3252 r"""Proxy of C++ GDALRasterBandShadow class."""
3253
3254 thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
3255
3257 raise AttributeError("No constructor defined")
3258 __repr__ = _swig_repr
3259 XSize = property(_gdal.Band_XSize_get, doc=r"""XSize : int""")
3260 YSize = property(_gdal.Band_YSize_get, doc=r"""YSize : int""")
3261 DataType = property(_gdal.Band_DataType_get, doc=r"""DataType : GDALDataType""")
3262
3264 r"""GetDataset(Band self) -> Dataset"""
3265 return _gdal.Band_GetDataset(self, *args)
3266
3268 r"""GetBand(Band self) -> int"""
3269 return _gdal.Band_GetBand(self, *args)
3270
3272 r"""GetBlockSize(Band self)"""
3273 return _gdal.Band_GetBlockSize(self, *args)
3274
3276 r"""GetActualBlockSize(Band self, int nXBlockOff, int nYBlockOff)"""
3277 return _gdal.Band_GetActualBlockSize(self, *args)
3278
3280 r"""GetColorInterpretation(Band self) -> GDALColorInterp"""
3281 return _gdal.Band_GetColorInterpretation(self, *args)
3282
3284 r"""GetRasterColorInterpretation(Band self) -> GDALColorInterp"""
3285 return _gdal.Band_GetRasterColorInterpretation(self, *args)
3286
3288 r"""SetColorInterpretation(Band self, GDALColorInterp val) -> CPLErr"""
3289 return _gdal.Band_SetColorInterpretation(self, *args)
3290
3292 r"""SetRasterColorInterpretation(Band self, GDALColorInterp val) -> CPLErr"""
3293 return _gdal.Band_SetRasterColorInterpretation(self, *args)
3294
3296 r"""GetNoDataValue(Band self)"""
3297 return _gdal.Band_GetNoDataValue(self, *args)
3298
3300 r"""SetNoDataValue(Band self, double d) -> CPLErr"""
3301 return _gdal.Band_SetNoDataValue(self, *args)
3302
3304 r"""DeleteNoDataValue(Band self) -> CPLErr"""
3305 return _gdal.Band_DeleteNoDataValue(self, *args)
3306
3308 r"""GetUnitType(Band self) -> char const *"""
3309 return _gdal.Band_GetUnitType(self, *args)
3310
3312 r"""SetUnitType(Band self, char const * val) -> CPLErr"""
3313 return _gdal.Band_SetUnitType(self, *args)
3314
3316 r"""GetRasterCategoryNames(Band self) -> char **"""
3317 return _gdal.Band_GetRasterCategoryNames(self, *args)
3318
3320 r"""SetRasterCategoryNames(Band self, char ** names) -> CPLErr"""
3321 return _gdal.Band_SetRasterCategoryNames(self, *args)
3322
3324 r"""GetMinimum(Band self)"""
3325 return _gdal.Band_GetMinimum(self, *args)
3326
3328 r"""GetMaximum(Band self)"""
3329 return _gdal.Band_GetMaximum(self, *args)
3330
3332 r"""GetOffset(Band self)"""
3333 return _gdal.Band_GetOffset(self, *args)
3334
3336 r"""GetScale(Band self)"""
3337 return _gdal.Band_GetScale(self, *args)
3338
3340 r"""SetOffset(Band self, double val) -> CPLErr"""
3341 return _gdal.Band_SetOffset(self, *args)
3342
3344 r"""SetScale(Band self, double val) -> CPLErr"""
3345 return _gdal.Band_SetScale(self, *args)
3346
3348 r"""GetStatistics(Band self, int approx_ok, int force) -> CPLErr"""
3349 return _gdal.Band_GetStatistics(self, *args)
3350
3352 r"""ComputeStatistics(Band self, bool approx_ok, GDALProgressFunc callback=0, void * callback_data=None) -> CPLErr"""
3353 return _gdal.Band_ComputeStatistics(self, *args)
3354
3356 r"""SetStatistics(Band self, double min, double max, double mean, double stddev) -> CPLErr"""
3357 return _gdal.Band_SetStatistics(self, *args)
3358
3360 r"""GetOverviewCount(Band self) -> int"""
3361 return _gdal.Band_GetOverviewCount(self, *args)
3362
3364 r"""GetOverview(Band self, int i) -> Band"""
3365 return _gdal.Band_GetOverview(self, *args)
3366
3368 r"""Checksum(Band self, int xoff=0, int yoff=0, int * xsize=None, int * ysize=None) -> int"""
3369 return _gdal.Band_Checksum(self, *args, **kwargs)
3370
3372 r"""ComputeRasterMinMax(Band self, int approx_ok=0)"""
3373 return _gdal.Band_ComputeRasterMinMax(self, *args)
3374
3376 r"""ComputeBandStats(Band self, int samplestep=1)"""
3377 return _gdal.Band_ComputeBandStats(self, *args)
3378
3379 - def Fill(self, *args):
3380 r"""Fill(Band self, double real_fill, double imag_fill=0.0) -> CPLErr"""
3381 return _gdal.Band_Fill(self, *args)
3382
3384 r"""WriteRaster(Band self, int xoff, int yoff, int xsize, int ysize, GIntBig buf_len, int * buf_xsize=None, int * buf_ysize=None, GDALDataType * buf_type=None, GIntBig * buf_pixel_space=None, GIntBig * buf_line_space=None) -> CPLErr"""
3385 return _gdal.Band_WriteRaster(self, *args, **kwargs)
3386
3388 r"""FlushCache(Band self)"""
3389 return _gdal.Band_FlushCache(self, *args)
3390
3392 r"""GetRasterColorTable(Band self) -> ColorTable"""
3393 return _gdal.Band_GetRasterColorTable(self, *args)
3394
3396 r"""GetColorTable(Band self) -> ColorTable"""
3397 return _gdal.Band_GetColorTable(self, *args)
3398
3400 r"""SetRasterColorTable(Band self, ColorTable arg) -> int"""
3401 return _gdal.Band_SetRasterColorTable(self, *args)
3402
3404 r"""SetColorTable(Band self, ColorTable arg) -> int"""
3405 return _gdal.Band_SetColorTable(self, *args)
3406
3408 r"""GetDefaultRAT(Band self) -> RasterAttributeTable"""
3409 return _gdal.Band_GetDefaultRAT(self, *args)
3410
3412 r"""SetDefaultRAT(Band self, RasterAttributeTable table) -> int"""
3413 return _gdal.Band_SetDefaultRAT(self, *args)
3414
3416 r"""GetMaskBand(Band self) -> Band"""
3417 return _gdal.Band_GetMaskBand(self, *args)
3418
3420 r"""GetMaskFlags(Band self) -> int"""
3421 return _gdal.Band_GetMaskFlags(self, *args)
3422
3424 r"""CreateMaskBand(Band self, int nFlags) -> CPLErr"""
3425 return _gdal.Band_CreateMaskBand(self, *args)
3426
3428 r"""GetHistogram(Band self, double min=-0.5, double max=255.5, int buckets=256, int include_out_of_range=0, int approx_ok=1, GDALProgressFunc callback=0, void * callback_data=None) -> CPLErr"""
3429 return _gdal.Band_GetHistogram(self, *args, **kwargs)
3430
3432 r"""GetDefaultHistogram(Band self, double * min_ret=None, double * max_ret=None, int * buckets_ret=None, GUIntBig ** ppanHistogram=None, int force=1, GDALProgressFunc callback=0, void * callback_data=None) -> CPLErr"""
3433 return _gdal.Band_GetDefaultHistogram(self, *args, **kwargs)
3434
3436 r"""SetDefaultHistogram(Band self, double min, double max, int buckets_in) -> CPLErr"""
3437 return _gdal.Band_SetDefaultHistogram(self, *args)
3438
3440 r"""HasArbitraryOverviews(Band self) -> bool"""
3441 return _gdal.Band_HasArbitraryOverviews(self, *args)
3442
3444 r"""GetCategoryNames(Band self) -> char **"""
3445 return _gdal.Band_GetCategoryNames(self, *args)
3446
3448 r"""SetCategoryNames(Band self, char ** papszCategoryNames) -> CPLErr"""
3449 return _gdal.Band_SetCategoryNames(self, *args)
3450
3452 r"""GetVirtualMem(Band self, GDALRWFlag eRWFlag, int nXOff, int nYOff, int nXSize, int nYSize, int nBufXSize, int nBufYSize, GDALDataType eBufType, size_t nCacheSize, size_t nPageSizeHint, char ** options=None) -> VirtualMem"""
3453 return _gdal.Band_GetVirtualMem(self, *args, **kwargs)
3454
3456 r"""GetVirtualMemAuto(Band self, GDALRWFlag eRWFlag, char ** options=None) -> VirtualMem"""
3457 return _gdal.Band_GetVirtualMemAuto(self, *args, **kwargs)
3458
3460 r"""GetTiledVirtualMem(Band self, GDALRWFlag eRWFlag, int nXOff, int nYOff, int nXSize, int nYSize, int nTileXSize, int nTileYSize, GDALDataType eBufType, size_t nCacheSize, char ** options=None) -> VirtualMem"""
3461 return _gdal.Band_GetTiledVirtualMem(self, *args, **kwargs)
3462
3464 r"""GetDataCoverageStatus(Band self, int nXOff, int nYOff, int nXSize, int nYSize, int nMaskFlagStop=0) -> int"""
3465 return _gdal.Band_GetDataCoverageStatus(self, *args)
3466
3468 r"""AdviseRead(Band self, int xoff, int yoff, int xsize, int ysize, int * buf_xsize=None, int * buf_ysize=None, GDALDataType * buf_type=None, char ** options=None) -> CPLErr"""
3469 return _gdal.Band_AdviseRead(self, *args)
3470
3472 r"""AsMDArray(Band self) -> MDArray"""
3473 return _gdal.Band_AsMDArray(self, *args)
3474
3476 r"""ReadRaster1(Band self, double xoff, double yoff, double xsize, double ysize, int * buf_xsize=None, int * buf_ysize=None, GDALDataType * buf_type=None, GIntBig * buf_pixel_space=None, GIntBig * buf_line_space=None, GDALRIOResampleAlg resample_alg=GRIORA_NearestNeighbour, GDALProgressFunc callback=0, void * callback_data=None, void * inputOutputBuf=None) -> CPLErr"""
3477 return _gdal.Band_ReadRaster1(self, *args, **kwargs)
3478
3480 r"""ReadBlock(Band self, int xoff, int yoff, void * buf_obj=None) -> CPLErr"""
3481 return _gdal.Band_ReadBlock(self, *args, **kwargs)
3482
3483
3485 """ComputeStatistics(Band self, bool approx_ok, GDALProgressFunc callback=0, void * callback_data=None) -> CPLErr"""
3486
3487
3488
3489 approx_ok = args[0]
3490 if approx_ok == 0:
3491 approx_ok = False
3492 elif approx_ok == 1:
3493 approx_ok = True
3494 new_args = [approx_ok]
3495 for arg in args[1:]:
3496 new_args.append( arg )
3497
3498 return _gdal.Band_ComputeStatistics(self, *new_args)
3499
3500
3501 - def ReadRaster(self, xoff=0, yoff=0, xsize=None, ysize=None,
3502 buf_xsize=None, buf_ysize=None, buf_type=None,
3503 buf_pixel_space=None, buf_line_space=None,
3504 resample_alg=gdalconst.GRIORA_NearestNeighbour,
3505 callback=None,
3506 callback_data=None,
3507 buf_obj=None):
3508
3509 if xsize is None:
3510 xsize = self.XSize
3511 if ysize is None:
3512 ysize = self.YSize
3513
3514 return _gdal.Band_ReadRaster1(self, xoff, yoff, xsize, ysize,
3515 buf_xsize, buf_ysize, buf_type,
3516 buf_pixel_space, buf_line_space,
3517 resample_alg, callback, callback_data,
3518 buf_obj)
3519
3520 - def WriteRaster(self, xoff, yoff, xsize, ysize,
3521 buf_string,
3522 buf_xsize=None, buf_ysize=None, buf_type=None,
3523 buf_pixel_space=None, buf_line_space=None ):
3524
3525 if buf_xsize is None:
3526 buf_xsize = xsize
3527 if buf_ysize is None:
3528 buf_ysize = ysize
3529
3530
3531
3532 if type(buf_string).__name__ == 'ndarray' and \
3533 buf_xsize == xsize and buf_ysize == ysize and buf_type is None and \
3534 buf_pixel_space is None and buf_line_space is None:
3535 return self.WriteArray(buf_string, xoff=xoff, yoff=yoff)
3536
3537 if buf_type is None:
3538 buf_type = self.DataType
3539
3540 return _gdal.Band_WriteRaster(self,
3541 xoff, yoff, xsize, ysize,
3542 buf_string, buf_xsize, buf_ysize, buf_type,
3543 buf_pixel_space, buf_line_space )
3544
3545 - def ReadAsArray(self, xoff=0, yoff=0, win_xsize=None, win_ysize=None,
3546 buf_xsize=None, buf_ysize=None, buf_type=None, buf_obj=None,
3547 resample_alg=gdalconst.GRIORA_NearestNeighbour,
3548 callback=None,
3549 callback_data=None):
3550 """ Reading a chunk of a GDAL band into a numpy array. The optional (buf_xsize,buf_ysize,buf_type)
3551 parameters should generally not be specified if buf_obj is specified. The array is returned"""
3552
3553 from osgeo import gdal_array
3554
3555 return gdal_array.BandReadAsArray(self, xoff, yoff,
3556 win_xsize, win_ysize,
3557 buf_xsize, buf_ysize, buf_type, buf_obj,
3558 resample_alg=resample_alg,
3559 callback=callback,
3560 callback_data=callback_data)
3561
3572
3573 - def GetVirtualMemArray(self, eAccess=gdalconst.GF_Read, xoff=0, yoff=0,
3574 xsize=None, ysize=None, bufxsize=None, bufysize=None,
3575 datatype=None,
3576 cache_size = 10 * 1024 * 1024, page_size_hint = 0,
3577 options=None):
3578 """Return a NumPy array for the band, seen as a virtual memory mapping.
3579 An element is accessed with array[y][x].
3580 Any reference to the array must be dropped before the last reference to the
3581 related dataset is also dropped.
3582 """
3583 from osgeo import gdal_array
3584 if xsize is None:
3585 xsize = self.XSize
3586 if ysize is None:
3587 ysize = self.YSize
3588 if bufxsize is None:
3589 bufxsize = self.XSize
3590 if bufysize is None:
3591 bufysize = self.YSize
3592 if datatype is None:
3593 datatype = self.DataType
3594 if options is None:
3595 virtualmem = self.GetVirtualMem(eAccess, xoff, yoff, xsize, ysize, bufxsize, bufysize, datatype, cache_size, page_size_hint)
3596 else:
3597 virtualmem = self.GetVirtualMem(eAccess, xoff, yoff, xsize, ysize, bufxsize, bufysize, datatype, cache_size, page_size_hint, options)
3598 return gdal_array.VirtualMemGetArray(virtualmem)
3599
3601 """Return a NumPy array for the band, seen as a virtual memory mapping.
3602 An element is accessed with array[y][x].
3603 Any reference to the array must be dropped before the last reference to the
3604 related dataset is also dropped.
3605 """
3606 from osgeo import gdal_array
3607 if options is None:
3608 virtualmem = self.GetVirtualMemAuto(eAccess)
3609 else:
3610 virtualmem = self.GetVirtualMemAuto(eAccess,options)
3611 return gdal_array.VirtualMemGetArray( virtualmem )
3612
3613 - def GetTiledVirtualMemArray(self, eAccess=gdalconst.GF_Read, xoff=0, yoff=0,
3614 xsize=None, ysize=None, tilexsize=256, tileysize=256,
3615 datatype=None,
3616 cache_size = 10 * 1024 * 1024, options=None):
3617 """Return a NumPy array for the band, seen as a virtual memory mapping with
3618 a tile organization.
3619 An element is accessed with array[tiley][tilex][y][x].
3620 Any reference to the array must be dropped before the last reference to the
3621 related dataset is also dropped.
3622 """
3623 from osgeo import gdal_array
3624 if xsize is None:
3625 xsize = self.XSize
3626 if ysize is None:
3627 ysize = self.YSize
3628 if datatype is None:
3629 datatype = self.DataType
3630 if options is None:
3631 virtualmem = self.GetTiledVirtualMem(eAccess,xoff,yoff,xsize,ysize,tilexsize,tileysize,datatype,cache_size)
3632 else:
3633 virtualmem = self.GetTiledVirtualMem(eAccess,xoff,yoff,xsize,ysize,tilexsize,tileysize,datatype,cache_size,options)
3634 return gdal_array.VirtualMemGetArray( virtualmem )
3635
3636
3637
3638 _gdal.Band_swigregister(Band)
3641 r"""Proxy of C++ GDALColorTableShadow class."""
3642
3643 thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
3644 __repr__ = _swig_repr
3645
3647 r"""__init__(ColorTable self, GDALPaletteInterp palette=GPI_RGB) -> ColorTable"""
3648 _gdal.ColorTable_swiginit(self, _gdal.new_ColorTable(*args, **kwargs))
3649 __swig_destroy__ = _gdal.delete_ColorTable
3650
3651 - def Clone(self, *args):
3652 r"""Clone(ColorTable self) -> ColorTable"""
3653 return _gdal.ColorTable_Clone(self, *args)
3654
3656 r"""GetPaletteInterpretation(ColorTable self) -> GDALPaletteInterp"""
3657 return _gdal.ColorTable_GetPaletteInterpretation(self, *args)
3658
3660 r"""GetCount(ColorTable self) -> int"""
3661 return _gdal.ColorTable_GetCount(self, *args)
3662
3663 - def GetColorEntry(self, *args):
3664 r"""GetColorEntry(ColorTable self, int entry) -> ColorEntry"""
3665 return _gdal.ColorTable_GetColorEntry(self, *args)
3666
3667 - def GetColorEntryAsRGB(self, *args):
3668 r"""GetColorEntryAsRGB(ColorTable self, int entry, ColorEntry centry) -> int"""
3669 return _gdal.ColorTable_GetColorEntryAsRGB(self, *args)
3670
3671 - def SetColorEntry(self, *args):
3672 r"""SetColorEntry(ColorTable self, int entry, ColorEntry centry)"""
3673 return _gdal.ColorTable_SetColorEntry(self, *args)
3674
3676 r"""CreateColorRamp(ColorTable self, int nStartIndex, ColorEntry startcolor, int nEndIndex, ColorEntry endcolor)"""
3677 return _gdal.ColorTable_CreateColorRamp(self, *args)
3678
3679
3680 _gdal.ColorTable_swigregister(ColorTable)
3683 r"""Proxy of C++ GDALRasterAttributeTableShadow class."""
3684
3685 thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
3686 __repr__ = _swig_repr
3687
3689 r"""__init__(RasterAttributeTable self) -> RasterAttributeTable"""
3690 _gdal.RasterAttributeTable_swiginit(self, _gdal.new_RasterAttributeTable(*args))
3691 __swig_destroy__ = _gdal.delete_RasterAttributeTable
3692
3693 - def Clone(self, *args):
3694 r"""Clone(RasterAttributeTable self) -> RasterAttributeTable"""
3695 return _gdal.RasterAttributeTable_Clone(self, *args)
3696
3698 r"""GetColumnCount(RasterAttributeTable self) -> int"""
3699 return _gdal.RasterAttributeTable_GetColumnCount(self, *args)
3700
3702 r"""GetNameOfCol(RasterAttributeTable self, int iCol) -> char const *"""
3703 return _gdal.RasterAttributeTable_GetNameOfCol(self, *args)
3704
3706 r"""GetUsageOfCol(RasterAttributeTable self, int iCol) -> GDALRATFieldUsage"""
3707 return _gdal.RasterAttributeTable_GetUsageOfCol(self, *args)
3708
3710 r"""GetTypeOfCol(RasterAttributeTable self, int iCol) -> GDALRATFieldType"""
3711 return _gdal.RasterAttributeTable_GetTypeOfCol(self, *args)
3712
3714 r"""GetColOfUsage(RasterAttributeTable self, GDALRATFieldUsage eUsage) -> int"""
3715 return _gdal.RasterAttributeTable_GetColOfUsage(self, *args)
3716
3718 r"""GetRowCount(RasterAttributeTable self) -> int"""
3719 return _gdal.RasterAttributeTable_GetRowCount(self, *args)
3720
3722 r"""GetValueAsString(RasterAttributeTable self, int iRow, int iCol) -> char const *"""
3723 return _gdal.RasterAttributeTable_GetValueAsString(self, *args)
3724
3726 r"""GetValueAsInt(RasterAttributeTable self, int iRow, int iCol) -> int"""
3727 return _gdal.RasterAttributeTable_GetValueAsInt(self, *args)
3728
3730 r"""GetValueAsDouble(RasterAttributeTable self, int iRow, int iCol) -> double"""
3731 return _gdal.RasterAttributeTable_GetValueAsDouble(self, *args)
3732
3734 r"""SetValueAsString(RasterAttributeTable self, int iRow, int iCol, char const * pszValue)"""
3735 return _gdal.RasterAttributeTable_SetValueAsString(self, *args)
3736
3738 r"""SetValueAsInt(RasterAttributeTable self, int iRow, int iCol, int nValue)"""
3739 return _gdal.RasterAttributeTable_SetValueAsInt(self, *args)
3740
3742 r"""SetValueAsDouble(RasterAttributeTable self, int iRow, int iCol, double dfValue)"""
3743 return _gdal.RasterAttributeTable_SetValueAsDouble(self, *args)
3744
3746 r"""SetRowCount(RasterAttributeTable self, int nCount)"""
3747 return _gdal.RasterAttributeTable_SetRowCount(self, *args)
3748
3750 r"""CreateColumn(RasterAttributeTable self, char const * pszName, GDALRATFieldType eType, GDALRATFieldUsage eUsage) -> int"""
3751 return _gdal.RasterAttributeTable_CreateColumn(self, *args)
3752
3754 r"""GetLinearBinning(RasterAttributeTable self) -> bool"""
3755 return _gdal.RasterAttributeTable_GetLinearBinning(self, *args)
3756
3758 r"""SetLinearBinning(RasterAttributeTable self, double dfRow0Min, double dfBinSize) -> int"""
3759 return _gdal.RasterAttributeTable_SetLinearBinning(self, *args)
3760
3762 r"""GetRowOfValue(RasterAttributeTable self, double dfValue) -> int"""
3763 return _gdal.RasterAttributeTable_GetRowOfValue(self, *args)
3764
3766 r"""ChangesAreWrittenToFile(RasterAttributeTable self) -> int"""
3767 return _gdal.RasterAttributeTable_ChangesAreWrittenToFile(self, *args)
3768
3770 r"""DumpReadable(RasterAttributeTable self)"""
3771 return _gdal.RasterAttributeTable_DumpReadable(self, *args)
3772
3774 r"""SetTableType(RasterAttributeTable self, GDALRATTableType eTableType)"""
3775 return _gdal.RasterAttributeTable_SetTableType(self, *args)
3776
3778 r"""GetTableType(RasterAttributeTable self) -> GDALRATTableType"""
3779 return _gdal.RasterAttributeTable_GetTableType(self, *args)
3780
3785
3790
3791
3792
3793 _gdal.RasterAttributeTable_swigregister(RasterAttributeTable)
3797 r"""TermProgress_nocb(double dfProgress, char const * pszMessage=None, void * pData=None) -> int"""
3798 return _gdal.TermProgress_nocb(*args, **kwargs)
3799 TermProgress = _gdal.TermProgress
3805
3807 r"""DitherRGB2PCT(Band red, Band green, Band blue, Band target, ColorTable colors, GDALProgressFunc callback=0, void * callback_data=None) -> int"""
3808 return _gdal.DitherRGB2PCT(*args, **kwargs)
3809
3811 r"""ReprojectImage(Dataset src_ds, Dataset dst_ds, char const * src_wkt=None, char const * dst_wkt=None, GDALResampleAlg eResampleAlg=GRA_NearestNeighbour, double WarpMemoryLimit=0.0, double maxerror=0.0, GDALProgressFunc callback=0, void * callback_data=None, char ** options=None) -> CPLErr"""
3812 return _gdal.ReprojectImage(*args, **kwargs)
3813
3815 r"""ComputeProximity(Band srcBand, Band proximityBand, char ** options=None, GDALProgressFunc callback=0, void * callback_data=None) -> int"""
3816 return _gdal.ComputeProximity(*args, **kwargs)
3817
3819 r"""RasterizeLayer(Dataset dataset, int bands, Layer layer, void * pfnTransformer=None, void * pTransformArg=None, int burn_values=0, char ** options=None, GDALProgressFunc callback=0, void * callback_data=None) -> int"""
3820 return _gdal.RasterizeLayer(*args, **kwargs)
3821
3823 r"""Polygonize(Band srcBand, Band maskBand, Layer outLayer, int iPixValField, char ** options=None, GDALProgressFunc callback=0, void * callback_data=None) -> int"""
3824 return _gdal.Polygonize(*args, **kwargs)
3825
3827 r"""FPolygonize(Band srcBand, Band maskBand, Layer outLayer, int iPixValField, char ** options=None, GDALProgressFunc callback=0, void * callback_data=None) -> int"""
3828 return _gdal.FPolygonize(*args, **kwargs)
3829
3831 r"""FillNodata(Band targetBand, Band maskBand, double maxSearchDist, int smoothingIterations, char ** options=None, GDALProgressFunc callback=0, void * callback_data=None) -> int"""
3832 return _gdal.FillNodata(*args, **kwargs)
3833
3835 r"""SieveFilter(Band srcBand, Band maskBand, Band dstBand, int threshold, int connectedness=4, char ** options=None, GDALProgressFunc callback=0, void * callback_data=None) -> int"""
3836 return _gdal.SieveFilter(*args, **kwargs)
3837
3839 r"""RegenerateOverviews(Band srcBand, int overviewBandCount, char const * resampling="average", GDALProgressFunc callback=0, void * callback_data=None) -> int"""
3840 return _gdal.RegenerateOverviews(*args, **kwargs)
3841
3843 r"""RegenerateOverview(Band srcBand, Band overviewBand, char const * resampling="average", GDALProgressFunc callback=0, void * callback_data=None) -> int"""
3844 return _gdal.RegenerateOverview(*args, **kwargs)
3845
3847 r"""ContourGenerate(Band srcBand, double contourInterval, double contourBase, int fixedLevelCount, int useNoData, double noDataValue, Layer dstLayer, int idField, int elevField, GDALProgressFunc callback=0, void * callback_data=None) -> int"""
3848 return _gdal.ContourGenerate(*args, **kwargs)
3849
3851 r"""ContourGenerateEx(Band srcBand, Layer dstLayer, char ** options=None, GDALProgressFunc callback=0, void * callback_data=None) -> int"""
3852 return _gdal.ContourGenerateEx(*args, **kwargs)
3853 GVM_Diagonal = _gdal.GVM_Diagonal
3854
3855 GVM_Edge = _gdal.GVM_Edge
3856
3857 GVM_Max = _gdal.GVM_Max
3858
3859 GVM_Min = _gdal.GVM_Min
3860
3861 GVOT_NORMAL = _gdal.GVOT_NORMAL
3862
3863 GVOT_MIN_TARGET_HEIGHT_FROM_DEM = _gdal.GVOT_MIN_TARGET_HEIGHT_FROM_DEM
3864
3865 GVOT_MIN_TARGET_HEIGHT_FROM_GROUND = _gdal.GVOT_MIN_TARGET_HEIGHT_FROM_GROUND
3869 r"""ViewshedGenerate(Band srcBand, char const * driverName, char const * targetRasterName, char ** creationOptions, double observerX, double observerY, double observerHeight, double targetHeight, double visibleVal, double invisibleVal, double outOfRangeVal, double noDataVal, double dfCurvCoeff, GDALViewshedMode mode, double maxDistance, GDALProgressFunc callback=0, void * callback_data=None, GDALViewshedOutputType heightMode=GVOT_NORMAL, char ** papszOptions=None) -> Dataset"""
3870 return _gdal.ViewshedGenerate(*args, **kwargs)
3871
3873 r"""AutoCreateWarpedVRT(Dataset src_ds, char const * src_wkt=None, char const * dst_wkt=None, GDALResampleAlg eResampleAlg=GRA_NearestNeighbour, double maxerror=0.0) -> Dataset"""
3874 return _gdal.AutoCreateWarpedVRT(*args)
3875
3877 r"""CreatePansharpenedVRT(char const * pszXML, Band panchroBand, int nInputSpectralBands) -> Dataset"""
3878 return _gdal.CreatePansharpenedVRT(*args)
3903
3904
3905 _gdal.GDALTransformerInfoShadow_swigregister(GDALTransformerInfoShadow)
3911
3913 r"""ApplyVerticalShiftGrid(Dataset src_ds, Dataset grid_ds, bool inverse=False, double srcUnitToMeter=1.0, double dstUnitToMeter=1.0, char ** options=None) -> Dataset"""
3914 return _gdal.ApplyVerticalShiftGrid(*args, **kwargs)
3915
3919
3923
3925 r"""VersionInfo(char const * request="VERSION_NUM") -> char const *"""
3926 return _gdal.VersionInfo(*args)
3927
3931
3935
3939
3943
3947
3951
3955
3957 r"""GetDataTypeName(GDALDataType eDataType) -> char const *"""
3958 return _gdal.GetDataTypeName(*args)
3959
3961 r"""GetDataTypeByName(char const * pszDataTypeName) -> GDALDataType"""
3962 return _gdal.GetDataTypeByName(*args)
3963
3967
3971
3973 r"""DecToDMS(double arg1, char const * arg2, int arg3=2) -> char const *"""
3974 return _gdal.DecToDMS(*args)
3975
3979
3983
3985 r"""ParseXMLString(char * pszXMLString) -> CPLXMLNode *"""
3986 return _gdal.ParseXMLString(*args)
3987
3989 r"""SerializeXMLTree(CPLXMLNode * xmlnode) -> retStringAndCPLFree *"""
3990 return _gdal.SerializeXMLTree(*args)
3991
3993 r"""GetJPEG2000Structure(char const * pszFilename, char ** options=None) -> CPLXMLNode *"""
3994 return _gdal.GetJPEG2000Structure(*args)
3995
3997 r"""GetJPEG2000StructureAsString(char const * pszFilename, char ** options=None) -> retStringAndCPLFree *"""
3998 return _gdal.GetJPEG2000StructureAsString(*args)
3999
4003
4007
4009 r"""GetDriver(int i) -> Driver"""
4010 return _gdal.GetDriver(*args)
4011
4013 r"""Open(char const * utf8_path, GDALAccess eAccess=GA_ReadOnly) -> Dataset"""
4014 return _gdal.Open(*args)
4015
4017 r"""OpenEx(char const * utf8_path, unsigned int nOpenFlags=0, char ** allowed_drivers=None, char ** open_options=None, char ** sibling_files=None) -> Dataset"""
4018 return _gdal.OpenEx(*args, **kwargs)
4019
4021 r"""OpenShared(char const * utf8_path, GDALAccess eAccess=GA_ReadOnly) -> Dataset"""
4022 return _gdal.OpenShared(*args)
4023
4025 r"""IdentifyDriver(char const * utf8_path, char ** papszSiblings=None) -> Driver"""
4026 return _gdal.IdentifyDriver(*args)
4027
4029 r"""IdentifyDriverEx(char const * utf8_path, unsigned int nIdentifyFlags=0, char ** allowed_drivers=None, char ** sibling_files=None) -> Driver"""
4030 return _gdal.IdentifyDriverEx(*args, **kwargs)
4031
4035
4036 __version__ = _gdal.VersionInfo("RELEASE_NAME")
4039 r"""Proxy of C++ GDALInfoOptions class."""
4040
4041 thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
4042 __repr__ = _swig_repr
4043
4045 r"""__init__(GDALInfoOptions self, char ** options) -> GDALInfoOptions"""
4046 _gdal.GDALInfoOptions_swiginit(self, _gdal.new_GDALInfoOptions(*args))
4047 __swig_destroy__ = _gdal.delete_GDALInfoOptions
4048
4049
4050 _gdal.GDALInfoOptions_swigregister(GDALInfoOptions)
4054 r"""InfoInternal(Dataset hDataset, GDALInfoOptions infoOptions) -> retStringAndCPLFree *"""
4055 return _gdal.InfoInternal(*args)
4057 r"""Proxy of C++ GDALMultiDimInfoOptions class."""
4058
4059 thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
4060 __repr__ = _swig_repr
4061
4063 r"""__init__(GDALMultiDimInfoOptions self, char ** options) -> GDALMultiDimInfoOptions"""
4064 _gdal.GDALMultiDimInfoOptions_swiginit(self, _gdal.new_GDALMultiDimInfoOptions(*args))
4065 __swig_destroy__ = _gdal.delete_GDALMultiDimInfoOptions
4066
4067
4068 _gdal.GDALMultiDimInfoOptions_swigregister(GDALMultiDimInfoOptions)
4072 r"""MultiDimInfoInternal(Dataset hDataset, GDALMultiDimInfoOptions infoOptions) -> retStringAndCPLFree *"""
4073 return _gdal.MultiDimInfoInternal(*args)
4075 r"""Proxy of C++ GDALTranslateOptions class."""
4076
4077 thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
4078 __repr__ = _swig_repr
4079
4081 r"""__init__(GDALTranslateOptions self, char ** options) -> GDALTranslateOptions"""
4082 _gdal.GDALTranslateOptions_swiginit(self, _gdal.new_GDALTranslateOptions(*args))
4083 __swig_destroy__ = _gdal.delete_GDALTranslateOptions
4084
4085
4086 _gdal.GDALTranslateOptions_swigregister(GDALTranslateOptions)
4090 r"""TranslateInternal(char const * dest, Dataset dataset, GDALTranslateOptions translateOptions, GDALProgressFunc callback=0, void * callback_data=None) -> Dataset"""
4091 return _gdal.TranslateInternal(*args)
4093 r"""Proxy of C++ GDALWarpAppOptions class."""
4094
4095 thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
4096 __repr__ = _swig_repr
4097
4099 r"""__init__(GDALWarpAppOptions self, char ** options) -> GDALWarpAppOptions"""
4100 _gdal.GDALWarpAppOptions_swiginit(self, _gdal.new_GDALWarpAppOptions(*args))
4101 __swig_destroy__ = _gdal.delete_GDALWarpAppOptions
4102
4103
4104 _gdal.GDALWarpAppOptions_swigregister(GDALWarpAppOptions)
4108 r"""wrapper_GDALWarpDestDS(Dataset dstDS, int object_list_count, GDALWarpAppOptions warpAppOptions, GDALProgressFunc callback=0, void * callback_data=None) -> int"""
4109 return _gdal.wrapper_GDALWarpDestDS(*args)
4110
4112 r"""wrapper_GDALWarpDestName(char const * dest, int object_list_count, GDALWarpAppOptions warpAppOptions, GDALProgressFunc callback=0, void * callback_data=None) -> Dataset"""
4113 return _gdal.wrapper_GDALWarpDestName(*args)
4115 r"""Proxy of C++ GDALVectorTranslateOptions class."""
4116
4117 thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
4118 __repr__ = _swig_repr
4119
4121 r"""__init__(GDALVectorTranslateOptions self, char ** options) -> GDALVectorTranslateOptions"""
4122 _gdal.GDALVectorTranslateOptions_swiginit(self, _gdal.new_GDALVectorTranslateOptions(*args))
4123 __swig_destroy__ = _gdal.delete_GDALVectorTranslateOptions
4124
4125
4126 _gdal.GDALVectorTranslateOptions_swigregister(GDALVectorTranslateOptions)
4130 r"""wrapper_GDALVectorTranslateDestDS(Dataset dstDS, Dataset srcDS, GDALVectorTranslateOptions options, GDALProgressFunc callback=0, void * callback_data=None) -> int"""
4131 return _gdal.wrapper_GDALVectorTranslateDestDS(*args)
4132
4134 r"""wrapper_GDALVectorTranslateDestName(char const * dest, Dataset srcDS, GDALVectorTranslateOptions options, GDALProgressFunc callback=0, void * callback_data=None) -> Dataset"""
4135 return _gdal.wrapper_GDALVectorTranslateDestName(*args)
4137 r"""Proxy of C++ GDALDEMProcessingOptions class."""
4138
4139 thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
4140 __repr__ = _swig_repr
4141
4143 r"""__init__(GDALDEMProcessingOptions self, char ** options) -> GDALDEMProcessingOptions"""
4144 _gdal.GDALDEMProcessingOptions_swiginit(self, _gdal.new_GDALDEMProcessingOptions(*args))
4145 __swig_destroy__ = _gdal.delete_GDALDEMProcessingOptions
4146
4147
4148 _gdal.GDALDEMProcessingOptions_swigregister(GDALDEMProcessingOptions)
4152 r"""DEMProcessingInternal(char const * dest, Dataset dataset, char const * pszProcessing, char const * pszColorFilename, GDALDEMProcessingOptions options, GDALProgressFunc callback=0, void * callback_data=None) -> Dataset"""
4153 return _gdal.DEMProcessingInternal(*args)
4155 r"""Proxy of C++ GDALNearblackOptions class."""
4156
4157 thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
4158 __repr__ = _swig_repr
4159
4161 r"""__init__(GDALNearblackOptions self, char ** options) -> GDALNearblackOptions"""
4162 _gdal.GDALNearblackOptions_swiginit(self, _gdal.new_GDALNearblackOptions(*args))
4163 __swig_destroy__ = _gdal.delete_GDALNearblackOptions
4164
4165
4166 _gdal.GDALNearblackOptions_swigregister(GDALNearblackOptions)
4170 r"""wrapper_GDALNearblackDestDS(Dataset dstDS, Dataset srcDS, GDALNearblackOptions options, GDALProgressFunc callback=0, void * callback_data=None) -> int"""
4171 return _gdal.wrapper_GDALNearblackDestDS(*args)
4172
4174 r"""wrapper_GDALNearblackDestName(char const * dest, Dataset srcDS, GDALNearblackOptions options, GDALProgressFunc callback=0, void * callback_data=None) -> Dataset"""
4175 return _gdal.wrapper_GDALNearblackDestName(*args)
4177 r"""Proxy of C++ GDALGridOptions class."""
4178
4179 thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
4180 __repr__ = _swig_repr
4181
4183 r"""__init__(GDALGridOptions self, char ** options) -> GDALGridOptions"""
4184 _gdal.GDALGridOptions_swiginit(self, _gdal.new_GDALGridOptions(*args))
4185 __swig_destroy__ = _gdal.delete_GDALGridOptions
4186
4187
4188 _gdal.GDALGridOptions_swigregister(GDALGridOptions)
4192 r"""GridInternal(char const * dest, Dataset dataset, GDALGridOptions options, GDALProgressFunc callback=0, void * callback_data=None) -> Dataset"""
4193 return _gdal.GridInternal(*args)
4195 r"""Proxy of C++ GDALRasterizeOptions class."""
4196
4197 thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
4198 __repr__ = _swig_repr
4199
4201 r"""__init__(GDALRasterizeOptions self, char ** options) -> GDALRasterizeOptions"""
4202 _gdal.GDALRasterizeOptions_swiginit(self, _gdal.new_GDALRasterizeOptions(*args))
4203 __swig_destroy__ = _gdal.delete_GDALRasterizeOptions
4204
4205
4206 _gdal.GDALRasterizeOptions_swigregister(GDALRasterizeOptions)
4210 r"""wrapper_GDALRasterizeDestDS(Dataset dstDS, Dataset srcDS, GDALRasterizeOptions options, GDALProgressFunc callback=0, void * callback_data=None) -> int"""
4211 return _gdal.wrapper_GDALRasterizeDestDS(*args)
4212
4214 r"""wrapper_GDALRasterizeDestName(char const * dest, Dataset srcDS, GDALRasterizeOptions options, GDALProgressFunc callback=0, void * callback_data=None) -> Dataset"""
4215 return _gdal.wrapper_GDALRasterizeDestName(*args)
4217 r"""Proxy of C++ GDALBuildVRTOptions class."""
4218
4219 thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
4220 __repr__ = _swig_repr
4221
4223 r"""__init__(GDALBuildVRTOptions self, char ** options) -> GDALBuildVRTOptions"""
4224 _gdal.GDALBuildVRTOptions_swiginit(self, _gdal.new_GDALBuildVRTOptions(*args))
4225 __swig_destroy__ = _gdal.delete_GDALBuildVRTOptions
4226
4227
4228 _gdal.GDALBuildVRTOptions_swigregister(GDALBuildVRTOptions)
4232 r"""BuildVRTInternalObjects(char const * dest, int object_list_count, GDALBuildVRTOptions options, GDALProgressFunc callback=0, void * callback_data=None) -> Dataset"""
4233 return _gdal.BuildVRTInternalObjects(*args)
4234
4236 r"""BuildVRTInternalNames(char const * dest, char ** source_filenames, GDALBuildVRTOptions options, GDALProgressFunc callback=0, void * callback_data=None) -> Dataset"""
4237 return _gdal.BuildVRTInternalNames(*args)
4239 r"""Proxy of C++ GDALMultiDimTranslateOptions class."""
4240
4241 thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
4242 __repr__ = _swig_repr
4243
4245 r"""__init__(GDALMultiDimTranslateOptions self, char ** options) -> GDALMultiDimTranslateOptions"""
4246 _gdal.GDALMultiDimTranslateOptions_swiginit(self, _gdal.new_GDALMultiDimTranslateOptions(*args))
4247 __swig_destroy__ = _gdal.delete_GDALMultiDimTranslateOptions
4248
4249
4250 _gdal.GDALMultiDimTranslateOptions_swigregister(GDALMultiDimTranslateOptions)
4254 r"""wrapper_GDALMultiDimTranslateDestName(char const * dest, int object_list_count, GDALMultiDimTranslateOptions multiDimTranslateOptions, GDALProgressFunc callback=0, void * callback_data=None) -> Dataset"""
4255 return _gdal.wrapper_GDALMultiDimTranslateDestName(*args)
4256