1
2
3
4
5
6
7
8
9
10
11 from sys import version_info
12 if version_info >= (2, 6, 0):
14 from os.path import dirname
15 import imp
16 fp = None
17 try:
18 fp, pathname, description = imp.find_module('_gdal', [dirname(__file__)])
19 except ImportError:
20 import _gdal
21 return _gdal
22 if fp is not None:
23 try:
24 _mod = imp.load_module('_gdal', fp, pathname, description)
25 finally:
26 fp.close()
27 return _mod
28 _gdal = swig_import_helper()
29 del swig_import_helper
30 else:
31 import _gdal
32 del version_info
33 try:
34 _swig_property = property
35 except NameError:
36 pass
37
38
40 if (name == "thisown"):
41 return self.this.own(value)
42 if (name == "this"):
43 if type(value).__name__ == 'SwigPyObject':
44 self.__dict__[name] = value
45 return
46 method = class_type.__swig_setmethods__.get(name, None)
47 if method:
48 return method(self, value)
49 if (not static):
50 if _newclass:
51 object.__setattr__(self, name, value)
52 else:
53 self.__dict__[name] = value
54 else:
55 raise AttributeError("You cannot add attributes to %s" % self)
56
57
60
61
63 if (name == "thisown"):
64 return self.this.own()
65 method = class_type.__swig_getmethods__.get(name, None)
66 if method:
67 return method(self)
68 if (not static):
69 return object.__getattr__(self, name)
70 else:
71 raise AttributeError(name)
72
75
76
78 try:
79 strthis = "proxy of " + self.this.__repr__()
80 except Exception:
81 strthis = ""
82 return "<%s.%s; %s >" % (self.__class__.__module__, self.__class__.__name__, strthis,)
83
84 try:
85 _object = object
86 _newclass = 1
87 except AttributeError:
90 _newclass = 0
91
92
93
94
95
96 have_warned = 0
98 global have_warned
99
100 if have_warned == 1:
101 return
102
103 have_warned = 1
104
105 from warnings import warn
106 warn('%s.py was placed in a namespace, it is now available as osgeo.%s' % (module,module),
107 DeprecationWarning)
108
109
110 from osgeo.gdalconst import *
111 from osgeo import gdalconst
112
113
114 import sys
115 byteorders = {"little": "<",
116 "big": ">"}
117 array_modes = { gdalconst.GDT_Int16: ("%si2" % byteorders[sys.byteorder]),
118 gdalconst.GDT_UInt16: ("%su2" % byteorders[sys.byteorder]),
119 gdalconst.GDT_Int32: ("%si4" % byteorders[sys.byteorder]),
120 gdalconst.GDT_UInt32: ("%su4" % byteorders[sys.byteorder]),
121 gdalconst.GDT_Float32: ("%sf4" % byteorders[sys.byteorder]),
122 gdalconst.GDT_Float64: ("%sf8" % byteorders[sys.byteorder]),
123 gdalconst.GDT_CFloat32: ("%sf4" % byteorders[sys.byteorder]),
124 gdalconst.GDT_CFloat64: ("%sf8" % byteorders[sys.byteorder]),
125 gdalconst.GDT_Byte: ("%st8" % byteorders[sys.byteorder]),
126 }
127
129 src_ds = Open(src_filename)
130 if src_ds is None or src_ds == 'NULL':
131 return 1
132
133 ct = ColorTable()
134 err = ComputeMedianCutPCT(src_ds.GetRasterBand(1),
135 src_ds.GetRasterBand(2),
136 src_ds.GetRasterBand(3),
137 256, ct)
138 if err != 0:
139 return err
140
141 gtiff_driver = GetDriverByName('GTiff')
142 if gtiff_driver is None:
143 return 1
144
145 dst_ds = gtiff_driver.Create(dst_filename,
146 src_ds.RasterXSize, src_ds.RasterYSize)
147 dst_ds.GetRasterBand(1).SetRasterColorTable(ct)
148
149 err = DitherRGB2PCT(src_ds.GetRasterBand(1),
150 src_ds.GetRasterBand(2),
151 src_ds.GetRasterBand(3),
152 dst_ds.GetRasterBand(1),
153 ct)
154 dst_ds = None
155 src_ds = None
156
157 return 0
158
159 -def listdir(path, recursionLevel = -1, options = []):
160 """ Iterate over a directory.
161
162 recursionLevel = -1 means unlimited level of recursion.
163 """
164 dir = OpenDir(path, recursionLevel, options)
165 if not dir:
166 raise OSError(path + ' does not exist')
167 try:
168 while True:
169 entry = GetNextDirEntry(dir)
170 if not entry:
171 break
172 yield entry
173 finally:
174 CloseDir(dir)
175
176
180
184
188
190 """VSIFReadL(unsigned int nMembSize, unsigned int nMembCount, VSILFILE fp) -> unsigned int"""
191 return _gdal.VSIFReadL(*args)
192
196
197
199 return isinstance(o, (str, type(u'')))
200
201 -def InfoOptions(options=None, format='text', deserialize=True,
202 computeMinMax=False, reportHistograms=False, reportProj4=False,
203 stats=False, approxStats=False, computeChecksum=False,
204 showGCPs=True, showMetadata=True, showRAT=True, showColorTable=True,
205 listMDD=False, showFileList=True, allMetadata=False,
206 extraMDDomains=None, wktFormat=None):
207 """ Create a InfoOptions() object that can be passed to gdal.Info()
208 options can be be an array of strings, a string or let empty and filled from other keywords."""
209
210 options = [] if options is None else options
211
212 if _is_str_or_unicode(options):
213 new_options = ParseCommandLine(options)
214 format = 'text'
215 if '-json' in new_options:
216 format = 'json'
217 else:
218 new_options = options
219 if format == 'json':
220 new_options += ['-json']
221 if computeMinMax:
222 new_options += ['-mm']
223 if reportHistograms:
224 new_options += ['-hist']
225 if reportProj4:
226 new_options += ['-proj4']
227 if stats:
228 new_options += ['-stats']
229 if approxStats:
230 new_options += ['-approx_stats']
231 if computeChecksum:
232 new_options += ['-checksum']
233 if not showGCPs:
234 new_options += ['-nogcp']
235 if not showMetadata:
236 new_options += ['-nomd']
237 if not showRAT:
238 new_options += ['-norat']
239 if not showColorTable:
240 new_options += ['-noct']
241 if listMDD:
242 new_options += ['-listmdd']
243 if not showFileList:
244 new_options += ['-nofl']
245 if allMetadata:
246 new_options += ['-mdd', 'all']
247 if wktFormat:
248 new_options += ['-wkt_format', wktFormat]
249 if extraMDDomains is not None:
250 for mdd in extraMDDomains:
251 new_options += ['-mdd', mdd]
252
253 return (GDALInfoOptions(new_options), format, deserialize)
254
255 -def Info(ds, **kwargs):
256 """ Return information on a dataset.
257 Arguments are :
258 ds --- a Dataset object or a filename
259 Keyword arguments are :
260 options --- return of gdal.InfoOptions(), string or array of strings
261 other keywords arguments of gdal.InfoOptions()
262 If options is provided as a gdal.InfoOptions() object, other keywords are ignored. """
263 if 'options' not in kwargs or isinstance(kwargs['options'], list) or _is_str_or_unicode(kwargs['options']):
264 (opts, format, deserialize) = InfoOptions(**kwargs)
265 else:
266 (opts, format, deserialize) = kwargs['options']
267 if _is_str_or_unicode(ds):
268 ds = Open(ds)
269 ret = InfoInternal(ds, opts)
270 if format == 'json' and deserialize:
271 import json
272 ret = json.loads(ret)
273 return ret
274
277
278 -def TranslateOptions(options=None, format=None,
279 outputType = gdalconst.GDT_Unknown, bandList=None, maskBand=None,
280 width = 0, height = 0, widthPct = 0.0, heightPct = 0.0,
281 xRes = 0.0, yRes = 0.0,
282 creationOptions=None, srcWin=None, projWin=None, projWinSRS=None, strict = False,
283 unscale = False, scaleParams=None, exponents=None,
284 outputBounds=None, metadataOptions=None,
285 outputSRS=None, nogcp=False, GCPs=None,
286 noData=None, rgbExpand=None,
287 stats = False, rat = True, resampleAlg=None,
288 callback=None, callback_data=None):
289 """ Create a TranslateOptions() object that can be passed to gdal.Translate()
290 Keyword arguments are :
291 options --- can be be an array of strings, a string or let empty and filled from other keywords.
292 format --- output format ("GTiff", etc...)
293 outputType --- output type (gdalconst.GDT_Byte, etc...)
294 bandList --- array of band numbers (index start at 1)
295 maskBand --- mask band to generate or not ("none", "auto", "mask", 1, ...)
296 width --- width of the output raster in pixel
297 height --- height of the output raster in pixel
298 widthPct --- width of the output raster in percentage (100 = original width)
299 heightPct --- height of the output raster in percentage (100 = original height)
300 xRes --- output horizontal resolution
301 yRes --- output vertical resolution
302 creationOptions --- list of creation options
303 srcWin --- subwindow in pixels to extract: [left_x, top_y, width, height]
304 projWin --- subwindow in projected coordinates to extract: [ulx, uly, lrx, lry]
305 projWinSRS --- SRS in which projWin is expressed
306 strict --- strict mode
307 unscale --- unscale values with scale and offset metadata
308 scaleParams --- list of scale parameters, each of the form [src_min,src_max] or [src_min,src_max,dst_min,dst_max]
309 exponents --- list of exponentiation parameters
310 outputBounds --- assigned output bounds: [ulx, uly, lrx, lry]
311 metadataOptions --- list of metadata options
312 outputSRS --- assigned output SRS
313 nogcp --- ignore GCP in the raster
314 GCPs --- list of GCPs
315 noData --- nodata value (or "none" to unset it)
316 rgbExpand --- Color palette expansion mode: "gray", "rgb", "rgba"
317 stats --- whether to calculate statistics
318 rat --- whether to write source RAT
319 resampleAlg --- resampling mode
320 callback --- callback method
321 callback_data --- user data for callback
322 """
323 options = [] if options is None else options
324
325 if _is_str_or_unicode(options):
326 new_options = ParseCommandLine(options)
327 else:
328 new_options = options
329 if format is not None:
330 new_options += ['-of', format]
331 if outputType != gdalconst.GDT_Unknown:
332 new_options += ['-ot', GetDataTypeName(outputType)]
333 if maskBand != None:
334 new_options += ['-mask', str(maskBand)]
335 if bandList != None:
336 for b in bandList:
337 new_options += ['-b', str(b)]
338 if width != 0 or height != 0:
339 new_options += ['-outsize', str(width), str(height)]
340 elif widthPct != 0 and heightPct != 0:
341 new_options += ['-outsize', str(widthPct) + '%%', str(heightPct) + '%%']
342 if creationOptions is not None:
343 for opt in creationOptions:
344 new_options += ['-co', opt]
345 if srcWin is not None:
346 new_options += ['-srcwin', _strHighPrec(srcWin[0]), _strHighPrec(srcWin[1]), _strHighPrec(srcWin[2]), _strHighPrec(srcWin[3])]
347 if strict:
348 new_options += ['-strict']
349 if unscale:
350 new_options += ['-unscale']
351 if scaleParams:
352 for scaleParam in scaleParams:
353 new_options += ['-scale']
354 for v in scaleParam:
355 new_options += [str(v)]
356 if exponents:
357 for exponent in exponents:
358 new_options += ['-exponent', _strHighPrec(exponent)]
359 if outputBounds is not None:
360 new_options += ['-a_ullr', _strHighPrec(outputBounds[0]), _strHighPrec(outputBounds[1]), _strHighPrec(outputBounds[2]), _strHighPrec(outputBounds[3])]
361 if metadataOptions is not None:
362 for opt in metadataOptions:
363 new_options += ['-mo', opt]
364 if outputSRS is not None:
365 new_options += ['-a_srs', str(outputSRS)]
366 if nogcp:
367 new_options += ['-nogcp']
368 if GCPs is not None:
369 for gcp in GCPs:
370 new_options += ['-gcp', _strHighPrec(gcp.GCPPixel), _strHighPrec(gcp.GCPLine), _strHighPrec(gcp.GCPX), str(gcp.GCPY), _strHighPrec(gcp.GCPZ)]
371 if projWin is not None:
372 new_options += ['-projwin', _strHighPrec(projWin[0]), _strHighPrec(projWin[1]), _strHighPrec(projWin[2]), _strHighPrec(projWin[3])]
373 if projWinSRS is not None:
374 new_options += ['-projwin_srs', str(projWinSRS)]
375 if noData is not None:
376 new_options += ['-a_nodata', _strHighPrec(noData)]
377 if rgbExpand is not None:
378 new_options += ['-expand', str(rgbExpand)]
379 if stats:
380 new_options += ['-stats']
381 if not rat:
382 new_options += ['-norat']
383 if resampleAlg is not None:
384 if resampleAlg == gdalconst.GRA_NearestNeighbour:
385 new_options += ['-r', 'near']
386 elif resampleAlg == gdalconst.GRA_Bilinear:
387 new_options += ['-r', 'bilinear']
388 elif resampleAlg == gdalconst.GRA_Cubic:
389 new_options += ['-r', 'cubic']
390 elif resampleAlg == gdalconst.GRA_CubicSpline:
391 new_options += ['-r', 'cubicspline']
392 elif resampleAlg == gdalconst.GRA_Lanczos:
393 new_options += ['-r', 'lanczos']
394 elif resampleAlg == gdalconst.GRA_Average:
395 new_options += ['-r', 'average']
396 elif resampleAlg == gdalconst.GRA_Mode:
397 new_options += ['-r', 'mode']
398 else:
399 new_options += ['-r', str(resampleAlg)]
400 if xRes != 0 and yRes != 0:
401 new_options += ['-tr', _strHighPrec(xRes), _strHighPrec(yRes)]
402
403 return (GDALTranslateOptions(new_options), callback, callback_data)
404
406 """ Convert a dataset.
407 Arguments are :
408 destName --- Output dataset name
409 srcDS --- a Dataset object or a filename
410 Keyword arguments are :
411 options --- return of gdal.TranslateOptions(), string or array of strings
412 other keywords arguments of gdal.TranslateOptions()
413 If options is provided as a gdal.TranslateOptions() object, other keywords are ignored. """
414
415 if 'options' not in kwargs or isinstance(kwargs['options'], list) or _is_str_or_unicode(kwargs['options']):
416 (opts, callback, callback_data) = TranslateOptions(**kwargs)
417 else:
418 (opts, callback, callback_data) = kwargs['options']
419 if _is_str_or_unicode(srcDS):
420 srcDS = Open(srcDS)
421
422 return TranslateInternal(destName, srcDS, opts, callback, callback_data)
423
424 -def WarpOptions(options=None, format=None,
425 outputBounds=None,
426 outputBoundsSRS=None,
427 xRes=None, yRes=None, targetAlignedPixels = False,
428 width = 0, height = 0,
429 srcSRS=None, dstSRS=None,
430 coordinateOperation=None,
431 srcAlpha = False, dstAlpha = False,
432 warpOptions=None, errorThreshold=None,
433 warpMemoryLimit=None, creationOptions=None, outputType = gdalconst.GDT_Unknown,
434 workingType = gdalconst.GDT_Unknown, resampleAlg=None,
435 srcNodata=None, dstNodata=None, multithread = False,
436 tps = False, rpc = False, geoloc = False, polynomialOrder=None,
437 transformerOptions=None, cutlineDSName=None,
438 cutlineLayer=None, cutlineWhere=None, cutlineSQL=None, cutlineBlend=None, cropToCutline = False,
439 copyMetadata = True, metadataConflictValue=None,
440 setColorInterpretation = False,
441 overviewLevel = 'AUTO',
442 callback=None, callback_data=None):
443 """ Create a WarpOptions() object that can be passed to gdal.Warp()
444 Keyword arguments are :
445 options --- can be be an array of strings, a string or let empty and filled from other keywords.
446 format --- output format ("GTiff", etc...)
447 outputBounds --- output bounds as (minX, minY, maxX, maxY) in target SRS
448 outputBoundsSRS --- SRS in which output bounds are expressed, in the case they are not expressed in dstSRS
449 xRes, yRes --- output resolution in target SRS
450 targetAlignedPixels --- whether to force output bounds to be multiple of output resolution
451 width --- width of the output raster in pixel
452 height --- height of the output raster in pixel
453 srcSRS --- source SRS
454 dstSRS --- output SRS
455 coordinateOperation -- coordinate operation as a PROJ string or WKT string
456 srcAlpha --- whether to force the last band of the input dataset to be considered as an alpha band
457 dstAlpha --- whether to force the creation of an output alpha band
458 outputType --- output type (gdalconst.GDT_Byte, etc...)
459 workingType --- working type (gdalconst.GDT_Byte, etc...)
460 warpOptions --- list of warping options
461 errorThreshold --- error threshold for approximation transformer (in pixels)
462 warpMemoryLimit --- size of working buffer in bytes
463 resampleAlg --- resampling mode
464 creationOptions --- list of creation options
465 srcNodata --- source nodata value(s)
466 dstNodata --- output nodata value(s)
467 multithread --- whether to multithread computation and I/O operations
468 tps --- whether to use Thin Plate Spline GCP transformer
469 rpc --- whether to use RPC transformer
470 geoloc --- whether to use GeoLocation array transformer
471 polynomialOrder --- order of polynomial GCP interpolation
472 transformerOptions --- list of transformer options
473 cutlineDSName --- cutline dataset name
474 cutlineLayer --- cutline layer name
475 cutlineWhere --- cutline WHERE clause
476 cutlineSQL --- cutline SQL statement
477 cutlineBlend --- cutline blend distance in pixels
478 cropToCutline --- whether to use cutline extent for output bounds
479 copyMetadata --- whether to copy source metadata
480 metadataConflictValue --- metadata data conflict value
481 setColorInterpretation --- whether to force color interpretation of input bands to output bands
482 overviewLevel --- To specify which overview level of source files must be used
483 callback --- callback method
484 callback_data --- user data for callback
485 """
486 options = [] if options is None else options
487
488 if _is_str_or_unicode(options):
489 new_options = ParseCommandLine(options)
490 else:
491 new_options = options
492 if format is not None:
493 new_options += ['-of', format]
494 if outputType != gdalconst.GDT_Unknown:
495 new_options += ['-ot', GetDataTypeName(outputType)]
496 if workingType != gdalconst.GDT_Unknown:
497 new_options += ['-wt', GetDataTypeName(workingType)]
498 if outputBounds is not None:
499 new_options += ['-te', _strHighPrec(outputBounds[0]), _strHighPrec(outputBounds[1]), _strHighPrec(outputBounds[2]), _strHighPrec(outputBounds[3])]
500 if outputBoundsSRS is not None:
501 new_options += ['-te_srs', str(outputBoundsSRS)]
502 if xRes is not None and yRes is not None:
503 new_options += ['-tr', _strHighPrec(xRes), _strHighPrec(yRes)]
504 if width != 0 or height != 0:
505 new_options += ['-ts', str(width), str(height)]
506 if srcSRS is not None:
507 new_options += ['-s_srs', str(srcSRS)]
508 if dstSRS is not None:
509 new_options += ['-t_srs', str(dstSRS)]
510 if coordinateOperation is not None:
511 new_options += ['-ct', coordinateOperation]
512 if targetAlignedPixels:
513 new_options += ['-tap']
514 if srcAlpha:
515 new_options += ['-srcalpha']
516 if dstAlpha:
517 new_options += ['-dstalpha']
518 if warpOptions is not None:
519 for opt in warpOptions:
520 new_options += ['-wo', str(opt)]
521 if errorThreshold is not None:
522 new_options += ['-et', _strHighPrec(errorThreshold)]
523 if resampleAlg is not None:
524 if resampleAlg == gdalconst.GRIORA_NearestNeighbour:
525 new_options += ['-r', 'near']
526 elif resampleAlg == gdalconst.GRIORA_Bilinear:
527 new_options += ['-rb']
528 elif resampleAlg == gdalconst.GRIORA_Cubic:
529 new_options += ['-rc']
530 elif resampleAlg == gdalconst.GRIORA_CubicSpline:
531 new_options += ['-rcs']
532 elif resampleAlg == gdalconst.GRIORA_Lanczos:
533 new_options += ['-r', 'lanczos']
534 elif resampleAlg == gdalconst.GRIORA_Average:
535 new_options += ['-r', 'average']
536 elif resampleAlg == gdalconst.GRIORA_Mode:
537 new_options += ['-r', 'mode']
538 elif resampleAlg == gdalconst.GRIORA_Gauss:
539 new_options += ['-r', 'gauss']
540 else:
541 new_options += ['-r', str(resampleAlg)]
542 if warpMemoryLimit is not None:
543 new_options += ['-wm', str(warpMemoryLimit)]
544 if creationOptions is not None:
545 for opt in creationOptions:
546 new_options += ['-co', opt]
547 if srcNodata is not None:
548 new_options += ['-srcnodata', str(srcNodata)]
549 if dstNodata is not None:
550 new_options += ['-dstnodata', str(dstNodata)]
551 if multithread:
552 new_options += ['-multi']
553 if tps:
554 new_options += ['-tps']
555 if rpc:
556 new_options += ['-rpc']
557 if geoloc:
558 new_options += ['-geoloc']
559 if polynomialOrder is not None:
560 new_options += ['-order', str(polynomialOrder)]
561 if transformerOptions is not None:
562 for opt in transformerOptions:
563 new_options += ['-to', opt]
564 if cutlineDSName is not None:
565 new_options += ['-cutline', str(cutlineDSName)]
566 if cutlineLayer is not None:
567 new_options += ['-cl', str(cutlineLayer)]
568 if cutlineWhere is not None:
569 new_options += ['-cwhere', str(cutlineWhere)]
570 if cutlineSQL is not None:
571 new_options += ['-csql', str(cutlineSQL)]
572 if cutlineBlend is not None:
573 new_options += ['-cblend', str(cutlineBlend)]
574 if cropToCutline:
575 new_options += ['-crop_to_cutline']
576 if not copyMetadata:
577 new_options += ['-nomd']
578 if metadataConflictValue:
579 new_options += ['-cvmd', str(metadataConflictValue)]
580 if setColorInterpretation:
581 new_options += ['-setci']
582
583 if overviewLevel is None or _is_str_or_unicode(overviewLevel):
584 pass
585 elif isinstance(overviewLevel, int):
586 if overviewLevel < 0:
587 overviewLevel = 'AUTO' + str(overviewLevel)
588 else:
589 overviewLevel = str(overviewLevel)
590 else:
591 overviewLevel = None
592
593 if overviewLevel:
594 new_options += ['-ovr', overviewLevel]
595
596 return (GDALWarpAppOptions(new_options), callback, callback_data)
597
598 -def Warp(destNameOrDestDS, srcDSOrSrcDSTab, **kwargs):
599 """ Warp one or several datasets.
600 Arguments are :
601 destNameOrDestDS --- Output dataset name or object
602 srcDSOrSrcDSTab --- an array of Dataset objects or filenames, or a Dataset object or a filename
603 Keyword arguments are :
604 options --- return of gdal.WarpOptions(), string or array of strings
605 other keywords arguments of gdal.WarpOptions()
606 If options is provided as a gdal.WarpOptions() object, other keywords are ignored. """
607
608 if 'options' not in kwargs or isinstance(kwargs['options'], list) or _is_str_or_unicode(kwargs['options']):
609 (opts, callback, callback_data) = WarpOptions(**kwargs)
610 else:
611 (opts, callback, callback_data) = kwargs['options']
612 if _is_str_or_unicode(srcDSOrSrcDSTab):
613 srcDSTab = [Open(srcDSOrSrcDSTab)]
614 elif isinstance(srcDSOrSrcDSTab, list):
615 srcDSTab = []
616 for elt in srcDSOrSrcDSTab:
617 if _is_str_or_unicode(elt):
618 srcDSTab.append(Open(elt))
619 else:
620 srcDSTab.append(elt)
621 else:
622 srcDSTab = [srcDSOrSrcDSTab]
623
624 if _is_str_or_unicode(destNameOrDestDS):
625 return wrapper_GDALWarpDestName(destNameOrDestDS, srcDSTab, opts, callback, callback_data)
626 else:
627 return wrapper_GDALWarpDestDS(destNameOrDestDS, srcDSTab, opts, callback, callback_data)
628
629
630 -def VectorTranslateOptions(options=None, format=None,
631 accessMode=None,
632 srcSRS=None, dstSRS=None, reproject=True,
633 coordinateOperation=None,
634 SQLStatement=None, SQLDialect=None, where=None, selectFields=None,
635 addFields=False,
636 forceNullable=False,
637 spatFilter=None, spatSRS=None,
638 datasetCreationOptions=None,
639 layerCreationOptions=None,
640 layers=None,
641 layerName=None,
642 geometryType=None,
643 dim=None,
644 segmentizeMaxDist= None,
645 zField=None,
646 skipFailures=False,
647 limit=None,
648 callback=None, callback_data=None):
649 """ Create a VectorTranslateOptions() object that can be passed to gdal.VectorTranslate()
650 Keyword arguments are :
651 options --- can be be an array of strings, a string or let empty and filled from other keywords.
652 format --- output format ("ESRI Shapefile", etc...)
653 accessMode --- None for creation, 'update', 'append', 'overwrite'
654 srcSRS --- source SRS
655 dstSRS --- output SRS (with reprojection if reproject = True)
656 coordinateOperation -- coordinate operation as a PROJ string or WKT string
657 reproject --- whether to do reprojection
658 SQLStatement --- SQL statement to apply to the source dataset
659 SQLDialect --- SQL dialect ('OGRSQL', 'SQLITE', ...)
660 where --- WHERE clause to apply to source layer(s)
661 selectFields --- list of fields to select
662 addFields --- whether to add new fields found in source layers (to be used with accessMode == 'append')
663 forceNullable --- whether to drop NOT NULL constraints on newly created fields
664 spatFilter --- spatial filter as (minX, minY, maxX, maxY) bounding box
665 spatSRS --- SRS in which the spatFilter is expressed. If not specified, it is assumed to be the one of the layer(s)
666 datasetCreationOptions --- list of dataset creation options
667 layerCreationOptions --- list of layer creation options
668 layers --- list of layers to convert
669 layerName --- output layer name
670 geometryType --- output layer geometry type ('POINT', ....)
671 dim --- output dimension ('XY', 'XYZ', 'XYM', 'XYZM', 'layer_dim')
672 segmentizeMaxDist --- maximum distance between consecutive nodes of a line geometry
673 zField --- name of field to use to set the Z component of geometries
674 skipFailures --- whether to skip failures
675 limit -- maximum number of features to read per layer
676 callback --- callback method
677 callback_data --- user data for callback
678 """
679 options = [] if options is None else options
680
681 if _is_str_or_unicode(options):
682 new_options = ParseCommandLine(options)
683 else:
684 new_options = options
685 if format is not None:
686 new_options += ['-f', format]
687 if srcSRS is not None:
688 new_options += ['-s_srs', str(srcSRS)]
689 if dstSRS is not None:
690 if reproject:
691 new_options += ['-t_srs', str(dstSRS)]
692 else:
693 new_options += ['-a_srs', str(dstSRS)]
694 if coordinateOperation is not None:
695 new_options += ['-ct', coordinateOperation]
696 if SQLStatement is not None:
697 new_options += ['-sql', str(SQLStatement)]
698 if SQLDialect is not None:
699 new_options += ['-dialect', str(SQLDialect)]
700 if where is not None:
701 new_options += ['-where', str(where)]
702 if accessMode is not None:
703 if accessMode == 'update':
704 new_options += ['-update']
705 elif accessMode == 'append':
706 new_options += ['-append']
707 elif accessMode == 'overwrite':
708 new_options += ['-overwrite']
709 else:
710 raise Exception('unhandled accessMode')
711 if addFields:
712 new_options += ['-addfields']
713 if forceNullable:
714 new_options += ['-forceNullable']
715 if selectFields is not None:
716 val = ''
717 for item in selectFields:
718 if val:
719 val += ','
720 val += item
721 new_options += ['-select', val]
722 if datasetCreationOptions is not None:
723 for opt in datasetCreationOptions:
724 new_options += ['-dsco', opt]
725 if layerCreationOptions is not None:
726 for opt in layerCreationOptions:
727 new_options += ['-lco', opt]
728 if layers is not None:
729 if _is_str_or_unicode(layers):
730 new_options += [layers]
731 else:
732 for lyr in layers:
733 new_options += [lyr]
734 if segmentizeMaxDist is not None:
735 new_options += ['-segmentize', str(segmentizeMaxDist)]
736 if spatFilter is not None:
737 new_options += ['-spat', str(spatFilter[0]), str(spatFilter[1]), str(spatFilter[2]), str(spatFilter[3])]
738 if spatSRS is not None:
739 new_options += ['-spat_srs', str(spatSRS)]
740 if layerName is not None:
741 new_options += ['-nln', layerName]
742 if geometryType is not None:
743 new_options += ['-nlt', geometryType]
744 if dim is not None:
745 new_options += ['-dim', dim]
746 if zField is not None:
747 new_options += ['-zfield', zField]
748 if skipFailures:
749 new_options += ['-skip']
750 if limit is not None:
751 new_options += ['-limit', str(limit)]
752 if callback is not None:
753 new_options += ['-progress']
754
755 return (GDALVectorTranslateOptions(new_options), callback, callback_data)
756
758 """ Convert one vector dataset
759 Arguments are :
760 destNameOrDestDS --- Output dataset name or object
761 srcDS --- a Dataset object or a filename
762 Keyword arguments are :
763 options --- return of gdal.VectorTranslateOptions(), string or array of strings
764 other keywords arguments of gdal.VectorTranslateOptions()
765 If options is provided as a gdal.VectorTranslateOptions() object, other keywords are ignored. """
766
767 if 'options' not in kwargs or isinstance(kwargs['options'], list) or _is_str_or_unicode(kwargs['options']):
768 (opts, callback, callback_data) = VectorTranslateOptions(**kwargs)
769 else:
770 (opts, callback, callback_data) = kwargs['options']
771 if _is_str_or_unicode(srcDS):
772 srcDS = OpenEx(srcDS, gdalconst.OF_VECTOR)
773
774 if _is_str_or_unicode(destNameOrDestDS):
775 return wrapper_GDALVectorTranslateDestName(destNameOrDestDS, srcDS, opts, callback, callback_data)
776 else:
777 return wrapper_GDALVectorTranslateDestDS(destNameOrDestDS, srcDS, opts, callback, callback_data)
778
779 -def DEMProcessingOptions(options=None, colorFilename=None, format=None,
780 creationOptions=None, computeEdges=False, alg='Horn', band=1,
781 zFactor=None, scale=None, azimuth=None, altitude=None,
782 combined=False, multiDirectional=False, igor=False,
783 slopeFormat=None, trigonometric=False, zeroForFlat=False,
784 addAlpha=None,
785 callback=None, callback_data=None):
786 """ Create a DEMProcessingOptions() object that can be passed to gdal.DEMProcessing()
787 Keyword arguments are :
788 options --- can be be an array of strings, a string or let empty and filled from other keywords.
789 colorFilename --- (mandatory for "color-relief") name of file that contains palette definition for the "color-relief" processing.
790 format --- output format ("GTiff", etc...)
791 creationOptions --- list of creation options
792 computeEdges --- whether to compute values at raster edges.
793 alg --- 'ZevenbergenThorne' or 'Horn'
794 band --- source band number to use
795 zFactor --- (hillshade only) vertical exaggeration used to pre-multiply the elevations.
796 scale --- ratio of vertical units to horizontal.
797 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.
798 altitude ---(hillshade only) altitude of the light, in degrees. 90 if the light comes from above the DEM, 0 if it is raking light.
799 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.
800 multiDirectional --- (hillshade only) whether to compute multi-directional shading. Only one of combined, multiDirectional and igor can be specified.
801 igor --- (hillshade only) whether to use Igor's hillshading from Maperitive. Only one of combined, multiDirectional and igor can be specified.
802 slopeformat --- (slope only) "degree" or "percent".
803 trigonometric --- (aspect only) whether to return trigonometric angle instead of azimuth. Thus 0deg means East, 90deg North, 180deg West, 270deg South.
804 zeroForFlat --- (aspect only) whether to return 0 for flat areas with slope=0, instead of -9999.
805 addAlpha --- adds an alpha band to the output file (only for processing = 'color-relief')
806 callback --- callback method
807 callback_data --- user data for callback
808 """
809 options = [] if options is None else options
810
811 if _is_str_or_unicode(options):
812 new_options = ParseCommandLine(options)
813 else:
814 new_options = options
815 if format is not None:
816 new_options += ['-of', format]
817 if creationOptions is not None:
818 for opt in creationOptions:
819 new_options += ['-co', opt]
820 if computeEdges:
821 new_options += ['-compute_edges']
822 if alg == 'ZevenbergenThorne':
823 new_options += ['-alg', 'ZevenbergenThorne']
824 new_options += ['-b', str(band)]
825 if zFactor is not None:
826 new_options += ['-z', str(zFactor)]
827 if scale is not None:
828 new_options += ['-s', str(scale)]
829 if azimuth is not None:
830 new_options += ['-az', str(azimuth)]
831 if altitude is not None:
832 new_options += ['-alt', str(altitude)]
833 if combined:
834 new_options += ['-combined']
835 if multiDirectional:
836 new_options += ['-multidirectional']
837 if igor:
838 new_options += ['-igor']
839 if slopeFormat == 'percent':
840 new_options += ['-p']
841 if trigonometric:
842 new_options += ['-trigonometric']
843 if zeroForFlat:
844 new_options += ['-zero_for_flat']
845 if addAlpha:
846 new_options += ['-alpha']
847
848 return (GDALDEMProcessingOptions(new_options), colorFilename, callback, callback_data)
849
851 """ Apply a DEM processing.
852 Arguments are :
853 destName --- Output dataset name
854 srcDS --- a Dataset object or a filename
855 processing --- one of "hillshade", "slope", "aspect", "color-relief", "TRI", "TPI", "Roughness"
856 Keyword arguments are :
857 options --- return of gdal.DEMProcessingOptions(), string or array of strings
858 other keywords arguments of gdal.DEMProcessingOptions()
859 If options is provided as a gdal.DEMProcessingOptions() object, other keywords are ignored. """
860
861 if 'options' not in kwargs or isinstance(kwargs['options'], list) or _is_str_or_unicode(kwargs['options']):
862 (opts, colorFilename, callback, callback_data) = DEMProcessingOptions(**kwargs)
863 else:
864 (opts, colorFilename, callback, callback_data) = kwargs['options']
865 if _is_str_or_unicode(srcDS):
866 srcDS = Open(srcDS)
867
868 return DEMProcessingInternal(destName, srcDS, processing, colorFilename, opts, callback, callback_data)
869
870
871 -def NearblackOptions(options=None, format=None,
872 creationOptions=None, white = False, colors=None,
873 maxNonBlack=None, nearDist=None, setAlpha = False, setMask = False,
874 callback=None, callback_data=None):
875 """ Create a NearblackOptions() object that can be passed to gdal.Nearblack()
876 Keyword arguments are :
877 options --- can be be an array of strings, a string or let empty and filled from other keywords.
878 format --- output format ("GTiff", etc...)
879 creationOptions --- list of creation options
880 white --- whether to search for nearly white (255) pixels instead of nearly black pixels.
881 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
882 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.
883 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.
884 setAlpha --- adds an alpha band to the output file.
885 setMask --- adds a mask band to the output file.
886 callback --- callback method
887 callback_data --- user data for callback
888 """
889 options = [] if options is None else options
890
891 if _is_str_or_unicode(options):
892 new_options = ParseCommandLine(options)
893 else:
894 new_options = options
895 if format is not None:
896 new_options += ['-of', format]
897 if creationOptions is not None:
898 for opt in creationOptions:
899 new_options += ['-co', opt]
900 if white:
901 new_options += ['-white']
902 if colors is not None:
903 for color in colors:
904 color_str = ''
905 for cpt in color:
906 if color_str != '':
907 color_str += ','
908 color_str += str(cpt)
909 new_options += ['-color', color_str]
910 if maxNonBlack is not None:
911 new_options += ['-nb', str(maxNonBlack)]
912 if nearDist is not None:
913 new_options += ['-near', str(nearDist)]
914 if setAlpha:
915 new_options += ['-setalpha']
916 if setMask:
917 new_options += ['-setmask']
918
919 return (GDALNearblackOptions(new_options), callback, callback_data)
920
921 -def Nearblack(destNameOrDestDS, srcDS, **kwargs):
922 """ Convert nearly black/white borders to exact value.
923 Arguments are :
924 destNameOrDestDS --- Output dataset name or object
925 srcDS --- a Dataset object or a filename
926 Keyword arguments are :
927 options --- return of gdal.NearblackOptions(), string or array of strings
928 other keywords arguments of gdal.NearblackOptions()
929 If options is provided as a gdal.NearblackOptions() object, other keywords are ignored. """
930
931 if 'options' not in kwargs or isinstance(kwargs['options'], list) or _is_str_or_unicode(kwargs['options']):
932 (opts, callback, callback_data) = NearblackOptions(**kwargs)
933 else:
934 (opts, callback, callback_data) = kwargs['options']
935 if _is_str_or_unicode(srcDS):
936 srcDS = OpenEx(srcDS)
937
938 if _is_str_or_unicode(destNameOrDestDS):
939 return wrapper_GDALNearblackDestName(destNameOrDestDS, srcDS, opts, callback, callback_data)
940 else:
941 return wrapper_GDALNearblackDestDS(destNameOrDestDS, srcDS, opts, callback, callback_data)
942
943
944 -def GridOptions(options=None, format=None,
945 outputType=gdalconst.GDT_Unknown,
946 width=0, height=0,
947 creationOptions=None,
948 outputBounds=None,
949 outputSRS=None,
950 noData=None,
951 algorithm=None,
952 layers=None,
953 SQLStatement=None,
954 where=None,
955 spatFilter=None,
956 zfield=None,
957 z_increase=None,
958 z_multiply=None,
959 callback=None, callback_data=None):
960 """ Create a GridOptions() object that can be passed to gdal.Grid()
961 Keyword arguments are :
962 options --- can be be an array of strings, a string or let empty and filled from other keywords.
963 format --- output format ("GTiff", etc...)
964 outputType --- output type (gdalconst.GDT_Byte, etc...)
965 width --- width of the output raster in pixel
966 height --- height of the output raster in pixel
967 creationOptions --- list of creation options
968 outputBounds --- assigned output bounds: [ulx, uly, lrx, lry]
969 outputSRS --- assigned output SRS
970 noData --- nodata value
971 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"
972 layers --- list of layers to convert
973 SQLStatement --- SQL statement to apply to the source dataset
974 where --- WHERE clause to apply to source layer(s)
975 spatFilter --- spatial filter as (minX, minY, maxX, maxY) bounding box
976 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.
977 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.
978 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.
979 callback --- callback method
980 callback_data --- user data for callback
981 """
982 options = [] if options is None else options
983
984 if _is_str_or_unicode(options):
985 new_options = ParseCommandLine(options)
986 else:
987 new_options = options
988 if format is not None:
989 new_options += ['-of', format]
990 if outputType != gdalconst.GDT_Unknown:
991 new_options += ['-ot', GetDataTypeName(outputType)]
992 if width != 0 or height != 0:
993 new_options += ['-outsize', str(width), str(height)]
994 if creationOptions is not None:
995 for opt in creationOptions:
996 new_options += ['-co', opt]
997 if outputBounds is not None:
998 new_options += ['-txe', _strHighPrec(outputBounds[0]), _strHighPrec(outputBounds[2]), '-tye', _strHighPrec(outputBounds[1]), _strHighPrec(outputBounds[3])]
999 if outputSRS is not None:
1000 new_options += ['-a_srs', str(outputSRS)]
1001 if algorithm is not None:
1002 new_options += ['-a', algorithm]
1003 if layers is not None:
1004 if isinstance(layers, (tuple, list)):
1005 for layer in layers:
1006 new_options += ['-l', layer]
1007 else:
1008 new_options += ['-l', layers]
1009 if SQLStatement is not None:
1010 new_options += ['-sql', str(SQLStatement)]
1011 if where is not None:
1012 new_options += ['-where', str(where)]
1013 if zfield is not None:
1014 new_options += ['-zfield', zfield]
1015 if z_increase is not None:
1016 new_options += ['-z_increase', str(z_increase)]
1017 if z_multiply is not None:
1018 new_options += ['-z_multiply', str(z_multiply)]
1019 if spatFilter is not None:
1020 new_options += ['-spat', str(spatFilter[0]), str(spatFilter[1]), str(spatFilter[2]), str(spatFilter[3])]
1021
1022 return (GDALGridOptions(new_options), callback, callback_data)
1023
1024 -def Grid(destName, srcDS, **kwargs):
1025 """ Create raster from the scattered data.
1026 Arguments are :
1027 destName --- Output dataset name
1028 srcDS --- a Dataset object or a filename
1029 Keyword arguments are :
1030 options --- return of gdal.GridOptions(), string or array of strings
1031 other keywords arguments of gdal.GridOptions()
1032 If options is provided as a gdal.GridOptions() object, other keywords are ignored. """
1033
1034 if 'options' not in kwargs or isinstance(kwargs['options'], list) or _is_str_or_unicode(kwargs['options']):
1035 (opts, callback, callback_data) = GridOptions(**kwargs)
1036 else:
1037 (opts, callback, callback_data) = kwargs['options']
1038 if _is_str_or_unicode(srcDS):
1039 srcDS = OpenEx(srcDS, gdalconst.OF_VECTOR)
1040
1041 return GridInternal(destName, srcDS, opts, callback, callback_data)
1042
1043 -def RasterizeOptions(options=None, format=None,
1044 outputType=gdalconst.GDT_Unknown,
1045 creationOptions=None, noData=None, initValues=None,
1046 outputBounds=None, outputSRS=None,
1047 transformerOptions=None,
1048 width=None, height=None,
1049 xRes=None, yRes=None, targetAlignedPixels=False,
1050 bands=None, inverse=False, allTouched=False,
1051 burnValues=None, attribute=None, useZ=False, layers=None,
1052 SQLStatement=None, SQLDialect=None, where=None, optim=None,
1053 callback=None, callback_data=None):
1054 """ Create a RasterizeOptions() object that can be passed to gdal.Rasterize()
1055 Keyword arguments are :
1056 options --- can be be an array of strings, a string or let empty and filled from other keywords.
1057 format --- output format ("GTiff", etc...)
1058 outputType --- output type (gdalconst.GDT_Byte, etc...)
1059 creationOptions --- list of creation options
1060 outputBounds --- assigned output bounds: [minx, miny, maxx, maxy]
1061 outputSRS --- assigned output SRS
1062 transformerOptions --- list of transformer options
1063 width --- width of the output raster in pixel
1064 height --- height of the output raster in pixel
1065 xRes, yRes --- output resolution in target SRS
1066 targetAlignedPixels --- whether to force output bounds to be multiple of output resolution
1067 noData --- nodata value
1068 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.
1069 bands --- list of output bands to burn values into
1070 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.
1071 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.
1072 burnValues -- list of fixed values to burn into each band for all objects. Excusive with attribute.
1073 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.
1074 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.
1075 layers --- list of layers from the datasource that will be used for input features.
1076 SQLStatement --- SQL statement to apply to the source dataset
1077 SQLDialect --- SQL dialect ('OGRSQL', 'SQLITE', ...)
1078 where --- WHERE clause to apply to source layer(s)
1079 callback --- callback method
1080 callback_data --- user data for callback
1081 """
1082 options = [] if options is None else options
1083
1084 if _is_str_or_unicode(options):
1085 new_options = ParseCommandLine(options)
1086 else:
1087 new_options = options
1088 if format is not None:
1089 new_options += ['-of', format]
1090 if outputType != gdalconst.GDT_Unknown:
1091 new_options += ['-ot', GetDataTypeName(outputType)]
1092 if creationOptions is not None:
1093 for opt in creationOptions:
1094 new_options += ['-co', opt]
1095 if bands is not None:
1096 for b in bands:
1097 new_options += ['-b', str(b)]
1098 if noData is not None:
1099 new_options += ['-a_nodata', str(noData)]
1100 if initValues is not None:
1101 if isinstance(initValues, (tuple, list)):
1102 for val in initValues:
1103 new_options += ['-init', str(val)]
1104 else:
1105 new_options += ['-init', str(initValues)]
1106 if outputBounds is not None:
1107 new_options += ['-te', _strHighPrec(outputBounds[0]), _strHighPrec(outputBounds[1]), _strHighPrec(outputBounds[2]), _strHighPrec(outputBounds[3])]
1108 if outputSRS is not None:
1109 new_options += ['-a_srs', str(outputSRS)]
1110 if transformerOptions is not None:
1111 for opt in transformerOptions:
1112 new_options += ['-to', opt]
1113 if width is not None and height is not None:
1114 new_options += ['-ts', str(width), str(height)]
1115 if xRes is not None and yRes is not None:
1116 new_options += ['-tr', _strHighPrec(xRes), _strHighPrec(yRes)]
1117 if targetAlignedPixels:
1118 new_options += ['-tap']
1119 if inverse:
1120 new_options += ['-i']
1121 if allTouched:
1122 new_options += ['-at']
1123 if burnValues is not None:
1124 if attribute is not None:
1125 raise Exception('burnValues and attribute option are exclusive.')
1126 if isinstance(burnValues, (tuple, list)):
1127 for val in burnValues:
1128 new_options += ['-burn', str(val)]
1129 else:
1130 new_options += ['-burn', str(burnValues)]
1131 if attribute is not None:
1132 new_options += ['-a', attribute]
1133 if useZ:
1134 new_options += ['-3d']
1135 if layers is not None:
1136 if isinstance(layers, ((tuple, list))):
1137 for layer in layers:
1138 new_options += ['-l', layer]
1139 else:
1140 new_options += ['-l', layers]
1141 if SQLStatement is not None:
1142 new_options += ['-sql', str(SQLStatement)]
1143 if SQLDialect is not None:
1144 new_options += ['-dialect', str(SQLDialect)]
1145 if where is not None:
1146 new_options += ['-where', str(where)]
1147 if optim is not None:
1148 new_options += ['-optim', str(optim)]
1149
1150 return (GDALRasterizeOptions(new_options), callback, callback_data)
1151
1152 -def Rasterize(destNameOrDestDS, srcDS, **kwargs):
1153 """ Burns vector geometries into a raster
1154 Arguments are :
1155 destNameOrDestDS --- Output dataset name or object
1156 srcDS --- a Dataset object or a filename
1157 Keyword arguments are :
1158 options --- return of gdal.RasterizeOptions(), string or array of strings
1159 other keywords arguments of gdal.RasterizeOptions()
1160 If options is provided as a gdal.RasterizeOptions() object, other keywords are ignored. """
1161
1162 if 'options' not in kwargs or isinstance(kwargs['options'], list) or _is_str_or_unicode(kwargs['options']):
1163 (opts, callback, callback_data) = RasterizeOptions(**kwargs)
1164 else:
1165 (opts, callback, callback_data) = kwargs['options']
1166 if _is_str_or_unicode(srcDS):
1167 srcDS = OpenEx(srcDS, gdalconst.OF_VECTOR)
1168
1169 if _is_str_or_unicode(destNameOrDestDS):
1170 return wrapper_GDALRasterizeDestName(destNameOrDestDS, srcDS, opts, callback, callback_data)
1171 else:
1172 return wrapper_GDALRasterizeDestDS(destNameOrDestDS, srcDS, opts, callback, callback_data)
1173
1174
1175 -def BuildVRTOptions(options=None,
1176 resolution=None,
1177 outputBounds=None,
1178 xRes=None, yRes=None,
1179 targetAlignedPixels=None,
1180 separate=None,
1181 bandList=None,
1182 addAlpha=None,
1183 resampleAlg=None,
1184 outputSRS=None,
1185 allowProjectionDifference=None,
1186 srcNodata=None,
1187 VRTNodata=None,
1188 hideNodata=None,
1189 callback=None, callback_data=None):
1190 """ Create a BuildVRTOptions() object that can be passed to gdal.BuildVRT()
1191 Keyword arguments are :
1192 options --- can be be an array of strings, a string or let empty and filled from other keywords..
1193 resolution --- 'highest', 'lowest', 'average', 'user'.
1194 outputBounds --- output bounds as (minX, minY, maxX, maxY) in target SRS.
1195 xRes, yRes --- output resolution in target SRS.
1196 targetAlignedPixels --- whether to force output bounds to be multiple of output resolution.
1197 separate --- whether each source file goes into a separate stacked band in the VRT band.
1198 bandList --- array of band numbers (index start at 1).
1199 addAlpha --- whether to add an alpha mask band to the VRT when the source raster have none.
1200 resampleAlg --- resampling mode.
1201 outputSRS --- assigned output SRS.
1202 allowProjectionDifference --- whether to accept input datasets have not the same projection. Note: they will *not* be reprojected.
1203 srcNodata --- source nodata value(s).
1204 VRTNodata --- nodata values at the VRT band level.
1205 hideNodata --- whether to make the VRT band not report the NoData value.
1206 callback --- callback method.
1207 callback_data --- user data for callback.
1208 """
1209 options = [] if options is None else options
1210
1211 if _is_str_or_unicode(options):
1212 new_options = ParseCommandLine(options)
1213 else:
1214 new_options = options
1215 if resolution is not None:
1216 new_options += ['-resolution', str(resolution)]
1217 if outputBounds is not None:
1218 new_options += ['-te', _strHighPrec(outputBounds[0]), _strHighPrec(outputBounds[1]), _strHighPrec(outputBounds[2]), _strHighPrec(outputBounds[3])]
1219 if xRes is not None and yRes is not None:
1220 new_options += ['-tr', _strHighPrec(xRes), _strHighPrec(yRes)]
1221 if targetAlignedPixels:
1222 new_options += ['-tap']
1223 if separate:
1224 new_options += ['-separate']
1225 if bandList != None:
1226 for b in bandList:
1227 new_options += ['-b', str(b)]
1228 if addAlpha:
1229 new_options += ['-addalpha']
1230 if resampleAlg is not None:
1231 if resampleAlg == gdalconst.GRIORA_NearestNeighbour:
1232 new_options += ['-r', 'near']
1233 elif resampleAlg == gdalconst.GRIORA_Bilinear:
1234 new_options += ['-rb']
1235 elif resampleAlg == gdalconst.GRIORA_Cubic:
1236 new_options += ['-rc']
1237 elif resampleAlg == gdalconst.GRIORA_CubicSpline:
1238 new_options += ['-rcs']
1239 elif resampleAlg == gdalconst.GRIORA_Lanczos:
1240 new_options += ['-r', 'lanczos']
1241 elif resampleAlg == gdalconst.GRIORA_Average:
1242 new_options += ['-r', 'average']
1243 elif resampleAlg == gdalconst.GRIORA_Mode:
1244 new_options += ['-r', 'mode']
1245 elif resampleAlg == gdalconst.GRIORA_Gauss:
1246 new_options += ['-r', 'gauss']
1247 else:
1248 new_options += ['-r', str(resampleAlg)]
1249 if outputSRS is not None:
1250 new_options += ['-a_srs', str(outputSRS)]
1251 if allowProjectionDifference:
1252 new_options += ['-allow_projection_difference']
1253 if srcNodata is not None:
1254 new_options += ['-srcnodata', str(srcNodata)]
1255 if VRTNodata is not None:
1256 new_options += ['-vrtnodata', str(VRTNodata)]
1257 if hideNodata:
1258 new_options += ['-hidenodata']
1259
1260 return (GDALBuildVRTOptions(new_options), callback, callback_data)
1261
1262 -def BuildVRT(destName, srcDSOrSrcDSTab, **kwargs):
1263 """ Build a VRT from a list of datasets.
1264 Arguments are :
1265 destName --- Output dataset name
1266 srcDSOrSrcDSTab --- an array of Dataset objects or filenames, or a Dataset object or a filename
1267 Keyword arguments are :
1268 options --- return of gdal.BuildVRTOptions(), string or array of strings
1269 other keywords arguments of gdal.BuildVRTOptions()
1270 If options is provided as a gdal.BuildVRTOptions() object, other keywords are ignored. """
1271
1272 if 'options' not in kwargs or isinstance(kwargs['options'], list) or _is_str_or_unicode(kwargs['options']):
1273 (opts, callback, callback_data) = BuildVRTOptions(**kwargs)
1274 else:
1275 (opts, callback, callback_data) = kwargs['options']
1276
1277 srcDSTab = []
1278 srcDSNamesTab = []
1279 if _is_str_or_unicode(srcDSOrSrcDSTab):
1280 srcDSNamesTab = [srcDSOrSrcDSTab]
1281 elif isinstance(srcDSOrSrcDSTab, list):
1282 for elt in srcDSOrSrcDSTab:
1283 if _is_str_or_unicode(elt):
1284 srcDSNamesTab.append(elt)
1285 else:
1286 srcDSTab.append(elt)
1287 if srcDSTab and srcDSNamesTab:
1288 raise Exception('Mix of names and dataset objects not supported')
1289 else:
1290 srcDSTab = [srcDSOrSrcDSTab]
1291
1292 if srcDSTab:
1293 return BuildVRTInternalObjects(destName, srcDSTab, opts, callback, callback_data)
1294 else:
1295 return BuildVRTInternalNames(destName, srcDSNamesTab, opts, callback, callback_data)
1296
1297
1298
1308
1333
1334
1335
1337 """Debug(char const * msg_class, char const * message)"""
1338 return _gdal.Debug(*args)
1339
1341 """SetErrorHandler(CPLErrorHandler pfnErrorHandler=0) -> CPLErr"""
1342 return _gdal.SetErrorHandler(*args)
1343
1345 """PushErrorHandler(CPLErrorHandler pfnErrorHandler=0) -> CPLErr"""
1346 return _gdal.PushErrorHandler(*args)
1347
1351
1353 """Error(CPLErr msg_class, int err_code=0, char const * msg)"""
1354 return _gdal.Error(*args)
1355
1357 """GOA2GetAuthorizationURL(char const * pszScope) -> retStringAndCPLFree *"""
1358 return _gdal.GOA2GetAuthorizationURL(*args)
1359
1361 """GOA2GetRefreshToken(char const * pszAuthToken, char const * pszScope) -> retStringAndCPLFree *"""
1362 return _gdal.GOA2GetRefreshToken(*args)
1363
1365 """GOA2GetAccessToken(char const * pszRefreshToken, char const * pszScope) -> retStringAndCPLFree *"""
1366 return _gdal.GOA2GetAccessToken(*args)
1367
1369 """ErrorReset()"""
1370 return _gdal.ErrorReset(*args)
1371
1373 """EscapeString(int len, int scheme) -> retStringAndCPLFree *"""
1374 return _gdal.EscapeString(*args, **kwargs)
1375
1377 """GetLastErrorNo() -> int"""
1378 return _gdal.GetLastErrorNo(*args)
1379
1383
1385 """GetLastErrorMsg() -> char const *"""
1386 return _gdal.GetLastErrorMsg(*args)
1387
1389 """GetErrorCounter() -> unsigned int"""
1390 return _gdal.GetErrorCounter(*args)
1391
1395
1397 """VSIGetLastErrorMsg() -> char const *"""
1398 return _gdal.VSIGetLastErrorMsg(*args)
1399
1401 """VSIErrorReset()"""
1402 return _gdal.VSIErrorReset(*args)
1403
1405 """PushFinderLocation(char const * utf8_path)"""
1406 return _gdal.PushFinderLocation(*args)
1407
1411
1413 """FinderClean()"""
1414 return _gdal.FinderClean(*args)
1415
1417 """FindFile(char const * pszClass, char const * utf8_path) -> char const *"""
1418 return _gdal.FindFile(*args)
1419
1421 """ReadDir(char const * utf8_path, int nMaxFiles=0) -> char **"""
1422 return _gdal.ReadDir(*args)
1423
1425 """ReadDirRecursive(char const * utf8_path) -> char **"""
1426 return _gdal.ReadDirRecursive(*args)
1427
1429 """OpenDir(char const * utf8_path, int nRecurseDepth=-1, char ** options=None) -> VSIDIR *"""
1430 return _gdal.OpenDir(*args)
1431 -class DirEntry(_object):
1432 """Proxy of C++ DirEntry class."""
1433
1434 __swig_setmethods__ = {}
1435 __setattr__ = lambda self, name, value: _swig_setattr(self, DirEntry, name, value)
1436 __swig_getmethods__ = {}
1437 __getattr__ = lambda self, name: _swig_getattr(self, DirEntry, name)
1438 __repr__ = _swig_repr
1439 __swig_getmethods__["name"] = _gdal.DirEntry_name_get
1440 if _newclass:
1441 name = _swig_property(_gdal.DirEntry_name_get)
1442 __swig_getmethods__["mode"] = _gdal.DirEntry_mode_get
1443 if _newclass:
1444 mode = _swig_property(_gdal.DirEntry_mode_get)
1445 __swig_getmethods__["size"] = _gdal.DirEntry_size_get
1446 if _newclass:
1447 size = _swig_property(_gdal.DirEntry_size_get)
1448 __swig_getmethods__["mtime"] = _gdal.DirEntry_mtime_get
1449 if _newclass:
1450 mtime = _swig_property(_gdal.DirEntry_mtime_get)
1451 __swig_getmethods__["modeKnown"] = _gdal.DirEntry_modeKnown_get
1452 if _newclass:
1453 modeKnown = _swig_property(_gdal.DirEntry_modeKnown_get)
1454 __swig_getmethods__["sizeKnown"] = _gdal.DirEntry_sizeKnown_get
1455 if _newclass:
1456 sizeKnown = _swig_property(_gdal.DirEntry_sizeKnown_get)
1457 __swig_getmethods__["mtimeKnown"] = _gdal.DirEntry_mtimeKnown_get
1458 if _newclass:
1459 mtimeKnown = _swig_property(_gdal.DirEntry_mtimeKnown_get)
1460 __swig_getmethods__["extra"] = _gdal.DirEntry_extra_get
1461 if _newclass:
1462 extra = _swig_property(_gdal.DirEntry_extra_get)
1463
1464 - def __init__(self, *args):
1465 """__init__(DirEntry self, DirEntry entryIn) -> DirEntry"""
1466 this = _gdal.new_DirEntry(*args)
1467 try:
1468 self.this.append(this)
1469 except Exception:
1470 self.this = this
1471 __swig_destroy__ = _gdal.delete_DirEntry
1472 __del__ = lambda self: None
1473
1474 - def IsDirectory(self, *args):
1475 """IsDirectory(DirEntry self) -> bool"""
1476 return _gdal.DirEntry_IsDirectory(self, *args)
1477
1478 DirEntry_swigregister = _gdal.DirEntry_swigregister
1479 DirEntry_swigregister(DirEntry)
1480
1481
1482 -def GetNextDirEntry(*args):
1483 """GetNextDirEntry(VSIDIR * dir) -> DirEntry"""
1484 return _gdal.GetNextDirEntry(*args)
1485
1487 """CloseDir(VSIDIR * dir)"""
1488 return _gdal.CloseDir(*args)
1489
1491 """SetConfigOption(char const * pszKey, char const * pszValue)"""
1492 return _gdal.SetConfigOption(*args)
1493
1495 """GetConfigOption(char const * pszKey, char const * pszDefault=None) -> char const *"""
1496 return _gdal.GetConfigOption(*args)
1497
1499 """CPLBinaryToHex(int nBytes) -> retStringAndCPLFree *"""
1500 return _gdal.CPLBinaryToHex(*args)
1501
1503 """CPLHexToBinary(char const * pszHex, int * pnBytes) -> GByte *"""
1504 return _gdal.CPLHexToBinary(*args)
1505
1507 """FileFromMemBuffer(char const * utf8_path, GIntBig nBytes)"""
1508 return _gdal.FileFromMemBuffer(*args)
1509
1511 """Unlink(char const * utf8_path) -> VSI_RETVAL"""
1512 return _gdal.Unlink(*args)
1513
1517
1519 """Mkdir(char const * utf8_path, int mode) -> VSI_RETVAL"""
1520 return _gdal.Mkdir(*args)
1521
1523 """Rmdir(char const * utf8_path) -> VSI_RETVAL"""
1524 return _gdal.Rmdir(*args)
1525
1527 """MkdirRecursive(char const * utf8_path, int mode) -> VSI_RETVAL"""
1528 return _gdal.MkdirRecursive(*args)
1529
1531 """RmdirRecursive(char const * utf8_path) -> VSI_RETVAL"""
1532 return _gdal.RmdirRecursive(*args)
1533
1535 """Rename(char const * pszOld, char const * pszNew) -> VSI_RETVAL"""
1536 return _gdal.Rename(*args)
1537
1538 -def Sync(*args, **kwargs):
1539 """Sync(char const * pszSource, char const * pszTarget, char ** options=None, GDALProgressFunc callback=0, void * callback_data=None) -> bool"""
1540 return _gdal.Sync(*args, **kwargs)
1541
1543 """GetActualURL(char const * utf8_path) -> char const *"""
1544 return _gdal.GetActualURL(*args)
1545
1547 """GetSignedURL(char const * utf8_path, char ** options=None) -> retStringAndCPLFree *"""
1548 return _gdal.GetSignedURL(*args)
1549
1553
1555 """GetFileSystemOptions(char const * utf8_path) -> char const *"""
1556 return _gdal.GetFileSystemOptions(*args)
1568 VSILFILE_swigregister = _gdal.VSILFILE_swigregister
1569 VSILFILE_swigregister(VSILFILE)
1570
1571
1572 _gdal.VSI_STAT_EXISTS_FLAG_swigconstant(_gdal)
1573 VSI_STAT_EXISTS_FLAG = _gdal.VSI_STAT_EXISTS_FLAG
1574
1575 _gdal.VSI_STAT_NATURE_FLAG_swigconstant(_gdal)
1576 VSI_STAT_NATURE_FLAG = _gdal.VSI_STAT_NATURE_FLAG
1577
1578 _gdal.VSI_STAT_SIZE_FLAG_swigconstant(_gdal)
1579 VSI_STAT_SIZE_FLAG = _gdal.VSI_STAT_SIZE_FLAG
1581 """Proxy of C++ StatBuf class."""
1582
1583 __swig_setmethods__ = {}
1584 __setattr__ = lambda self, name, value: _swig_setattr(self, StatBuf, name, value)
1585 __swig_getmethods__ = {}
1586 __getattr__ = lambda self, name: _swig_getattr(self, StatBuf, name)
1587 __repr__ = _swig_repr
1588 __swig_getmethods__["mode"] = _gdal.StatBuf_mode_get
1589 if _newclass:
1590 mode = _swig_property(_gdal.StatBuf_mode_get)
1591 __swig_getmethods__["size"] = _gdal.StatBuf_size_get
1592 if _newclass:
1593 size = _swig_property(_gdal.StatBuf_size_get)
1594 __swig_getmethods__["mtime"] = _gdal.StatBuf_mtime_get
1595 if _newclass:
1596 mtime = _swig_property(_gdal.StatBuf_mtime_get)
1597
1599 """__init__(StatBuf self, StatBuf psStatBuf) -> StatBuf"""
1600 this = _gdal.new_StatBuf(*args)
1601 try:
1602 self.this.append(this)
1603 except Exception:
1604 self.this = this
1605 __swig_destroy__ = _gdal.delete_StatBuf
1606 __del__ = lambda self: None
1607
1609 """IsDirectory(StatBuf self) -> int"""
1610 return _gdal.StatBuf_IsDirectory(self, *args)
1611
1612 StatBuf_swigregister = _gdal.StatBuf_swigregister
1613 StatBuf_swigregister(StatBuf)
1614
1615
1617 """VSIStatL(char const * utf8_path, int nFlags=0) -> int"""
1618 return _gdal.VSIStatL(*args)
1619
1621 """VSIFOpenL(char const * utf8_path, char const * pszMode) -> VSILFILE"""
1622 return _gdal.VSIFOpenL(*args)
1623
1625 """VSIFOpenExL(char const * utf8_path, char const * pszMode, int bSetError) -> VSILFILE"""
1626 return _gdal.VSIFOpenExL(*args)
1627
1629 """VSIFEofL(VSILFILE fp) -> int"""
1630 return _gdal.VSIFEofL(*args)
1631
1633 """VSIFFlushL(VSILFILE fp) -> int"""
1634 return _gdal.VSIFFlushL(*args)
1635
1637 """VSIFCloseL(VSILFILE fp) -> VSI_RETVAL"""
1638 return _gdal.VSIFCloseL(*args)
1639
1641 """VSIFSeekL(VSILFILE fp, GIntBig offset, int whence) -> int"""
1642 return _gdal.VSIFSeekL(*args)
1643
1645 """VSIFTellL(VSILFILE fp) -> GIntBig"""
1646 return _gdal.VSIFTellL(*args)
1647
1649 """VSIFTruncateL(VSILFILE fp, GIntBig length) -> int"""
1650 return _gdal.VSIFTruncateL(*args)
1651
1653 """VSISupportsSparseFiles(char const * utf8_path) -> int"""
1654 return _gdal.VSISupportsSparseFiles(*args)
1655
1656 _gdal.VSI_RANGE_STATUS_UNKNOWN_swigconstant(_gdal)
1657 VSI_RANGE_STATUS_UNKNOWN = _gdal.VSI_RANGE_STATUS_UNKNOWN
1658
1659 _gdal.VSI_RANGE_STATUS_DATA_swigconstant(_gdal)
1660 VSI_RANGE_STATUS_DATA = _gdal.VSI_RANGE_STATUS_DATA
1661
1662 _gdal.VSI_RANGE_STATUS_HOLE_swigconstant(_gdal)
1663 VSI_RANGE_STATUS_HOLE = _gdal.VSI_RANGE_STATUS_HOLE
1664
1666 """VSIFGetRangeStatusL(VSILFILE fp, GIntBig offset, GIntBig length) -> int"""
1667 return _gdal.VSIFGetRangeStatusL(*args)
1668
1670 """VSIFWriteL(int nLen, int size, int memb, VSILFILE fp) -> int"""
1671 return _gdal.VSIFWriteL(*args)
1672
1676
1680
1682 """ParseCommandLine(char const * utf8_path) -> char **"""
1683 return _gdal.ParseCommandLine(*args)
1685 """Proxy of C++ GDALMajorObjectShadow class."""
1686
1687 __swig_setmethods__ = {}
1688 __setattr__ = lambda self, name, value: _swig_setattr(self, MajorObject, name, value)
1689 __swig_getmethods__ = {}
1690 __getattr__ = lambda self, name: _swig_getattr(self, MajorObject, name)
1691
1693 raise AttributeError("No constructor defined")
1694 __repr__ = _swig_repr
1695
1697 """GetDescription(MajorObject self) -> char const *"""
1698 return _gdal.MajorObject_GetDescription(self, *args)
1699
1700
1702 """SetDescription(MajorObject self, char const * pszNewDesc)"""
1703 return _gdal.MajorObject_SetDescription(self, *args)
1704
1705
1707 """GetMetadataDomainList(MajorObject self) -> char **"""
1708 return _gdal.MajorObject_GetMetadataDomainList(self, *args)
1709
1710
1714
1715
1719
1720
1727
1728
1732
1733
1737
1738
1743
1744 MajorObject_swigregister = _gdal.MajorObject_swigregister
1745 MajorObject_swigregister(MajorObject)
1746
1748 """Proxy of C++ GDALDriverShadow class."""
1749
1750 __swig_setmethods__ = {}
1751 for _s in [MajorObject]:
1752 __swig_setmethods__.update(getattr(_s, '__swig_setmethods__', {}))
1753 __setattr__ = lambda self, name, value: _swig_setattr(self, Driver, name, value)
1754 __swig_getmethods__ = {}
1755 for _s in [MajorObject]:
1756 __swig_getmethods__.update(getattr(_s, '__swig_getmethods__', {}))
1757 __getattr__ = lambda self, name: _swig_getattr(self, Driver, name)
1758
1760 raise AttributeError("No constructor defined")
1761 __repr__ = _swig_repr
1762 __swig_getmethods__["ShortName"] = _gdal.Driver_ShortName_get
1763 if _newclass:
1764 ShortName = _swig_property(_gdal.Driver_ShortName_get)
1765 __swig_getmethods__["LongName"] = _gdal.Driver_LongName_get
1766 if _newclass:
1767 LongName = _swig_property(_gdal.Driver_LongName_get)
1768 __swig_getmethods__["HelpTopic"] = _gdal.Driver_HelpTopic_get
1769 if _newclass:
1770 HelpTopic = _swig_property(_gdal.Driver_HelpTopic_get)
1771
1772 - def Create(self, *args, **kwargs):
1773 """Create(Driver self, char const * utf8_path, int xsize, int ysize, int bands=1, GDALDataType eType, char ** options=None) -> Dataset"""
1774 return _gdal.Driver_Create(self, *args, **kwargs)
1775
1776
1778 """CreateCopy(Driver self, char const * utf8_path, Dataset src, int strict=1, char ** options=None, GDALProgressFunc callback=0, void * callback_data=None) -> Dataset"""
1779 return _gdal.Driver_CreateCopy(self, *args, **kwargs)
1780
1781
1783 """Delete(Driver self, char const * utf8_path) -> CPLErr"""
1784 return _gdal.Driver_Delete(self, *args)
1785
1786
1788 """Rename(Driver self, char const * newName, char const * oldName) -> CPLErr"""
1789 return _gdal.Driver_Rename(self, *args)
1790
1791
1793 """CopyFiles(Driver self, char const * newName, char const * oldName) -> CPLErr"""
1794 return _gdal.Driver_CopyFiles(self, *args)
1795
1796
1798 """Register(Driver self) -> int"""
1799 return _gdal.Driver_Register(self, *args)
1800
1801
1803 """Deregister(Driver self)"""
1804 return _gdal.Driver_Deregister(self, *args)
1805
1806 Driver_swigregister = _gdal.Driver_swigregister
1807 Driver_swigregister(Driver)
1808
1809 from . import ogr
1810 from . import osr
1811 -class ColorEntry(_object):
1812 """Proxy of C++ GDALColorEntry class."""
1813
1814 __swig_setmethods__ = {}
1815 __setattr__ = lambda self, name, value: _swig_setattr(self, ColorEntry, name, value)
1816 __swig_getmethods__ = {}
1817 __getattr__ = lambda self, name: _swig_getattr(self, ColorEntry, name)
1818
1819 - def __init__(self, *args, **kwargs):
1820 raise AttributeError("No constructor defined")
1821 __repr__ = _swig_repr
1822 __swig_setmethods__["c1"] = _gdal.ColorEntry_c1_set
1823 __swig_getmethods__["c1"] = _gdal.ColorEntry_c1_get
1824 if _newclass:
1825 c1 = _swig_property(_gdal.ColorEntry_c1_get, _gdal.ColorEntry_c1_set)
1826 __swig_setmethods__["c2"] = _gdal.ColorEntry_c2_set
1827 __swig_getmethods__["c2"] = _gdal.ColorEntry_c2_get
1828 if _newclass:
1829 c2 = _swig_property(_gdal.ColorEntry_c2_get, _gdal.ColorEntry_c2_set)
1830 __swig_setmethods__["c3"] = _gdal.ColorEntry_c3_set
1831 __swig_getmethods__["c3"] = _gdal.ColorEntry_c3_get
1832 if _newclass:
1833 c3 = _swig_property(_gdal.ColorEntry_c3_get, _gdal.ColorEntry_c3_set)
1834 __swig_setmethods__["c4"] = _gdal.ColorEntry_c4_set
1835 __swig_getmethods__["c4"] = _gdal.ColorEntry_c4_get
1836 if _newclass:
1837 c4 = _swig_property(_gdal.ColorEntry_c4_get, _gdal.ColorEntry_c4_set)
1838 ColorEntry_swigregister = _gdal.ColorEntry_swigregister
1839 ColorEntry_swigregister(ColorEntry)
1840
1841 -class GCP(_object):
1842 """Proxy of C++ GDAL_GCP class."""
1843
1844 __swig_setmethods__ = {}
1845 __setattr__ = lambda self, name, value: _swig_setattr(self, GCP, name, value)
1846 __swig_getmethods__ = {}
1847 __getattr__ = lambda self, name: _swig_getattr(self, GCP, name)
1848 __repr__ = _swig_repr
1849 __swig_setmethods__["GCPX"] = _gdal.GCP_GCPX_set
1850 __swig_getmethods__["GCPX"] = _gdal.GCP_GCPX_get
1851 if _newclass:
1852 GCPX = _swig_property(_gdal.GCP_GCPX_get, _gdal.GCP_GCPX_set)
1853 __swig_setmethods__["GCPY"] = _gdal.GCP_GCPY_set
1854 __swig_getmethods__["GCPY"] = _gdal.GCP_GCPY_get
1855 if _newclass:
1856 GCPY = _swig_property(_gdal.GCP_GCPY_get, _gdal.GCP_GCPY_set)
1857 __swig_setmethods__["GCPZ"] = _gdal.GCP_GCPZ_set
1858 __swig_getmethods__["GCPZ"] = _gdal.GCP_GCPZ_get
1859 if _newclass:
1860 GCPZ = _swig_property(_gdal.GCP_GCPZ_get, _gdal.GCP_GCPZ_set)
1861 __swig_setmethods__["GCPPixel"] = _gdal.GCP_GCPPixel_set
1862 __swig_getmethods__["GCPPixel"] = _gdal.GCP_GCPPixel_get
1863 if _newclass:
1864 GCPPixel = _swig_property(_gdal.GCP_GCPPixel_get, _gdal.GCP_GCPPixel_set)
1865 __swig_setmethods__["GCPLine"] = _gdal.GCP_GCPLine_set
1866 __swig_getmethods__["GCPLine"] = _gdal.GCP_GCPLine_get
1867 if _newclass:
1868 GCPLine = _swig_property(_gdal.GCP_GCPLine_get, _gdal.GCP_GCPLine_set)
1869 __swig_setmethods__["Info"] = _gdal.GCP_Info_set
1870 __swig_getmethods__["Info"] = _gdal.GCP_Info_get
1871 if _newclass:
1872 Info = _swig_property(_gdal.GCP_Info_get, _gdal.GCP_Info_set)
1873 __swig_setmethods__["Id"] = _gdal.GCP_Id_set
1874 __swig_getmethods__["Id"] = _gdal.GCP_Id_get
1875 if _newclass:
1876 Id = _swig_property(_gdal.GCP_Id_get, _gdal.GCP_Id_set)
1877
1879 """__init__(GDAL_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"""
1880 this = _gdal.new_GCP(*args)
1881 try:
1882 self.this.append(this)
1883 except Exception:
1884 self.this = this
1885 __swig_destroy__ = _gdal.delete_GCP
1886 __del__ = lambda self: None
1887
1889 str = '%s (%.2fP,%.2fL) -> (%.7fE,%.7fN,%.2f) %s '\
1890 % (self.Id, self.GCPPixel, self.GCPLine,
1891 self.GCPX, self.GCPY, self.GCPZ, self.Info )
1892 return str
1893
1895 base = [gdalconst.CXT_Element,'GCP']
1896 base.append([gdalconst.CXT_Attribute,'Id',[gdalconst.CXT_Text,self.Id]])
1897 pixval = '%0.15E' % self.GCPPixel
1898 lineval = '%0.15E' % self.GCPLine
1899 xval = '%0.15E' % self.GCPX
1900 yval = '%0.15E' % self.GCPY
1901 zval = '%0.15E' % self.GCPZ
1902 base.append([gdalconst.CXT_Attribute,'Pixel',[gdalconst.CXT_Text,pixval]])
1903 base.append([gdalconst.CXT_Attribute,'Line',[gdalconst.CXT_Text,lineval]])
1904 base.append([gdalconst.CXT_Attribute,'X',[gdalconst.CXT_Text,xval]])
1905 base.append([gdalconst.CXT_Attribute,'Y',[gdalconst.CXT_Text,yval]])
1906 if with_Z:
1907 base.append([gdalconst.CXT_Attribute,'Z',[gdalconst.CXT_Text,zval]])
1908 return base
1909
1910 GCP_swigregister = _gdal.GCP_swigregister
1911 GCP_swigregister(GCP)
1912
1913
1915 """GDAL_GCP_GCPX_get(GCP gcp) -> double"""
1916 return _gdal.GDAL_GCP_GCPX_get(*args)
1917
1919 """GDAL_GCP_GCPX_set(GCP gcp, double dfGCPX)"""
1920 return _gdal.GDAL_GCP_GCPX_set(*args)
1921
1923 """GDAL_GCP_GCPY_get(GCP gcp) -> double"""
1924 return _gdal.GDAL_GCP_GCPY_get(*args)
1925
1927 """GDAL_GCP_GCPY_set(GCP gcp, double dfGCPY)"""
1928 return _gdal.GDAL_GCP_GCPY_set(*args)
1929
1931 """GDAL_GCP_GCPZ_get(GCP gcp) -> double"""
1932 return _gdal.GDAL_GCP_GCPZ_get(*args)
1933
1935 """GDAL_GCP_GCPZ_set(GCP gcp, double dfGCPZ)"""
1936 return _gdal.GDAL_GCP_GCPZ_set(*args)
1937
1941
1943 """GDAL_GCP_GCPPixel_set(GCP gcp, double dfGCPPixel)"""
1944 return _gdal.GDAL_GCP_GCPPixel_set(*args)
1945
1949
1951 """GDAL_GCP_GCPLine_set(GCP gcp, double dfGCPLine)"""
1952 return _gdal.GDAL_GCP_GCPLine_set(*args)
1953
1955 """GDAL_GCP_Info_get(GCP gcp) -> char const *"""
1956 return _gdal.GDAL_GCP_Info_get(*args)
1957
1959 """GDAL_GCP_Info_set(GCP gcp, char const * pszInfo)"""
1960 return _gdal.GDAL_GCP_Info_set(*args)
1961
1963 """GDAL_GCP_Id_get(GCP gcp) -> char const *"""
1964 return _gdal.GDAL_GCP_Id_get(*args)
1965
1967 """GDAL_GCP_Id_set(GCP gcp, char const * pszId)"""
1968 return _gdal.GDAL_GCP_Id_set(*args)
1969
1974 """Proxy of C++ CPLVirtualMemShadow class."""
1975
1976 __swig_setmethods__ = {}
1977 __setattr__ = lambda self, name, value: _swig_setattr(self, VirtualMem, name, value)
1978 __swig_getmethods__ = {}
1979 __getattr__ = lambda self, name: _swig_getattr(self, VirtualMem, name)
1980
1982 raise AttributeError("No constructor defined")
1983 __repr__ = _swig_repr
1984 __swig_destroy__ = _gdal.delete_VirtualMem
1985 __del__ = lambda self: None
1986
1988 """GetAddr(VirtualMem self)"""
1989 return _gdal.VirtualMem_GetAddr(self, *args)
1990
1991
1992 - def Pin(self, *args):
1993 """Pin(VirtualMem self, size_t start_offset=0, size_t nsize=0, int bWriteOp=0)"""
1994 return _gdal.VirtualMem_Pin(self, *args)
1995
1996 VirtualMem_swigregister = _gdal.VirtualMem_swigregister
1997 VirtualMem_swigregister(VirtualMem)
1998
2000 """Proxy of C++ GDALAsyncReaderShadow class."""
2001
2002 __swig_setmethods__ = {}
2003 __setattr__ = lambda self, name, value: _swig_setattr(self, AsyncReader, name, value)
2004 __swig_getmethods__ = {}
2005 __getattr__ = lambda self, name: _swig_getattr(self, AsyncReader, name)
2006
2008 raise AttributeError("No constructor defined")
2009 __repr__ = _swig_repr
2010 __swig_destroy__ = _gdal.delete_AsyncReader
2011 __del__ = lambda self: None
2012
2014 """GetNextUpdatedRegion(AsyncReader self, double timeout) -> GDALAsyncStatusType"""
2015 return _gdal.AsyncReader_GetNextUpdatedRegion(self, *args)
2016
2017
2019 """GetBuffer(AsyncReader self)"""
2020 return _gdal.AsyncReader_GetBuffer(self, *args)
2021
2022
2024 """LockBuffer(AsyncReader self, double timeout) -> int"""
2025 return _gdal.AsyncReader_LockBuffer(self, *args)
2026
2027
2029 """UnlockBuffer(AsyncReader self)"""
2030 return _gdal.AsyncReader_UnlockBuffer(self, *args)
2031
2032 AsyncReader_swigregister = _gdal.AsyncReader_swigregister
2033 AsyncReader_swigregister(AsyncReader)
2034
2036 """Proxy of C++ GDALDatasetShadow class."""
2037
2038 __swig_setmethods__ = {}
2039 for _s in [MajorObject]:
2040 __swig_setmethods__.update(getattr(_s, '__swig_setmethods__', {}))
2041 __setattr__ = lambda self, name, value: _swig_setattr(self, Dataset, name, value)
2042 __swig_getmethods__ = {}
2043 for _s in [MajorObject]:
2044 __swig_getmethods__.update(getattr(_s, '__swig_getmethods__', {}))
2045 __getattr__ = lambda self, name: _swig_getattr(self, Dataset, name)
2046
2048 raise AttributeError("No constructor defined")
2049 __repr__ = _swig_repr
2050 __swig_getmethods__["RasterXSize"] = _gdal.Dataset_RasterXSize_get
2051 if _newclass:
2052 RasterXSize = _swig_property(_gdal.Dataset_RasterXSize_get)
2053 __swig_getmethods__["RasterYSize"] = _gdal.Dataset_RasterYSize_get
2054 if _newclass:
2055 RasterYSize = _swig_property(_gdal.Dataset_RasterYSize_get)
2056 __swig_getmethods__["RasterCount"] = _gdal.Dataset_RasterCount_get
2057 if _newclass:
2058 RasterCount = _swig_property(_gdal.Dataset_RasterCount_get)
2059 __swig_destroy__ = _gdal.delete_Dataset
2060 __del__ = lambda self: None
2061
2063 """GetDriver(Dataset self) -> Driver"""
2064 return _gdal.Dataset_GetDriver(self, *args)
2065
2066
2068 """GetRasterBand(Dataset self, int nBand) -> Band"""
2069 return _gdal.Dataset_GetRasterBand(self, *args)
2070
2071
2073 """GetProjection(Dataset self) -> char const *"""
2074 return _gdal.Dataset_GetProjection(self, *args)
2075
2076
2078 """GetProjectionRef(Dataset self) -> char const *"""
2079 return _gdal.Dataset_GetProjectionRef(self, *args)
2080
2081
2083 """GetSpatialRef(Dataset self) -> SpatialReference"""
2084 return _gdal.Dataset_GetSpatialRef(self, *args)
2085
2086
2088 """SetProjection(Dataset self, char const * prj) -> CPLErr"""
2089 return _gdal.Dataset_SetProjection(self, *args)
2090
2091
2093 """SetSpatialRef(Dataset self, SpatialReference srs)"""
2094 return _gdal.Dataset_SetSpatialRef(self, *args)
2095
2096
2100
2101
2105
2106
2108 """BuildOverviews(Dataset self, char const * resampling, int overviewlist=0, GDALProgressFunc callback=0, void * callback_data=None) -> int"""
2109 return _gdal.Dataset_BuildOverviews(self, *args, **kwargs)
2110
2111
2113 """GetGCPCount(Dataset self) -> int"""
2114 return _gdal.Dataset_GetGCPCount(self, *args)
2115
2116
2118 """GetGCPProjection(Dataset self) -> char const *"""
2119 return _gdal.Dataset_GetGCPProjection(self, *args)
2120
2121
2123 """GetGCPSpatialRef(Dataset self) -> SpatialReference"""
2124 return _gdal.Dataset_GetGCPSpatialRef(self, *args)
2125
2126
2128 """GetGCPs(Dataset self)"""
2129 return _gdal.Dataset_GetGCPs(self, *args)
2130
2131
2133 """_SetGCPs(Dataset self, int nGCPs, char const * pszGCPProjection) -> CPLErr"""
2134 return _gdal.Dataset__SetGCPs(self, *args)
2135
2136
2138 """_SetGCPs2(Dataset self, int nGCPs, SpatialReference hSRS) -> CPLErr"""
2139 return _gdal.Dataset__SetGCPs2(self, *args)
2140
2141
2143 """FlushCache(Dataset self)"""
2144 return _gdal.Dataset_FlushCache(self, *args)
2145
2146
2147 - def AddBand(self, *args, **kwargs):
2148 """AddBand(Dataset self, GDALDataType datatype, char ** options=None) -> CPLErr"""
2149 return _gdal.Dataset_AddBand(self, *args, **kwargs)
2150
2151
2153 """CreateMaskBand(Dataset self, int nFlags) -> CPLErr"""
2154 return _gdal.Dataset_CreateMaskBand(self, *args)
2155
2156
2158 """GetFileList(Dataset self) -> char **"""
2159 return _gdal.Dataset_GetFileList(self, *args)
2160
2161
2163 """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"""
2164 return _gdal.Dataset_WriteRaster(self, *args, **kwargs)
2165
2166
2168 """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
2171
2173 """BeginAsyncReader(Dataset self, int xOff, int yOff, int xSize, int ySize, int buf_len, int buf_xsize, int buf_ysize, GDALDataType bufType, int band_list=0, int nPixelSpace=0, int nLineSpace=0, int nBandSpace=0, char ** options=None) -> AsyncReader"""
2174 return _gdal.Dataset_BeginAsyncReader(self, *args, **kwargs)
2175
2176
2178 """EndAsyncReader(Dataset self, AsyncReader ario)"""
2179 return _gdal.Dataset_EndAsyncReader(self, *args)
2180
2181
2183 """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"""
2184 return _gdal.Dataset_GetVirtualMem(self, *args, **kwargs)
2185
2186
2188 """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"""
2189 return _gdal.Dataset_GetTiledVirtualMem(self, *args, **kwargs)
2190
2191
2193 """CreateLayer(Dataset self, char const * name, SpatialReference srs=None, OGRwkbGeometryType geom_type, char ** options=None) -> Layer"""
2194 return _gdal.Dataset_CreateLayer(self, *args, **kwargs)
2195
2196
2198 """CopyLayer(Dataset self, Layer src_layer, char const * new_name, char ** options=None) -> Layer"""
2199 return _gdal.Dataset_CopyLayer(self, *args, **kwargs)
2200
2201
2203 """DeleteLayer(Dataset self, int index) -> OGRErr"""
2204 return _gdal.Dataset_DeleteLayer(self, *args)
2205
2206
2208 """GetLayerCount(Dataset self) -> int"""
2209 return _gdal.Dataset_GetLayerCount(self, *args)
2210
2211
2213 """GetLayerByIndex(Dataset self, int index=0) -> Layer"""
2214 return _gdal.Dataset_GetLayerByIndex(self, *args)
2215
2216
2218 """GetLayerByName(Dataset self, char const * layer_name) -> Layer"""
2219 return _gdal.Dataset_GetLayerByName(self, *args)
2220
2221
2223 """ResetReading(Dataset self)"""
2224 return _gdal.Dataset_ResetReading(self, *args)
2225
2226
2228 """GetNextFeature(Dataset self, bool include_layer=True, bool include_pct=False, GDALProgressFunc callback=0, void * callback_data=None) -> Feature"""
2229 return _gdal.Dataset_GetNextFeature(self, *args, **kwargs)
2230
2231
2233 """TestCapability(Dataset self, char const * cap) -> bool"""
2234 return _gdal.Dataset_TestCapability(self, *args)
2235
2236
2238 """ExecuteSQL(Dataset self, char const * statement, Geometry spatialFilter=None, char const * dialect) -> Layer"""
2239 return _gdal.Dataset_ExecuteSQL(self, *args, **kwargs)
2240
2241
2243 """ReleaseResultSet(Dataset self, Layer layer)"""
2244 return _gdal.Dataset_ReleaseResultSet(self, *args)
2245
2246
2248 """GetStyleTable(Dataset self) -> StyleTable"""
2249 return _gdal.Dataset_GetStyleTable(self, *args)
2250
2251
2253 """SetStyleTable(Dataset self, StyleTable table)"""
2254 return _gdal.Dataset_SetStyleTable(self, *args)
2255
2256
2258 """StartTransaction(Dataset self, int force=False) -> OGRErr"""
2259 return _gdal.Dataset_StartTransaction(self, *args, **kwargs)
2260
2261
2263 """CommitTransaction(Dataset self) -> OGRErr"""
2264 return _gdal.Dataset_CommitTransaction(self, *args)
2265
2266
2268 """RollbackTransaction(Dataset self) -> OGRErr"""
2269 return _gdal.Dataset_RollbackTransaction(self, *args)
2270
2271
2273 """ReadRaster1(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, GIntBig * buf_pixel_space=None, GIntBig * buf_line_space=None, GIntBig * buf_band_space=None, GDALRIOResampleAlg resample_alg, GDALProgressFunc callback=0, void * callback_data=None) -> CPLErr"""
2274 return _gdal.Dataset_ReadRaster1(self, *args, **kwargs)
2275
2276
2277
2278 - def ReadAsArray(self, xoff=0, yoff=0, xsize=None, ysize=None, buf_obj=None,
2279 buf_xsize=None, buf_ysize=None, buf_type=None,
2280 resample_alg=gdalconst.GRIORA_NearestNeighbour,
2281 callback=None,
2282 callback_data=None,
2283 interleave='band'):
2284 """ Reading a chunk of a GDAL band into a numpy array. The optional (buf_xsize,buf_ysize,buf_type)
2285 parameters should generally not be specified if buf_obj is specified. The array is returned"""
2286
2287 from osgeo import gdalnumeric
2288 return gdalnumeric.DatasetReadAsArray(self, xoff, yoff, xsize, ysize, buf_obj,
2289 buf_xsize, buf_ysize, buf_type,
2290 resample_alg=resample_alg,
2291 callback=callback,
2292 callback_data=callback_data,
2293 interleave=interleave )
2294
2295 - def WriteRaster(self, xoff, yoff, xsize, ysize,
2296 buf_string,
2297 buf_xsize=None, buf_ysize=None, buf_type=None,
2298 band_list=None,
2299 buf_pixel_space=None, buf_line_space=None, buf_band_space=None ):
2300
2301 if buf_xsize is None:
2302 buf_xsize = xsize
2303 if buf_ysize is None:
2304 buf_ysize = ysize
2305 if band_list is None:
2306 band_list = range(1,self.RasterCount+1)
2307 if buf_type is None:
2308 buf_type = self.GetRasterBand(1).DataType
2309
2310 return _gdal.Dataset_WriteRaster(self,
2311 xoff, yoff, xsize, ysize,
2312 buf_string, buf_xsize, buf_ysize, buf_type, band_list,
2313 buf_pixel_space, buf_line_space, buf_band_space )
2314
2315 - def ReadRaster(self, xoff=0, yoff=0, xsize=None, ysize=None,
2316 buf_xsize=None, buf_ysize=None, buf_type=None,
2317 band_list=None,
2318 buf_pixel_space=None, buf_line_space=None, buf_band_space=None,
2319 resample_alg=gdalconst.GRIORA_NearestNeighbour,
2320 callback=None,
2321 callback_data=None):
2322
2323 if xsize is None:
2324 xsize = self.RasterXSize
2325 if ysize is None:
2326 ysize = self.RasterYSize
2327 if band_list is None:
2328 band_list = range(1,self.RasterCount+1)
2329 if buf_xsize is None:
2330 buf_xsize = xsize
2331 if buf_ysize is None:
2332 buf_ysize = ysize
2333
2334 if buf_type is None:
2335 buf_type = self.GetRasterBand(1).DataType;
2336
2337 return _gdal.Dataset_ReadRaster1(self, xoff, yoff, xsize, ysize,
2338 buf_xsize, buf_ysize, buf_type,
2339 band_list, buf_pixel_space, buf_line_space, buf_band_space,
2340 resample_alg, callback, callback_data )
2341
2342 - def GetVirtualMemArray(self, eAccess=gdalconst.GF_Read, xoff=0, yoff=0,
2343 xsize=None, ysize=None, bufxsize=None, bufysize=None,
2344 datatype=None, band_list=None, band_sequential = True,
2345 cache_size = 10 * 1024 * 1024, page_size_hint = 0,
2346 options=None):
2347 """Return a NumPy array for the dataset, seen as a virtual memory mapping.
2348 If there are several bands and band_sequential = True, an element is
2349 accessed with array[band][y][x].
2350 If there are several bands and band_sequential = False, an element is
2351 accessed with array[y][x][band].
2352 If there is only one band, an element is accessed with array[y][x].
2353 Any reference to the array must be dropped before the last reference to the
2354 related dataset is also dropped.
2355 """
2356 from osgeo import gdalnumeric
2357 if xsize is None:
2358 xsize = self.RasterXSize
2359 if ysize is None:
2360 ysize = self.RasterYSize
2361 if bufxsize is None:
2362 bufxsize = self.RasterXSize
2363 if bufysize is None:
2364 bufysize = self.RasterYSize
2365 if datatype is None:
2366 datatype = self.GetRasterBand(1).DataType
2367 if band_list is None:
2368 band_list = range(1,self.RasterCount+1)
2369 if options is None:
2370 virtualmem = self.GetVirtualMem(eAccess, xoff, yoff, xsize, ysize, bufxsize, bufysize, datatype, band_list, band_sequential, cache_size, page_size_hint)
2371 else:
2372 virtualmem = self.GetVirtualMem(eAccess, xoff, yoff, xsize, ysize, bufxsize, bufysize, datatype, band_list, band_sequential, cache_size, page_size_hint, options)
2373 return gdalnumeric.VirtualMemGetArray( virtualmem )
2374
2375 - def GetTiledVirtualMemArray(self, eAccess=gdalconst.GF_Read, xoff=0, yoff=0,
2376 xsize=None, ysize=None, tilexsize=256, tileysize=256,
2377 datatype=None, band_list=None, tile_organization=gdalconst.GTO_BSQ,
2378 cache_size = 10 * 1024 * 1024, options=None):
2379 """Return a NumPy array for the dataset, seen as a virtual memory mapping with
2380 a tile organization.
2381 If there are several bands and tile_organization = gdal.GTO_TIP, an element is
2382 accessed with array[tiley][tilex][y][x][band].
2383 If there are several bands and tile_organization = gdal.GTO_BIT, an element is
2384 accessed with array[tiley][tilex][band][y][x].
2385 If there are several bands and tile_organization = gdal.GTO_BSQ, an element is
2386 accessed with array[band][tiley][tilex][y][x].
2387 If there is only one band, an element is accessed with array[tiley][tilex][y][x].
2388 Any reference to the array must be dropped before the last reference to the
2389 related dataset is also dropped.
2390 """
2391 from osgeo import gdalnumeric
2392 if xsize is None:
2393 xsize = self.RasterXSize
2394 if ysize is None:
2395 ysize = self.RasterYSize
2396 if datatype is None:
2397 datatype = self.GetRasterBand(1).DataType
2398 if band_list is None:
2399 band_list = range(1,self.RasterCount+1)
2400 if options is None:
2401 virtualmem = self.GetTiledVirtualMem(eAccess,xoff,yoff,xsize,ysize,tilexsize,tileysize,datatype,band_list,tile_organization,cache_size)
2402 else:
2403 virtualmem = self.GetTiledVirtualMem(eAccess,xoff,yoff,xsize,ysize,tilexsize,tileysize,datatype,band_list,tile_organization,cache_size, options)
2404 return gdalnumeric.VirtualMemGetArray( virtualmem )
2405
2407 sd_list = []
2408
2409 sd = self.GetMetadata('SUBDATASETS')
2410 if sd is None:
2411 return sd_list
2412
2413 i = 1
2414 while 'SUBDATASET_'+str(i)+'_NAME' in sd:
2415 sd_list.append((sd['SUBDATASET_'+str(i)+'_NAME'],
2416 sd['SUBDATASET_'+str(i)+'_DESC']))
2417 i = i + 1
2418 return sd_list
2419
2420 - def BeginAsyncReader(self, xoff, yoff, xsize, ysize, buf_obj=None, buf_xsize=None, buf_ysize=None, buf_type=None, band_list=None, options=None):
2421 if band_list is None:
2422 band_list = range(1, self.RasterCount + 1)
2423 if buf_xsize is None:
2424 buf_xsize = 0;
2425 if buf_ysize is None:
2426 buf_ysize = 0;
2427 if buf_type is None:
2428 buf_type = gdalconst.GDT_Byte
2429
2430 if buf_xsize <= 0:
2431 buf_xsize = xsize
2432 if buf_ysize <= 0:
2433 buf_ysize = ysize
2434 options = [] if options is None else options
2435
2436 if buf_obj is None:
2437 from sys import version_info
2438 nRequiredSize = int(buf_xsize * buf_ysize * len(band_list) * (_gdal.GetDataTypeSize(buf_type) / 8))
2439 if version_info >= (3, 0, 0):
2440 buf_obj_ar = [None]
2441 exec("buf_obj_ar[0] = b' ' * nRequiredSize")
2442 buf_obj = buf_obj_ar[0]
2443 else:
2444 buf_obj = ' ' * nRequiredSize
2445 return _gdal.Dataset_BeginAsyncReader(self, xoff, yoff, xsize, ysize, buf_obj, buf_xsize, buf_ysize, buf_type, band_list, 0, 0, 0, options)
2446
2448 """Return the layer given an index or a name"""
2449 if isinstance(iLayer, str):
2450 return self.GetLayerByName(str(iLayer))
2451 elif isinstance(iLayer, int):
2452 return self.GetLayerByIndex(iLayer)
2453 else:
2454 raise TypeError("Input %s is not of String or Int type" % type(iLayer))
2455
2457 """Deletes the layer given an index or layer name"""
2458 if isinstance(value, str):
2459 for i in range(self.GetLayerCount()):
2460 name = self.GetLayer(i).GetName()
2461 if name == value:
2462 return _gdal.Dataset_DeleteLayer(self, i)
2463 raise ValueError("Layer %s not found to delete" % value)
2464 elif isinstance(value, int):
2465 return _gdal.Dataset_DeleteLayer(self, value)
2466 else:
2467 raise TypeError("Input %s is not of String or Int type" % type(value))
2468
2469 - def SetGCPs(self, gcps, wkt_or_spatial_ref):
2470 if isinstance(wkt_or_spatial_ref, str):
2471 return self._SetGCPs(gcps, wkt_or_spatial_ref)
2472 else:
2473 return self._SetGCPs2(gcps, wkt_or_spatial_ref)
2474
2475 Dataset_swigregister = _gdal.Dataset_swigregister
2476 Dataset_swigregister(Dataset)
2477
2478 -class Band(MajorObject):
2479 """Proxy of C++ GDALRasterBandShadow class."""
2480
2481 __swig_setmethods__ = {}
2482 for _s in [MajorObject]:
2483 __swig_setmethods__.update(getattr(_s, '__swig_setmethods__', {}))
2484 __setattr__ = lambda self, name, value: _swig_setattr(self, Band, name, value)
2485 __swig_getmethods__ = {}
2486 for _s in [MajorObject]:
2487 __swig_getmethods__.update(getattr(_s, '__swig_getmethods__', {}))
2488 __getattr__ = lambda self, name: _swig_getattr(self, Band, name)
2489
2491 raise AttributeError("No constructor defined")
2492 __repr__ = _swig_repr
2493 __swig_getmethods__["XSize"] = _gdal.Band_XSize_get
2494 if _newclass:
2495 XSize = _swig_property(_gdal.Band_XSize_get)
2496 __swig_getmethods__["YSize"] = _gdal.Band_YSize_get
2497 if _newclass:
2498 YSize = _swig_property(_gdal.Band_YSize_get)
2499 __swig_getmethods__["DataType"] = _gdal.Band_DataType_get
2500 if _newclass:
2501 DataType = _swig_property(_gdal.Band_DataType_get)
2502
2504 """GetDataset(Band self) -> Dataset"""
2505 return _gdal.Band_GetDataset(self, *args)
2506
2507
2509 """GetBand(Band self) -> int"""
2510 return _gdal.Band_GetBand(self, *args)
2511
2512
2514 """GetBlockSize(Band self)"""
2515 return _gdal.Band_GetBlockSize(self, *args)
2516
2517
2519 """GetActualBlockSize(Band self, int nXBlockOff, int nYBlockOff)"""
2520 return _gdal.Band_GetActualBlockSize(self, *args)
2521
2522
2524 """GetColorInterpretation(Band self) -> GDALColorInterp"""
2525 return _gdal.Band_GetColorInterpretation(self, *args)
2526
2527
2529 """GetRasterColorInterpretation(Band self) -> GDALColorInterp"""
2530 return _gdal.Band_GetRasterColorInterpretation(self, *args)
2531
2532
2534 """SetColorInterpretation(Band self, GDALColorInterp val) -> CPLErr"""
2535 return _gdal.Band_SetColorInterpretation(self, *args)
2536
2537
2539 """SetRasterColorInterpretation(Band self, GDALColorInterp val) -> CPLErr"""
2540 return _gdal.Band_SetRasterColorInterpretation(self, *args)
2541
2542
2544 """GetNoDataValue(Band self)"""
2545 return _gdal.Band_GetNoDataValue(self, *args)
2546
2547
2549 """SetNoDataValue(Band self, double d) -> CPLErr"""
2550 return _gdal.Band_SetNoDataValue(self, *args)
2551
2552
2554 """DeleteNoDataValue(Band self) -> CPLErr"""
2555 return _gdal.Band_DeleteNoDataValue(self, *args)
2556
2557
2559 """GetUnitType(Band self) -> char const *"""
2560 return _gdal.Band_GetUnitType(self, *args)
2561
2562
2564 """SetUnitType(Band self, char const * val) -> CPLErr"""
2565 return _gdal.Band_SetUnitType(self, *args)
2566
2567
2569 """GetRasterCategoryNames(Band self) -> char **"""
2570 return _gdal.Band_GetRasterCategoryNames(self, *args)
2571
2572
2574 """SetRasterCategoryNames(Band self, char ** names) -> CPLErr"""
2575 return _gdal.Band_SetRasterCategoryNames(self, *args)
2576
2577
2579 """GetMinimum(Band self)"""
2580 return _gdal.Band_GetMinimum(self, *args)
2581
2582
2584 """GetMaximum(Band self)"""
2585 return _gdal.Band_GetMaximum(self, *args)
2586
2587
2589 """GetOffset(Band self)"""
2590 return _gdal.Band_GetOffset(self, *args)
2591
2592
2594 """GetScale(Band self)"""
2595 return _gdal.Band_GetScale(self, *args)
2596
2597
2599 """SetOffset(Band self, double val) -> CPLErr"""
2600 return _gdal.Band_SetOffset(self, *args)
2601
2602
2604 """SetScale(Band self, double val) -> CPLErr"""
2605 return _gdal.Band_SetScale(self, *args)
2606
2607
2609 """GetStatistics(Band self, int approx_ok, int force) -> CPLErr"""
2610 return _gdal.Band_GetStatistics(self, *args)
2611
2612
2614 """ComputeStatistics(Band self, bool approx_ok, GDALProgressFunc callback=0, void * callback_data=None) -> CPLErr"""
2615 return _gdal.Band_ComputeStatistics(self, *args)
2616
2617
2619 """SetStatistics(Band self, double min, double max, double mean, double stddev) -> CPLErr"""
2620 return _gdal.Band_SetStatistics(self, *args)
2621
2622
2624 """GetOverviewCount(Band self) -> int"""
2625 return _gdal.Band_GetOverviewCount(self, *args)
2626
2627
2629 """GetOverview(Band self, int i) -> Band"""
2630 return _gdal.Band_GetOverview(self, *args)
2631
2632
2634 """Checksum(Band self, int xoff=0, int yoff=0, int * xsize=None, int * ysize=None) -> int"""
2635 return _gdal.Band_Checksum(self, *args, **kwargs)
2636
2637
2639 """ComputeRasterMinMax(Band self, int approx_ok=0)"""
2640 return _gdal.Band_ComputeRasterMinMax(self, *args)
2641
2642
2644 """ComputeBandStats(Band self, int samplestep=1)"""
2645 return _gdal.Band_ComputeBandStats(self, *args)
2646
2647
2648 - def Fill(self, *args):
2649 """Fill(Band self, double real_fill, double imag_fill=0.0) -> CPLErr"""
2650 return _gdal.Band_Fill(self, *args)
2651
2652
2654 """WriteRaster(Band self, int xoff, int yoff, int xsize, int ysize, GIntBig buf_len, int * buf_xsize=None, int * buf_ysize=None, int * buf_type=None, GIntBig * buf_pixel_space=None, GIntBig * buf_line_space=None) -> CPLErr"""
2655 return _gdal.Band_WriteRaster(self, *args, **kwargs)
2656
2657
2659 """FlushCache(Band self)"""
2660 return _gdal.Band_FlushCache(self, *args)
2661
2662
2664 """GetRasterColorTable(Band self) -> ColorTable"""
2665 return _gdal.Band_GetRasterColorTable(self, *args)
2666
2667
2669 """GetColorTable(Band self) -> ColorTable"""
2670 return _gdal.Band_GetColorTable(self, *args)
2671
2672
2674 """SetRasterColorTable(Band self, ColorTable arg) -> int"""
2675 return _gdal.Band_SetRasterColorTable(self, *args)
2676
2677
2679 """SetColorTable(Band self, ColorTable arg) -> int"""
2680 return _gdal.Band_SetColorTable(self, *args)
2681
2682
2684 """GetDefaultRAT(Band self) -> RasterAttributeTable"""
2685 return _gdal.Band_GetDefaultRAT(self, *args)
2686
2687
2689 """SetDefaultRAT(Band self, RasterAttributeTable table) -> int"""
2690 return _gdal.Band_SetDefaultRAT(self, *args)
2691
2692
2694 """GetMaskBand(Band self) -> Band"""
2695 return _gdal.Band_GetMaskBand(self, *args)
2696
2697
2699 """GetMaskFlags(Band self) -> int"""
2700 return _gdal.Band_GetMaskFlags(self, *args)
2701
2702
2704 """CreateMaskBand(Band self, int nFlags) -> CPLErr"""
2705 return _gdal.Band_CreateMaskBand(self, *args)
2706
2707
2709 """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"""
2710 return _gdal.Band_GetHistogram(self, *args, **kwargs)
2711
2712
2714 """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"""
2715 return _gdal.Band_GetDefaultHistogram(self, *args, **kwargs)
2716
2717
2719 """SetDefaultHistogram(Band self, double min, double max, int buckets_in) -> CPLErr"""
2720 return _gdal.Band_SetDefaultHistogram(self, *args)
2721
2722
2724 """HasArbitraryOverviews(Band self) -> bool"""
2725 return _gdal.Band_HasArbitraryOverviews(self, *args)
2726
2727
2729 """GetCategoryNames(Band self) -> char **"""
2730 return _gdal.Band_GetCategoryNames(self, *args)
2731
2732
2734 """SetCategoryNames(Band self, char ** papszCategoryNames) -> CPLErr"""
2735 return _gdal.Band_SetCategoryNames(self, *args)
2736
2737
2739 """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"""
2740 return _gdal.Band_GetVirtualMem(self, *args, **kwargs)
2741
2742
2744 """GetVirtualMemAuto(Band self, GDALRWFlag eRWFlag, char ** options=None) -> VirtualMem"""
2745 return _gdal.Band_GetVirtualMemAuto(self, *args, **kwargs)
2746
2747
2749 """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"""
2750 return _gdal.Band_GetTiledVirtualMem(self, *args, **kwargs)
2751
2752
2754 """GetDataCoverageStatus(Band self, int nXOff, int nYOff, int nXSize, int nYSize, int nMaskFlagStop=0) -> int"""
2755 return _gdal.Band_GetDataCoverageStatus(self, *args)
2756
2757
2759 """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"""
2760 return _gdal.Band_AdviseRead(self, *args)
2761
2762
2764 """ReadRaster1(Band self, double xoff, double yoff, double xsize, double ysize, int * buf_xsize=None, int * buf_ysize=None, int * buf_type=None, GIntBig * buf_pixel_space=None, GIntBig * buf_line_space=None, GDALRIOResampleAlg resample_alg, GDALProgressFunc callback=0, void * callback_data=None) -> CPLErr"""
2765 return _gdal.Band_ReadRaster1(self, *args, **kwargs)
2766
2767
2769 """ReadBlock(Band self, int xoff, int yoff) -> CPLErr"""
2770 return _gdal.Band_ReadBlock(self, *args, **kwargs)
2771
2772
2773
2775 """ComputeStatistics(Band self, bool approx_ok, GDALProgressFunc callback=0, void * callback_data=None) -> CPLErr"""
2776
2777
2778
2779 approx_ok = args[0]
2780 if approx_ok == 0:
2781 approx_ok = False
2782 elif approx_ok == 1:
2783 approx_ok = True
2784 new_args = [approx_ok]
2785 for arg in args[1:]:
2786 new_args.append( arg )
2787
2788 return _gdal.Band_ComputeStatistics(self, *new_args)
2789
2790
2791 - def ReadRaster(self, xoff=0, yoff=0, xsize=None, ysize=None,
2792 buf_xsize=None, buf_ysize=None, buf_type=None,
2793 buf_pixel_space=None, buf_line_space=None,
2794 resample_alg=gdalconst.GRIORA_NearestNeighbour,
2795 callback=None,
2796 callback_data=None):
2797
2798 if xsize is None:
2799 xsize = self.XSize
2800 if ysize is None:
2801 ysize = self.YSize
2802
2803 return _gdal.Band_ReadRaster1(self, xoff, yoff, xsize, ysize,
2804 buf_xsize, buf_ysize, buf_type,
2805 buf_pixel_space, buf_line_space,
2806 resample_alg, callback, callback_data)
2807
2808 - def ReadAsArray(self, xoff=0, yoff=0, win_xsize=None, win_ysize=None,
2809 buf_xsize=None, buf_ysize=None, buf_type=None, buf_obj=None,
2810 resample_alg=gdalconst.GRIORA_NearestNeighbour,
2811 callback=None,
2812 callback_data=None):
2813 """ Reading a chunk of a GDAL band into a numpy array. The optional (buf_xsize,buf_ysize,buf_type)
2814 parameters should generally not be specified if buf_obj is specified. The array is returned"""
2815
2816 from osgeo import gdalnumeric
2817
2818 return gdalnumeric.BandReadAsArray(self, xoff, yoff,
2819 win_xsize, win_ysize,
2820 buf_xsize, buf_ysize, buf_type, buf_obj,
2821 resample_alg=resample_alg,
2822 callback=callback,
2823 callback_data=callback_data)
2824
2829 from osgeo import gdalnumeric
2830
2831 return gdalnumeric.BandWriteArray(self, array, xoff, yoff,
2832 resample_alg=resample_alg,
2833 callback=callback,
2834 callback_data=callback_data)
2835
2836 - def GetVirtualMemArray(self, eAccess=gdalconst.GF_Read, xoff=0, yoff=0,
2837 xsize=None, ysize=None, bufxsize=None, bufysize=None,
2838 datatype=None,
2839 cache_size = 10 * 1024 * 1024, page_size_hint = 0,
2840 options=None):
2841 """Return a NumPy array for the band, seen as a virtual memory mapping.
2842 An element is accessed with array[y][x].
2843 Any reference to the array must be dropped before the last reference to the
2844 related dataset is also dropped.
2845 """
2846 from osgeo import gdalnumeric
2847 if xsize is None:
2848 xsize = self.XSize
2849 if ysize is None:
2850 ysize = self.YSize
2851 if bufxsize is None:
2852 bufxsize = self.XSize
2853 if bufysize is None:
2854 bufysize = self.YSize
2855 if datatype is None:
2856 datatype = self.DataType
2857 if options is None:
2858 virtualmem = self.GetVirtualMem(eAccess, xoff, yoff, xsize, ysize, bufxsize, bufysize, datatype, cache_size, page_size_hint)
2859 else:
2860 virtualmem = self.GetVirtualMem(eAccess, xoff, yoff, xsize, ysize, bufxsize, bufysize, datatype, cache_size, page_size_hint, options)
2861 return gdalnumeric.VirtualMemGetArray(virtualmem)
2862
2864 """Return a NumPy array for the band, seen as a virtual memory mapping.
2865 An element is accessed with array[y][x].
2866 Any reference to the array must be dropped before the last reference to the
2867 related dataset is also dropped.
2868 """
2869 from osgeo import gdalnumeric
2870 if options is None:
2871 virtualmem = self.GetVirtualMemAuto(eAccess)
2872 else:
2873 virtualmem = self.GetVirtualMemAuto(eAccess,options)
2874 return gdalnumeric.VirtualMemGetArray( virtualmem )
2875
2876 - def GetTiledVirtualMemArray(self, eAccess=gdalconst.GF_Read, xoff=0, yoff=0,
2877 xsize=None, ysize=None, tilexsize=256, tileysize=256,
2878 datatype=None,
2879 cache_size = 10 * 1024 * 1024, options=None):
2880 """Return a NumPy array for the band, seen as a virtual memory mapping with
2881 a tile organization.
2882 An element is accessed with array[tiley][tilex][y][x].
2883 Any reference to the array must be dropped before the last reference to the
2884 related dataset is also dropped.
2885 """
2886 from osgeo import gdalnumeric
2887 if xsize is None:
2888 xsize = self.XSize
2889 if ysize is None:
2890 ysize = self.YSize
2891 if datatype is None:
2892 datatype = self.DataType
2893 if options is None:
2894 virtualmem = self.GetTiledVirtualMem(eAccess,xoff,yoff,xsize,ysize,tilexsize,tileysize,datatype,cache_size)
2895 else:
2896 virtualmem = self.GetTiledVirtualMem(eAccess,xoff,yoff,xsize,ysize,tilexsize,tileysize,datatype,cache_size,options)
2897 return gdalnumeric.VirtualMemGetArray( virtualmem )
2898
2899 Band_swigregister = _gdal.Band_swigregister
2900 Band_swigregister(Band)
2901
2903 """Proxy of C++ GDALColorTableShadow class."""
2904
2905 __swig_setmethods__ = {}
2906 __setattr__ = lambda self, name, value: _swig_setattr(self, ColorTable, name, value)
2907 __swig_getmethods__ = {}
2908 __getattr__ = lambda self, name: _swig_getattr(self, ColorTable, name)
2909 __repr__ = _swig_repr
2910
2912 """__init__(GDALColorTableShadow self, GDALPaletteInterp palette) -> ColorTable"""
2913 this = _gdal.new_ColorTable(*args, **kwargs)
2914 try:
2915 self.this.append(this)
2916 except Exception:
2917 self.this = this
2918 __swig_destroy__ = _gdal.delete_ColorTable
2919 __del__ = lambda self: None
2920
2921 - def Clone(self, *args):
2922 """Clone(ColorTable self) -> ColorTable"""
2923 return _gdal.ColorTable_Clone(self, *args)
2924
2925
2927 """GetPaletteInterpretation(ColorTable self) -> GDALPaletteInterp"""
2928 return _gdal.ColorTable_GetPaletteInterpretation(self, *args)
2929
2930
2932 """GetCount(ColorTable self) -> int"""
2933 return _gdal.ColorTable_GetCount(self, *args)
2934
2935
2936 - def GetColorEntry(self, *args):
2937 """GetColorEntry(ColorTable self, int entry) -> ColorEntry"""
2938 return _gdal.ColorTable_GetColorEntry(self, *args)
2939
2940
2941 - def GetColorEntryAsRGB(self, *args):
2942 """GetColorEntryAsRGB(ColorTable self, int entry, ColorEntry centry) -> int"""
2943 return _gdal.ColorTable_GetColorEntryAsRGB(self, *args)
2944
2945
2946 - def SetColorEntry(self, *args):
2947 """SetColorEntry(ColorTable self, int entry, ColorEntry centry)"""
2948 return _gdal.ColorTable_SetColorEntry(self, *args)
2949
2950
2952 """CreateColorRamp(ColorTable self, int nStartIndex, ColorEntry startcolor, int nEndIndex, ColorEntry endcolor)"""
2953 return _gdal.ColorTable_CreateColorRamp(self, *args)
2954
2955 ColorTable_swigregister = _gdal.ColorTable_swigregister
2956 ColorTable_swigregister(ColorTable)
2957
2959 """Proxy of C++ GDALRasterAttributeTableShadow class."""
2960
2961 __swig_setmethods__ = {}
2962 __setattr__ = lambda self, name, value: _swig_setattr(self, RasterAttributeTable, name, value)
2963 __swig_getmethods__ = {}
2964 __getattr__ = lambda self, name: _swig_getattr(self, RasterAttributeTable, name)
2965 __repr__ = _swig_repr
2966
2968 """__init__(GDALRasterAttributeTableShadow self) -> RasterAttributeTable"""
2969 this = _gdal.new_RasterAttributeTable(*args)
2970 try:
2971 self.this.append(this)
2972 except Exception:
2973 self.this = this
2974 __swig_destroy__ = _gdal.delete_RasterAttributeTable
2975 __del__ = lambda self: None
2976
2977 - def Clone(self, *args):
2978 """Clone(RasterAttributeTable self) -> RasterAttributeTable"""
2979 return _gdal.RasterAttributeTable_Clone(self, *args)
2980
2981
2983 """GetColumnCount(RasterAttributeTable self) -> int"""
2984 return _gdal.RasterAttributeTable_GetColumnCount(self, *args)
2985
2986
2988 """GetNameOfCol(RasterAttributeTable self, int iCol) -> char const *"""
2989 return _gdal.RasterAttributeTable_GetNameOfCol(self, *args)
2990
2991
2993 """GetUsageOfCol(RasterAttributeTable self, int iCol) -> GDALRATFieldUsage"""
2994 return _gdal.RasterAttributeTable_GetUsageOfCol(self, *args)
2995
2996
2998 """GetTypeOfCol(RasterAttributeTable self, int iCol) -> GDALRATFieldType"""
2999 return _gdal.RasterAttributeTable_GetTypeOfCol(self, *args)
3000
3001
3003 """GetColOfUsage(RasterAttributeTable self, GDALRATFieldUsage eUsage) -> int"""
3004 return _gdal.RasterAttributeTable_GetColOfUsage(self, *args)
3005
3006
3008 """GetRowCount(RasterAttributeTable self) -> int"""
3009 return _gdal.RasterAttributeTable_GetRowCount(self, *args)
3010
3011
3013 """GetValueAsString(RasterAttributeTable self, int iRow, int iCol) -> char const *"""
3014 return _gdal.RasterAttributeTable_GetValueAsString(self, *args)
3015
3016
3018 """GetValueAsInt(RasterAttributeTable self, int iRow, int iCol) -> int"""
3019 return _gdal.RasterAttributeTable_GetValueAsInt(self, *args)
3020
3021
3023 """GetValueAsDouble(RasterAttributeTable self, int iRow, int iCol) -> double"""
3024 return _gdal.RasterAttributeTable_GetValueAsDouble(self, *args)
3025
3026
3028 """SetValueAsString(RasterAttributeTable self, int iRow, int iCol, char const * pszValue)"""
3029 return _gdal.RasterAttributeTable_SetValueAsString(self, *args)
3030
3031
3033 """SetValueAsInt(RasterAttributeTable self, int iRow, int iCol, int nValue)"""
3034 return _gdal.RasterAttributeTable_SetValueAsInt(self, *args)
3035
3036
3038 """SetValueAsDouble(RasterAttributeTable self, int iRow, int iCol, double dfValue)"""
3039 return _gdal.RasterAttributeTable_SetValueAsDouble(self, *args)
3040
3041
3043 """SetRowCount(RasterAttributeTable self, int nCount)"""
3044 return _gdal.RasterAttributeTable_SetRowCount(self, *args)
3045
3046
3048 """CreateColumn(RasterAttributeTable self, char const * pszName, GDALRATFieldType eType, GDALRATFieldUsage eUsage) -> int"""
3049 return _gdal.RasterAttributeTable_CreateColumn(self, *args)
3050
3051
3053 """GetLinearBinning(RasterAttributeTable self) -> bool"""
3054 return _gdal.RasterAttributeTable_GetLinearBinning(self, *args)
3055
3056
3058 """SetLinearBinning(RasterAttributeTable self, double dfRow0Min, double dfBinSize) -> int"""
3059 return _gdal.RasterAttributeTable_SetLinearBinning(self, *args)
3060
3061
3063 """GetRowOfValue(RasterAttributeTable self, double dfValue) -> int"""
3064 return _gdal.RasterAttributeTable_GetRowOfValue(self, *args)
3065
3066
3068 """ChangesAreWrittenToFile(RasterAttributeTable self) -> int"""
3069 return _gdal.RasterAttributeTable_ChangesAreWrittenToFile(self, *args)
3070
3071
3073 """DumpReadable(RasterAttributeTable self)"""
3074 return _gdal.RasterAttributeTable_DumpReadable(self, *args)
3075
3076
3078 """SetTableType(RasterAttributeTable self, GDALRATTableType eTableType)"""
3079 return _gdal.RasterAttributeTable_SetTableType(self, *args)
3080
3081
3083 """GetTableType(RasterAttributeTable self) -> GDALRATTableType"""
3084 return _gdal.RasterAttributeTable_GetTableType(self, *args)
3085
3086
3088 from osgeo import gdalnumeric
3089
3090 return gdalnumeric.RATWriteArray(self, array, field, start)
3091
3093 from osgeo import gdalnumeric
3094
3095 return gdalnumeric.RATReadArray(self, field, start, length)
3096
3097 RasterAttributeTable_swigregister = _gdal.RasterAttributeTable_swigregister
3098 RasterAttributeTable_swigregister(RasterAttributeTable)
3099
3100
3102 """TermProgress_nocb(double dfProgress, char const * pszMessage=None, void * pData=None) -> int"""
3103 return _gdal.TermProgress_nocb(*args, **kwargs)
3104
3105 _gdal.TermProgress_swigconstant(_gdal)
3106 TermProgress = _gdal.TermProgress
3107
3111
3113 """DitherRGB2PCT(Band red, Band green, Band blue, Band target, ColorTable colors, GDALProgressFunc callback=0, void * callback_data=None) -> int"""
3114 return _gdal.DitherRGB2PCT(*args, **kwargs)
3115
3117 """ReprojectImage(Dataset src_ds, Dataset dst_ds, char const * src_wkt=None, char const * dst_wkt=None, GDALResampleAlg eResampleAlg, double WarpMemoryLimit=0.0, double maxerror=0.0, GDALProgressFunc callback=0, void * callback_data=None, char ** options=None) -> CPLErr"""
3118 return _gdal.ReprojectImage(*args, **kwargs)
3119
3121 """ComputeProximity(Band srcBand, Band proximityBand, char ** options=None, GDALProgressFunc callback=0, void * callback_data=None) -> int"""
3122 return _gdal.ComputeProximity(*args, **kwargs)
3123
3125 """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"""
3126 return _gdal.RasterizeLayer(*args, **kwargs)
3127
3129 """Polygonize(Band srcBand, Band maskBand, Layer outLayer, int iPixValField, char ** options=None, GDALProgressFunc callback=0, void * callback_data=None) -> int"""
3130 return _gdal.Polygonize(*args, **kwargs)
3131
3133 """FPolygonize(Band srcBand, Band maskBand, Layer outLayer, int iPixValField, char ** options=None, GDALProgressFunc callback=0, void * callback_data=None) -> int"""
3134 return _gdal.FPolygonize(*args, **kwargs)
3135
3137 """FillNodata(Band targetBand, Band maskBand, double maxSearchDist, int smoothingIterations, char ** options=None, GDALProgressFunc callback=0, void * callback_data=None) -> int"""
3138 return _gdal.FillNodata(*args, **kwargs)
3139
3141 """SieveFilter(Band srcBand, Band maskBand, Band dstBand, int threshold, int connectedness=4, char ** options=None, GDALProgressFunc callback=0, void * callback_data=None) -> int"""
3142 return _gdal.SieveFilter(*args, **kwargs)
3143
3145 """RegenerateOverviews(Band srcBand, int overviewBandCount, char const * resampling, GDALProgressFunc callback=0, void * callback_data=None) -> int"""
3146 return _gdal.RegenerateOverviews(*args, **kwargs)
3147
3149 """RegenerateOverview(Band srcBand, Band overviewBand, char const * resampling, GDALProgressFunc callback=0, void * callback_data=None) -> int"""
3150 return _gdal.RegenerateOverview(*args, **kwargs)
3151
3153 """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"""
3154 return _gdal.ContourGenerate(*args, **kwargs)
3155
3157 """ContourGenerateEx(Band srcBand, Layer dstLayer, char ** options=None, GDALProgressFunc callback=0, void * callback_data=None) -> int"""
3158 return _gdal.ContourGenerateEx(*args, **kwargs)
3159
3161 """AutoCreateWarpedVRT(Dataset src_ds, char const * src_wkt=None, char const * dst_wkt=None, GDALResampleAlg eResampleAlg, double maxerror=0.0) -> Dataset"""
3162 return _gdal.AutoCreateWarpedVRT(*args)
3163
3165 """CreatePansharpenedVRT(char const * pszXML, Band panchroBand, int nInputSpectralBands) -> Dataset"""
3166 return _gdal.CreatePansharpenedVRT(*args)
3197
3198 GDALTransformerInfoShadow_swigregister = _gdal.GDALTransformerInfoShadow_swigregister
3199 GDALTransformerInfoShadow_swigregister(GDALTransformerInfoShadow)
3200
3201
3205
3207 """ApplyVerticalShiftGrid(Dataset src_ds, Dataset grid_ds, bool inverse=False, double srcUnitToMeter=1.0, double dstUnitToMeter=1.0, char ** options=None) -> Dataset"""
3208 return _gdal.ApplyVerticalShiftGrid(*args, **kwargs)
3209
3213
3217
3219 """VersionInfo(char const * request) -> char const *"""
3220 return _gdal.VersionInfo(*args)
3221
3223 """AllRegister()"""
3224 return _gdal.AllRegister(*args)
3225
3229
3231 """GetCacheMax() -> GIntBig"""
3232 return _gdal.GetCacheMax(*args)
3233
3235 """GetCacheUsed() -> GIntBig"""
3236 return _gdal.GetCacheUsed(*args)
3237
3239 """SetCacheMax(GIntBig nBytes)"""
3240 return _gdal.SetCacheMax(*args)
3241
3243 """GetDataTypeSize(GDALDataType eDataType) -> int"""
3244 return _gdal.GetDataTypeSize(*args)
3245
3247 """DataTypeIsComplex(GDALDataType eDataType) -> int"""
3248 return _gdal.DataTypeIsComplex(*args)
3249
3251 """GetDataTypeName(GDALDataType eDataType) -> char const *"""
3252 return _gdal.GetDataTypeName(*args)
3253
3255 """GetDataTypeByName(char const * pszDataTypeName) -> GDALDataType"""
3256 return _gdal.GetDataTypeByName(*args)
3257
3259 """GetColorInterpretationName(GDALColorInterp eColorInterp) -> char const *"""
3260 return _gdal.GetColorInterpretationName(*args)
3261
3263 """GetPaletteInterpretationName(GDALPaletteInterp ePaletteInterp) -> char const *"""
3264 return _gdal.GetPaletteInterpretationName(*args)
3265
3267 """DecToDMS(double arg1, char const * arg2, int arg3=2) -> char const *"""
3268 return _gdal.DecToDMS(*args)
3269
3271 """PackedDMSToDec(double dfPacked) -> double"""
3272 return _gdal.PackedDMSToDec(*args)
3273
3275 """DecToPackedDMS(double dfDec) -> double"""
3276 return _gdal.DecToPackedDMS(*args)
3277
3279 """ParseXMLString(char * pszXMLString) -> CPLXMLNode *"""
3280 return _gdal.ParseXMLString(*args)
3281
3283 """SerializeXMLTree(CPLXMLNode * xmlnode) -> retStringAndCPLFree *"""
3284 return _gdal.SerializeXMLTree(*args)
3285
3287 """GetJPEG2000Structure(char const * pszFilename, char ** options=None) -> CPLXMLNode *"""
3288 return _gdal.GetJPEG2000Structure(*args)
3289
3291 """GetJPEG2000StructureAsString(char const * pszFilename, char ** options=None) -> retStringAndCPLFree *"""
3292 return _gdal.GetJPEG2000StructureAsString(*args)
3293
3295 """GetDriverCount() -> int"""
3296 return _gdal.GetDriverCount(*args)
3297
3299 """GetDriverByName(char const * name) -> Driver"""
3300 return _gdal.GetDriverByName(*args)
3301
3303 """GetDriver(int i) -> Driver"""
3304 return _gdal.GetDriver(*args)
3305
3307 """Open(char const * utf8_path, GDALAccess eAccess) -> Dataset"""
3308 return _gdal.Open(*args)
3309
3311 """OpenEx(char const * utf8_path, unsigned int nOpenFlags=0, char ** allowed_drivers=None, char ** open_options=None, char ** sibling_files=None) -> Dataset"""
3312 return _gdal.OpenEx(*args, **kwargs)
3313
3315 """OpenShared(char const * utf8_path, GDALAccess eAccess) -> Dataset"""
3316 return _gdal.OpenShared(*args)
3317
3319 """IdentifyDriver(char const * utf8_path, char ** papszSiblings=None) -> Driver"""
3320 return _gdal.IdentifyDriver(*args)
3321
3323 """IdentifyDriverEx(char const * utf8_path, unsigned int nIdentifyFlags=0, char ** allowed_drivers=None, char ** sibling_files=None) -> Driver"""
3324 return _gdal.IdentifyDriverEx(*args, **kwargs)
3325
3327 """GeneralCmdLineProcessor(char ** papszArgv, int nOptions=0) -> char **"""
3328 return _gdal.GeneralCmdLineProcessor(*args)
3329
3330 __version__ = _gdal.VersionInfo("RELEASE_NAME")
3331
3350 GDALInfoOptions_swigregister = _gdal.GDALInfoOptions_swigregister
3351 GDALInfoOptions_swigregister(GDALInfoOptions)
3352
3353
3355 """InfoInternal(Dataset hDataset, GDALInfoOptions infoOptions) -> retStringAndCPLFree *"""
3356 return _gdal.InfoInternal(*args)
3375 GDALTranslateOptions_swigregister = _gdal.GDALTranslateOptions_swigregister
3376 GDALTranslateOptions_swigregister(GDALTranslateOptions)
3377
3378
3380 """TranslateInternal(char const * dest, Dataset dataset, GDALTranslateOptions translateOptions, GDALProgressFunc callback=0, void * callback_data=None) -> Dataset"""
3381 return _gdal.TranslateInternal(*args)
3400 GDALWarpAppOptions_swigregister = _gdal.GDALWarpAppOptions_swigregister
3401 GDALWarpAppOptions_swigregister(GDALWarpAppOptions)
3402
3403
3405 """wrapper_GDALWarpDestDS(Dataset dstDS, int object_list_count, GDALWarpAppOptions warpAppOptions, GDALProgressFunc callback=0, void * callback_data=None) -> int"""
3406 return _gdal.wrapper_GDALWarpDestDS(*args)
3407
3409 """wrapper_GDALWarpDestName(char const * dest, int object_list_count, GDALWarpAppOptions warpAppOptions, GDALProgressFunc callback=0, void * callback_data=None) -> Dataset"""
3410 return _gdal.wrapper_GDALWarpDestName(*args)
3429 GDALVectorTranslateOptions_swigregister = _gdal.GDALVectorTranslateOptions_swigregister
3430 GDALVectorTranslateOptions_swigregister(GDALVectorTranslateOptions)
3431
3432
3434 """wrapper_GDALVectorTranslateDestDS(Dataset dstDS, Dataset srcDS, GDALVectorTranslateOptions options, GDALProgressFunc callback=0, void * callback_data=None) -> int"""
3435 return _gdal.wrapper_GDALVectorTranslateDestDS(*args)
3436
3438 """wrapper_GDALVectorTranslateDestName(char const * dest, Dataset srcDS, GDALVectorTranslateOptions options, GDALProgressFunc callback=0, void * callback_data=None) -> Dataset"""
3439 return _gdal.wrapper_GDALVectorTranslateDestName(*args)
3458 GDALDEMProcessingOptions_swigregister = _gdal.GDALDEMProcessingOptions_swigregister
3459 GDALDEMProcessingOptions_swigregister(GDALDEMProcessingOptions)
3460
3461
3463 """DEMProcessingInternal(char const * dest, Dataset dataset, char const * pszProcessing, char const * pszColorFilename, GDALDEMProcessingOptions options, GDALProgressFunc callback=0, void * callback_data=None) -> Dataset"""
3464 return _gdal.DEMProcessingInternal(*args)
3483 GDALNearblackOptions_swigregister = _gdal.GDALNearblackOptions_swigregister
3484 GDALNearblackOptions_swigregister(GDALNearblackOptions)
3485
3486
3488 """wrapper_GDALNearblackDestDS(Dataset dstDS, Dataset srcDS, GDALNearblackOptions options, GDALProgressFunc callback=0, void * callback_data=None) -> int"""
3489 return _gdal.wrapper_GDALNearblackDestDS(*args)
3490
3492 """wrapper_GDALNearblackDestName(char const * dest, Dataset srcDS, GDALNearblackOptions options, GDALProgressFunc callback=0, void * callback_data=None) -> Dataset"""
3493 return _gdal.wrapper_GDALNearblackDestName(*args)
3512 GDALGridOptions_swigregister = _gdal.GDALGridOptions_swigregister
3513 GDALGridOptions_swigregister(GDALGridOptions)
3514
3515
3517 """GridInternal(char const * dest, Dataset dataset, GDALGridOptions options, GDALProgressFunc callback=0, void * callback_data=None) -> Dataset"""
3518 return _gdal.GridInternal(*args)
3537 GDALRasterizeOptions_swigregister = _gdal.GDALRasterizeOptions_swigregister
3538 GDALRasterizeOptions_swigregister(GDALRasterizeOptions)
3539
3540
3542 """wrapper_GDALRasterizeDestDS(Dataset dstDS, Dataset srcDS, GDALRasterizeOptions options, GDALProgressFunc callback=0, void * callback_data=None) -> int"""
3543 return _gdal.wrapper_GDALRasterizeDestDS(*args)
3544
3546 """wrapper_GDALRasterizeDestName(char const * dest, Dataset srcDS, GDALRasterizeOptions options, GDALProgressFunc callback=0, void * callback_data=None) -> Dataset"""
3547 return _gdal.wrapper_GDALRasterizeDestName(*args)
3566 GDALBuildVRTOptions_swigregister = _gdal.GDALBuildVRTOptions_swigregister
3567 GDALBuildVRTOptions_swigregister(GDALBuildVRTOptions)
3568
3569
3571 """BuildVRTInternalObjects(char const * dest, int object_list_count, GDALBuildVRTOptions options, GDALProgressFunc callback=0, void * callback_data=None) -> Dataset"""
3572 return _gdal.BuildVRTInternalObjects(*args)
3573
3575 """BuildVRTInternalNames(char const * dest, char ** source_filenames, GDALBuildVRTOptions options, GDALProgressFunc callback=0, void * callback_data=None) -> Dataset"""
3576 return _gdal.BuildVRTInternalNames(*args)
3577
3578