# osgeo.gdal module

osgeo.gdal.AbortPendingUploads(char const * utf8_path) → bool

osgeo.gdal.AllRegister()

osgeo.gdal.ApplyGeoTransform(double [6] padfGeoTransform, double dfPixel, double dfLine)

osgeo.gdal.ApplyVerticalShiftGrid(Dataset src_ds, Dataset grid_ds, bool inverse=False, double srcUnitToMeter=1.0, double dstUnitToMeter=1.0, char ** options=None) → Dataset

class osgeo.gdal.AsyncReader(*args, **kwargs)

  Bases: `object`

  Proxy of C++ GDALAsyncReaderShadow class.

  GetBuffer(AsyncReader self)
  GetNextUpdatedRegion(AsyncReader self, double timeout) → GDALAsyncStatusType
  LockBuffer(AsyncReader self, double timeout) → int
  UnlockBuffer(AsyncReader self)
  property thisown

    The membership flag

class osgeo.gdal.Attribute(*args, **kwargs)

  Bases: `object`

  Proxy of C++ GDALAttributeHS class.

  GetDataType(Attribute self) → ExtendedDataType
  GetDimensionCount(Attribute self) → size_t
  GetDimensionsSize(Attribute self)
  GetFullName(Attribute self) → char const *
  GetName(Attribute self) → char const *
  GetTotalElementsCount(Attribute self) → GUIntBig
  Read()

    Read an attribute and return it with the most appropriate type

  ReadAsDouble(Attribute self) → double
  ReadAsDoubleArray(Attribute self)
  ReadAsInt(Attribute self) → int
  ReadAsIntArray(Attribute self)
  ReadAsRaw(Attribute self) → CPLErr
  ReadAsString(Attribute self) → char const *
  ReadAsStringArray(Attribute self) → char **
  Rename(Attribute self, char const * newName) → CPLErr
  Write(val)
  WriteDouble(Attribute self, double val) → CPLErr
  WriteDoubleArray(Attribute self, int nList) → CPLErr
  WriteInt(Attribute self, int val) → CPLErr
  WriteRaw(Attribute self, GIntBig nLen) → CPLErr
  WriteString(Attribute self, char const * val) → CPLErr
  WriteStringArray(Attribute self, char ** vals) → CPLErr
  property thisown

    The membership flag

osgeo.gdal.AutoCreateWarpedVRT(Dataset src_ds, char const * src_wkt=None, char const * dst_wkt=None, GDALResampleAlg eResampleAlg=GRA_NearestNeighbour, double maxerror=0.0) → Dataset

class osgeo.gdal.Band(*args, **kwargs)

  Bases: `MajorObject`

  Proxy of C++ GDALRasterBandShadow class.

  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
  AsMDArray(Band self) → MDArray
  Checksum(Band self, int xoff=0, int yoff=0, int * xsize=None, int * ysize=None) → int
  ComputeBandStats(Band self, int samplestep=1)
  ComputeRasterMinMax(Band self, bool approx_ok=False, bool can_return_none=False) → (min, max) or None
  ComputeStatistics(Band self, bool approx_ok, callback=None, callback_data=None) → CPLErr
  CreateMaskBand(Band self, int nFlags) → CPLErr
  property DataType

    GDALDataType

    Type:

      DataType

  DeleteNoDataValue(Band self) → CPLErr
  Fill(Band self, double real_fill, double imag_fill=0.0) → CPLErr
  FlushCache(Band self)
  GetActualBlockSize(Band self, int nXBlockOff, int nYBlockOff)
  GetBand(Band self) → int
  GetBlockSize(Band self)
  GetCategoryNames(Band self) → char **
  GetColorInterpretation(Band self) → GDALColorInterp
  GetColorTable(Band self) → ColorTable
  GetDataCoverageStatus(Band self, int nXOff, int nYOff, int nXSize, int nYSize, int nMaskFlagStop=0) → int
  GetDataset(Band self) → Dataset
  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
  GetDefaultRAT(Band self) → RasterAttributeTable
  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
  GetMaskBand(Band self) → Band
  GetMaskFlags(Band self) → int
  GetMaximum(Band self)
  GetMinimum(Band self)
  GetNoDataValue(Band self) → value
  GetNoDataValueAsInt64(Band self)
  GetNoDataValueAsUInt64(Band self)
  GetOffset(Band self)
  GetOverview(Band self, int i) → Band
  GetOverviewCount(Band self) → int
  GetRasterCategoryNames(Band self) → char **
  GetRasterColorInterpretation(Band self) → GDALColorInterp
  GetRasterColorTable(Band self) → ColorTable
  GetScale(Band self)
  GetStatistics(Band self, int approx_ok, int force) → CPLErr
  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
  GetTiledVirtualMemArray(eAccess=0, xoff=0, yoff=0, xsize=None, ysize=None, tilexsize=256, tileysize=256, datatype=None, cache_size=10485760, options=None)

    Return a NumPy array for the band, seen as a virtual memory mapping with a tile organization. An element is accessed with array[tiley][tilex][y][x]. Any reference to the array must be dropped before the last reference to the related dataset is also dropped.

  GetUnitType(Band self) → char const *
  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
  GetVirtualMemArray(eAccess=0, xoff=0, yoff=0, xsize=None, ysize=None, bufxsize=None, bufysize=None, datatype=None, cache_size=10485760, page_size_hint=0, options=None)

    Return a NumPy array for the band, seen as a virtual memory mapping. An element is accessed with array[y][x]. Any reference to the array must be dropped before the last reference to the related dataset is also dropped.

  GetVirtualMemAuto(Band self, GDALRWFlag eRWFlag, char ** options=None) → VirtualMem
  GetVirtualMemAutoArray(eAccess=0, options=None)

    Return a NumPy array for the band, seen as a virtual memory mapping. An element is accessed with array[y][x]. Any reference to the array must be dropped before the last reference to the related dataset is also dropped.

  HasArbitraryOverviews(Band self) → bool
  IsMaskBand(Band self) → bool
  ReadAsArray(xoff=0, yoff=0, win_xsize=None, win_ysize=None, buf_xsize=None, buf_ysize=None, buf_type=None, buf_obj=None, resample_alg=0, callback=None, callback_data=None)

    Reading a chunk of a GDAL band into a numpy array. The optional (buf_xsize,buf_ysize,buf_type) parameters should generally not be specified if buf_obj is specified. The array is returned

  ReadBlock(Band self, int xoff, int yoff, void * buf_obj=None) → CPLErr
  ReadRaster(xoff=0, yoff=0, xsize=None, ysize=None, buf_xsize=None, buf_ysize=None, buf_type=None, buf_pixel_space=None, buf_line_space=None, resample_alg=0, callback=None, callback_data=None, buf_obj=None)
  ReadRaster1(Band self, double xoff, double yoff, double xsize, double ysize, int * buf_xsize=None, int * buf_ysize=None, GDALDataType * buf_type=None, GIntBig * buf_pixel_space=None, GIntBig * buf_line_space=None, GDALRIOResampleAlg resample_alg=GRIORA_NearestNeighbour, GDALProgressFunc callback=0, void * callback_data=None, void * inputOutputBuf=None) → CPLErr
  SetCategoryNames(Band self, char ** papszCategoryNames) → CPLErr
  SetColorInterpretation(Band self, GDALColorInterp val) → CPLErr
  SetColorTable(Band self, ColorTable arg) → int
  SetDefaultHistogram(Band self, double min, double max, int buckets_in) → CPLErr
  SetDefaultRAT(Band self, RasterAttributeTable table) → int
  SetNoDataValue(Band self, value) → CPLErr
  SetNoDataValueAsInt64(Band self, GIntBig v) → CPLErr
  SetNoDataValueAsUInt64(Band self, GUIntBig v) → CPLErr
  SetOffset(Band self, double val) → CPLErr
  SetRasterCategoryNames(Band self, char ** names) → CPLErr
  SetRasterColorInterpretation(Band self, GDALColorInterp val) → CPLErr
  SetRasterColorTable(Band self, ColorTable arg) → int
  SetScale(Band self, double val) → CPLErr
  SetStatistics(Band self, double min, double max, double mean, double stddev) → CPLErr
  SetUnitType(Band self, char const * val) → CPLErr
  WriteArray(array, xoff=0, yoff=0, resample_alg=0, callback=None, callback_data=None)
  WriteRaster(xoff, yoff, xsize, ysize, buf_string, buf_xsize=None, buf_ysize=None, buf_type=None, buf_pixel_space=None, buf_line_space=None)
  property XSize

    int

    Type:

      XSize

  property YSize

    int

    Type:

      YSize

  property thisown

    The membership flag

osgeo.gdal.BuildVRT(destName, srcDSOrSrcDSTab, **kwargs)

  Build a VRT from a list of datasets.

  Parameters:

    - destName -- Output dataset name.

    - srcDSOrSrcDSTab -- An array of Dataset objects or filenames, or a Dataset object or a filename.

    - kwargs -- options: return of gdal.BuildVRTOptions(), string or array of strings, other keywords arguments of gdal.BuildVRTOptions(). If options is provided as a gdal.BuildVRTOptions() object, other keywords are ignored.

osgeo.gdal.BuildVRTInternalNames(char const * dest, char ** source_filenames, GDALBuildVRTOptions options, GDALProgressFunc callback=0, void * callback_data=None) → Dataset

osgeo.gdal.BuildVRTInternalObjects(char const * dest, int object_list_count, GDALBuildVRTOptions options, GDALProgressFunc callback=0, void * callback_data=None) → Dataset

osgeo.gdal.BuildVRTOptions(options=None, resolution=None, outputBounds=None, xRes=None, yRes=None, targetAlignedPixels=None, separate=None, bandList=None, addAlpha=None, resampleAlg=None, outputSRS=None, allowProjectionDifference=None, srcNodata=None, VRTNodata=None, hideNodata=None, strict=False, callback=None, callback_data=None)

  Create a BuildVRTOptions() object that can be passed to gdal.BuildVRT()

  Parameters:

    - options (l) -- can be be an array of strings, a string or let empty and filled from other keywords.

    - resolution -- 'highest', 'lowest', 'average', 'user'.

    - outputBounds (l) -- output bounds as (minX, minY, maxX, maxY) in target SRS.

    - xRes -- output resolution in target SRS.

    - yRes -- output resolution in target SRS.

    - targetAlignedPixels -- whether to force output bounds to be multiple of output resolution.

    - separate -- whether each source file goes into a separate stacked band in the VRT band.

    - bandList -- array of band numbers (index start at 1).

    - addAlpha -- whether to add an alpha mask band to the VRT when the source raster have none.

    - resampleAlg -- resampling mode.

    - outputSRS -- assigned output SRS.

    - allowProjectionDifference -- whether to accept input datasets have not the same projection. Note: they will not be reprojected.

    - srcNodata -- source nodata value(s).

    - VRTNodata -- nodata values at the VRT band level.

    - hideNodata -- whether to make the VRT band not report the NoData value.

    - strict -- set to True if warnings should be failures

    - callback -- callback method.

    - callback_data -- user data for callback.

osgeo.gdal.CPLBinaryToHex(int nBytes) → retStringAndCPLFree *

osgeo.gdal.CPLHexToBinary(char const * pszHex, int * pnBytes) → GByte *

osgeo.gdal.ClearCredentials(char const * pszPathPrefix=None)

osgeo.gdal.ClearPathSpecificOptions(char const * pszPathPrefix=None)

osgeo.gdal.CloseDir(VSIDIR * dir)

class osgeo.gdal.ColorEntry(*args, **kwargs)

  Bases: `object`

  Proxy of C++ GDALColorEntry class.

  property c1

    short

    Type:

      c1

  property c2

    short

    Type:

      c2

  property c3

    short

    Type:

      c3

  property c4

    short

    Type:

      c4

  property thisown

    The membership flag

class osgeo.gdal.ColorTable(*args, **kwargs)

  Bases: `object`

  Proxy of C++ GDALColorTableShadow class.

  Clone(ColorTable self) → ColorTable
  CreateColorRamp(ColorTable self, int nStartIndex, ColorEntry startcolor, int nEndIndex, ColorEntry endcolor)
  GetColorEntry(ColorTable self, int entry) → ColorEntry
  GetColorEntryAsRGB(ColorTable self, int entry, ColorEntry centry) → int
  GetCount(ColorTable self) → int
  GetPaletteInterpretation(ColorTable self) → GDALPaletteInterp
  SetColorEntry(ColorTable self, int entry, ColorEntry centry)
  property thisown

    The membership flag

osgeo.gdal.ComputeMedianCutPCT(Band red, Band green, Band blue, int num_colors, ColorTable colors, GDALProgressFunc callback=0, void * callback_data=None) → int

osgeo.gdal.ComputeProximity(Band srcBand, Band proximityBand, char ** options=None, GDALProgressFunc callback=0, void * callback_data=None) → int

osgeo.gdal.ConfigurePythonLogging(logger_name='gdal', enable_debug=False)

  Configure GDAL to use Python's logging framework

osgeo.gdal.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

osgeo.gdal.ContourGenerateEx(Band srcBand, Layer dstLayer, char ** options=None, GDALProgressFunc callback=0, void * callback_data=None) → int

osgeo.gdal.CopyFile(char const * pszSource, char const * pszTarget, VSILFILE fpSource=None, GIntBig nSourceSize=-1, char ** options=None, GDALProgressFunc callback=0, void * callback_data=None) → int

osgeo.gdal.CreatePansharpenedVRT(char const * pszXML, Band panchroBand, int nInputSpectralBands) → Dataset

osgeo.gdal.DEMProcessing(destName, srcDS, processing, **kwargs)

  Apply a DEM processing.

  Parameters:

    - destName -- Output dataset name

    - srcDS -- a Dataset object or a filename

    - processing -- one of "hillshade", "slope", "aspect", "color-relief", "TRI", "TPI", "Roughness"

    - kwargs -- options: return of gdal.DEMProcessingOptions(), string or array of strings, other keywords arguments of gdal.DEMProcessingOptions(). If options is provided as a gdal.DEMProcessingOptions() object, other keywords are ignored.

osgeo.gdal.DEMProcessingInternal(char const * dest, Dataset dataset, char const * pszProcessing, char const * pszColorFilename, GDALDEMProcessingOptions options, GDALProgressFunc callback=0, void * callback_data=None) → Dataset

osgeo.gdal.DEMProcessingOptions(options=None, colorFilename=None, format=None, creationOptions=None, computeEdges=False, alg=None, band=1, zFactor=None, scale=None, azimuth=None, altitude=None, combined=False, multiDirectional=False, igor=False, slopeFormat=None, trigonometric=False, zeroForFlat=False, addAlpha=None, colorSelection=None, callback=None, callback_data=None)

  Create a DEMProcessingOptions() object that can be passed to gdal.DEMProcessing()

  Parameters:

    - options -- can be be an array of strings, a string or let empty and filled from other keywords.

    - colorFilename -- (mandatory for "color-relief") name of file that contains palette definition for the "color-relief" processing.

    - format -- output format ("GTiff", etc...)

    - creationOptions -- list or dict of creation options

    - computeEdges -- whether to compute values at raster edges.

    - alg -- 'Horn' (default) or 'ZevenbergenThorne' for hillshade, slope or aspect. 'Wilson' (default) or 'Riley' for TRI

    - band -- source band number to use

    - zFactor -- (hillshade only) vertical exaggeration used to pre-multiply the elevations.

    - scale -- ratio of vertical units to horizontal.

    - 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.

    - altitude -- (hillshade only) altitude of the light, in degrees. 90 if the light comes from above the DEM, 0 if it is raking light.

    - 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.

    - multiDirectional -- (hillshade only) whether to compute multi-directional shading. Only one of combined, multiDirectional and igor can be specified.

    - igor -- (hillshade only) whether to use Igor's hillshading from Maperitive. Only one of combined, multiDirectional and igor can be specified.

    - slopeFormat -- (slope only) "degree" or "percent".

    - trigonometric -- (aspect only) whether to return trigonometric angle instead of azimuth. Thus 0deg means East, 90deg North, 180deg West, 270deg South.

    - zeroForFlat -- (aspect only) whether to return 0 for flat areas with slope=0, instead of -9999.

    - addAlpha -- adds an alpha band to the output file (only for processing = 'color-relief')

    - colorSelection -- (color-relief only) Determines how color entries are selected from an input value. Can be "nearest_color_entry", "exact_color_entry" or "linear_interpolation". Defaults to "linear_interpolation"

    - callback -- callback method

    - callback_data -- user data for callback

osgeo.gdal.DataTypeIsComplex(GDALDataType eDataType) → int

osgeo.gdal.DataTypeUnion(GDALDataType a, GDALDataType b) → GDALDataType

class osgeo.gdal.Dataset(*args, **kwargs)

  Bases: `MajorObject`

  Python proxy of a raster `GDALDataset`.

  Since GDAL 3.8, a Dataset can be used as a context manager. When exiting the context, the Dataset will be closed and data will be written to disk.

  AbortSQL(Dataset self) → OGRErr
  AddBand(Dataset self, GDALDataType datatype=GDT_Byte, char ** options=None) → CPLErr
  AddFieldDomain(Dataset self, FieldDomain fieldDomain) → bool
  AddRelationship(Dataset self, Relationship relationship) → bool
  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
  BeginAsyncReader(xoff, yoff, xsize, ysize, buf_obj=None, buf_xsize=None, buf_ysize=None, buf_type=None, band_list=None, options=None)
  BuildOverviews(Dataset self, char const * resampling="NEAREST", int overviewlist=0, GDALProgressFunc callback=0, void * callback_data=None, char ** options=None) → int
  ClearStatistics(Dataset self)
  Close(Dataset self) → CPLErr

    Closes opened dataset and releases allocated resources.

    This method can be used to force the dataset to close when one more references to the dataset are still reachable. If Close is never called, the dataset will be closed automatically during garbage collection.

  CommitTransaction(Dataset self) → OGRErr
  CopyLayer(Dataset self, Layer src_layer, char const * new_name, char ** options=None) → Layer
  CreateLayer(Dataset self, char const * name, SpatialReference srs=None, OGRwkbGeometryType geom_type=wkbUnknown, char ** options=None) → Layer
  CreateMaskBand(Dataset self, int nFlags) → CPLErr
  DeleteFieldDomain(Dataset self, char const * name) → bool
  DeleteLayer(value)

    Deletes the layer given an index or layer name

  DeleteRelationship(Dataset self, char const * name) → bool
  EndAsyncReader(Dataset self, AsyncReader ario)
  ExecuteSQL(self, statement, spatialFilter: ogr.Geometry = None, dialect: str | None = '', keep_ref_on_ds=False) → ogr.Layer

    Execute a SQL statement against the dataset

    The result of a SQL query is:

      - None (or an exception if exceptions are enabled) for statements that are in error

      - or None for statements that have no results set,

      - or a ogr.Layer handle representing a results set from the query.

    Note that this ogr.Layer is in addition to the layers in the data store and must be released with ReleaseResultSet() before the data source is closed (destroyed).

    Starting with GDAL 3.7, this method can also be used as a context manager, as a convenient way of automatically releasing the returned result layer.

    For more information on the SQL dialect supported internally by OGR review the OGR SQL document (OGR SQL dialect and SQLITE SQL dialect) Some drivers (i.e. Oracle and PostGIS) pass the SQL directly through to the underlying RDBMS.

    The SQLITE dialect can also be used (SQL SQLite dialect)

    Parameters:

      - statement -- the SQL statement to execute (e.g "SELECT * FROM layer")

      - spatialFilter -- a geometry which represents a spatial filter. Can be None

      - dialect -- allows control of the statement dialect. If set to None or empty string, the OGR SQL engine will be used, except for RDBMS drivers that will use their dedicated SQL engine, unless OGRSQL is explicitly passed as the dialect. The SQLITE dialect can also be used.

      - keep_ref_on_ds -- whether the returned layer should keep a (strong) reference on the current dataset. Cf example 2 for a use case.

    Returns:

      a ogr.Layer containing the results of the query, that will be automatically released when the context manager goes out of scope.

    Return type:

      ogr.Layer

    Examples

    1. Use as a context manager:

        >>> with ds.ExecuteSQL("SELECT * FROM layer") as lyr:
        ...     print(lyr.GetFeatureCount())

    2. Use keep_ref_on_ds=True to return an object that keeps a reference to its dataset:

        >>> def get_sql_lyr():
        ...     return gdal.OpenEx("test.shp").ExecuteSQL("SELECT * FROM test", keep_ref_on_ds=True)
        ...
        ... with get_sql_lyr() as lyr:
        ...     print(lyr.GetFeatureCount())

  FlushCache(Dataset self) → CPLErr
  GetDriver(Dataset self) → Driver
  GetFieldDomain(Dataset self, char const * name) → FieldDomain
  GetFieldDomainNames(Dataset self, char ** options=None) → char **
  GetFileList(Dataset self) → char **
  GetGCPCount(Dataset self) → int
  GetGCPProjection(Dataset self) → char const *
  GetGCPSpatialRef(Dataset self) → SpatialReference
  GetGCPs(Dataset self)
  GetGeoTransform(Dataset self, int * can_return_null=None)
  GetLayer(iLayer=0)

    Return the layer given an index or a name

  GetLayerByIndex(Dataset self, int index=0) → Layer
  GetLayerByName(Dataset self, char const * layer_name) → Layer
  GetLayerCount(Dataset self) → int
  GetNextFeature(Dataset self, bool include_layer=True, bool include_pct=False, GDALProgressFunc callback=0, void * callback_data=None) → Feature
  GetProjection(Dataset self) → char const *
  GetProjectionRef(Dataset self) → char const *
  GetRasterBand(Dataset self, int nBand) → Band
  GetRelationship(Dataset self, char const * name) → Relationship
  GetRelationshipNames(Dataset self, char ** options=None) → char **
  GetRootGroup(Dataset self) → Group
  GetSpatialRef(Dataset self) → SpatialReference
  GetStyleTable(Dataset self) → StyleTable
  GetSubDatasets()
  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
  GetTiledVirtualMemArray(eAccess=0, xoff=0, yoff=0, xsize=None, ysize=None, tilexsize=256, tileysize=256, datatype=None, band_list=None, tile_organization=2, cache_size=10485760, options=None)

    Return a NumPy array for the dataset, seen as a virtual memory mapping with a tile organization. If there are several bands and tile_organization = gdal.GTO_TIP, an element is accessed with array[tiley][tilex][y][x][band]. If there are several bands and tile_organization = gdal.GTO_BIT, an element is accessed with array[tiley][tilex][band][y][x]. If there are several bands and tile_organization = gdal.GTO_BSQ, an element is accessed with array[band][tiley][tilex][y][x]. If there is only one band, an element is accessed with array[tiley][tilex][y][x]. Any reference to the array must be dropped before the last reference to the related dataset is also dropped.

  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
  GetVirtualMemArray(eAccess=0, xoff=0, yoff=0, xsize=None, ysize=None, bufxsize=None, bufysize=None, datatype=None, band_list=None, band_sequential=True, cache_size=10485760, page_size_hint=0, options=None)

    Return a NumPy array for the dataset, seen as a virtual memory mapping. If there are several bands and band_sequential = True, an element is accessed with array[band][y][x]. If there are several bands and band_sequential = False, an element is accessed with array[y][x][band]. If there is only one band, an element is accessed with array[y][x]. Any reference to the array must be dropped before the last reference to the related dataset is also dropped.

  IsLayerPrivate(Dataset self, int index) → bool
  property RasterCount

    int

    Type:

      RasterCount

  property RasterXSize

    int

    Type:

      RasterXSize

  property RasterYSize

    int

    Type:

      RasterYSize

  ReadAsArray(xoff=0, yoff=0, xsize=None, ysize=None, buf_obj=None, buf_xsize=None, buf_ysize=None, buf_type=None, resample_alg=0, callback=None, callback_data=None, interleave='band', band_list=None)

    Reading a chunk of a GDAL band into a numpy array. The optional (buf_xsize,buf_ysize,buf_type) parameters should generally not be specified if buf_obj is specified. The array is returned

  ReadRaster(xoff=0, yoff=0, xsize=None, ysize=None, buf_xsize=None, buf_ysize=None, buf_type=None, band_list=None, buf_pixel_space=None, buf_line_space=None, buf_band_space=None, resample_alg=0, callback=None, callback_data=None, buf_obj=None)
  ReadRaster1(Dataset self, double xoff, double yoff, double xsize, double ysize, int * buf_xsize=None, int * buf_ysize=None, GDALDataType * buf_type=None, int band_list=0, GIntBig * buf_pixel_space=None, GIntBig * buf_line_space=None, GIntBig * buf_band_space=None, GDALRIOResampleAlg resample_alg=GRIORA_NearestNeighbour, GDALProgressFunc callback=0, void * callback_data=None, void * inputOutputBuf=None) → CPLErr
  ReleaseResultSet(self, sql_lyr: ogr.Layer)

    Release ogr.Layer returned by ExecuteSQL() (when not called as an execution manager)

    The sql_lyr object is invalidated after this call.

    Parameters:

      sql_lyr -- ogr.Layer got with ExecuteSQL()

  ResetReading(Dataset self)
  RollbackTransaction(Dataset self) → OGRErr
  SetGCPs(gcps, wkt_or_spatial_ref)
  SetGeoTransform(Dataset self, double [6] argin) → CPLErr
  SetProjection(Dataset self, char const * prj) → CPLErr
  SetSpatialRef(Dataset self, SpatialReference srs) → CPLErr
  SetStyleTable(Dataset self, StyleTable table)
  StartTransaction(Dataset self, int force=FALSE) → OGRErr
  TestCapability(Dataset self, char const * cap) → bool
  UpdateFieldDomain(Dataset self, FieldDomain fieldDomain) → bool
  UpdateRelationship(Dataset self, Relationship relationship) → bool
  WriteArray(array, xoff=0, yoff=0, band_list=None, interleave='band', resample_alg=0, callback=None, callback_data=None)
  WriteRaster(xoff, yoff, xsize, ysize, buf_string, buf_xsize=None, buf_ysize=None, buf_type=None, band_list=None, buf_pixel_space=None, buf_line_space=None, buf_band_space=None)
  property thisown

    The membership flag

osgeo.gdal.Debug(char const * msg_class, char const * message)

osgeo.gdal.DecToDMS(double arg1, char const * arg2, int arg3=2) → char const *

osgeo.gdal.DecToPackedDMS(double dfDec) → double

class osgeo.gdal.Dimension(*args, **kwargs)

  Bases: `object`

  Proxy of C++ GDALDimensionHS class.

  GetDirection(Dimension self) → char const *
  GetFullName(Dimension self) → char const *
  GetIndexingVariable(Dimension self) → MDArray
  GetName(Dimension self) → char const *
  GetSize(Dimension self) → GUIntBig
  GetType(Dimension self) → char const *
  Rename(Dimension self, char const * newName) → CPLErr
  SetIndexingVariable(Dimension self, MDArray array) → bool
  property thisown

    The membership flag

class osgeo.gdal.DirEntry(*args)

  Bases: `object`

  Proxy of C++ DirEntry class.

  IsDirectory(DirEntry self) → bool
  property extra

    p.p.char

    Type:

      extra

  property mode

    int

    Type:

      mode

  property modeKnown

    bool

    Type:

      modeKnown

  property mtime

    GIntBig

    Type:

      mtime

  property mtimeKnown

    bool

    Type:

      mtimeKnown

  property name

    p.char

    Type:

      name

  property size

    GIntBig

    Type:

      size

  property sizeKnown

    bool

    Type:

      sizeKnown

  property thisown

    The membership flag

osgeo.gdal.DitherRGB2PCT(Band red, Band green, Band blue, Band target, ColorTable colors, GDALProgressFunc callback=0, void * callback_data=None) → int

osgeo.gdal.DontUseExceptions()

  Disable exceptions in all GDAL related modules (osgeo.gdal, osgeo.ogr, osgeo.osr, osgeo.gnm). Note: prior to GDAL 3.7, this only affected the calling module

class osgeo.gdal.Driver(*args, **kwargs)

  Bases: `MajorObject`

  Proxy of C++ GDALDriverShadow class.

  CopyFiles(Driver self, char const * newName, char const * oldName) → CPLErr
  Create(Driver self, char const * utf8_path, int xsize, int ysize, int bands=1, GDALDataType eType=GDT_Byte, char ** options=None) → Dataset
  CreateCopy(Driver self, char const * utf8_path, Dataset src, int strict=1, char ** options=None, GDALProgressFunc callback=0, void * callback_data=None) → Dataset
  CreateMultiDimensional(Driver self, char const * utf8_path, char ** root_group_options=None, char ** options=None) → Dataset
  Delete(Driver self, char const * utf8_path) → CPLErr
  Deregister(Driver self)
  property HelpTopic

    p.q(const).char

    Type:

      HelpTopic

  property LongName

    p.q(const).char

    Type:

      LongName

  Register(Driver self) → int
  Rename(Driver self, char const * newName, char const * oldName) → CPLErr
  property ShortName

    p.q(const).char

    Type:

      ShortName

  property thisown

    The membership flag

class osgeo.gdal.EDTComponent(*args, **kwargs)

  Bases: `object`

  Proxy of C++ GDALEDTComponentHS class.

  static Create(char const * name, size_t offset, ExtendedDataType type) → EDTComponent
  GetName(EDTComponent self) → char const *
  GetOffset(EDTComponent self) → size_t
  GetType(EDTComponent self) → ExtendedDataType
  property thisown

    The membership flag

osgeo.gdal.Error(CPLErr msg_class=CE_Failure, int err_code=0, char const * msg="error")

osgeo.gdal.ErrorReset()

osgeo.gdal.EscapeBinary(int len, int scheme=CPLES_SQL)

osgeo.gdal.EscapeString(string_or_bytes, scheme=gdal.CPLES_SQL)

class osgeo.gdal.ExceptionMgr(useExceptions=True)

  Bases: `object`

  Context manager to manage Python Exception state for GDAL/OGR/OSR/GNM.

  Separate exception state is maintained for each module (gdal, ogr, etc), and this class appears independently in all of them. This is built in top of calls to the older UseExceptions()/DontUseExceptions() functions.

  Example:

      >>> print(gdal.GetUseExceptions())
      0
      >>> with gdal.ExceptionMgr():
      ...     # Exceptions are now in use
      ...     print(gdal.GetUseExceptions())
      1
      >>>
      >>> # Exception state has now been restored
      >>> print(gdal.GetUseExceptions())
      0

class osgeo.gdal.ExtendedDataType(*args, **kwargs)

  Bases: `object`

  Proxy of C++ GDALExtendedDataTypeHS class.

  CanConvertTo(ExtendedDataType self, ExtendedDataType other) → bool
  static Create(GDALDataType dt) → ExtendedDataType
  static CreateCompound(char const * name, size_t nTotalSize, int nComps) → ExtendedDataType
  static CreateString(size_t nMaxStringLength=0, GDALExtendedDataTypeSubType eSubType=GEDTST_NONE) → ExtendedDataType
  Equals(ExtendedDataType self, ExtendedDataType other) → bool
  GetClass(ExtendedDataType self) → GDALExtendedDataTypeClass
  GetComponents(ExtendedDataType self)
  GetMaxStringLength(ExtendedDataType self) → size_t
  GetName(ExtendedDataType self) → char const *
  GetNumericDataType(ExtendedDataType self) → GDALDataType
  GetSize(ExtendedDataType self) → size_t
  GetSubType(ExtendedDataType self) → GDALExtendedDataTypeSubType
  property thisown

    The membership flag

osgeo.gdal.FPolygonize(Band srcBand, Band maskBand, Layer outLayer, int iPixValField, char ** options=None, GDALProgressFunc callback=0, void * callback_data=None) → int

osgeo.gdal.FileFromMemBuffer(char const * utf8_path, GIntBig nBytes) → VSI_RETVAL

osgeo.gdal.FillNodata(Band targetBand, Band maskBand, double maxSearchDist, int smoothingIterations, char ** options=None, GDALProgressFunc callback=0, void * callback_data=None) → int

osgeo.gdal.FindFile(char const * pszClass, char const * utf8_path) → char const *

osgeo.gdal.FinderClean()

osgeo.gdal.Footprint(destNameOrDestDS, srcDS, **kwargs)

  Compute the footprint of a raster

  Parameters:

    - destNameOrDestDS -- Output dataset name or object

    - srcDS -- a Dataset object or a filename

    - kwargs -- options: return of gdal.FootprintOptions(), string or array of strings, other keywords arguments of gdal.FootprintOptions() If options is provided as a gdal.FootprintOptions() object, other keywords are ignored.

  Examples

  1. Special mode to get deserialized GeoJSON (in EPSG:4326 if dstSRS not specified):

      >>> deserialized_geojson = gdal.FootPrint(None, src_ds, format="GeoJSON")

  2. Special mode to get WKT:

      >>> wkt = gdal.FootPrint(None, src_ds, format="WKT")

  3. Get result in a GeoPackage

      >>> gdal.FootPrintf("out.gpkg", src_ds, format="GPKG")

osgeo.gdal.FootprintOptions(options=None, format=None, bands=None, srcNodata=None, ovr=None, targetCoordinateSystem=None, dstSRS=None, splitPolys=None, convexHull=None, densify=None, simplify=None, maxPoints=None, layerName=None, layerCreationOptions=None, datasetCreationOptions=None, callback=None, callback_data=None)

  Create a FootprintOptions() object that can be passed to gdal.Footprint()

  Parameters:

    - options -- can be be an array of strings, a string or let empty and filled from other keywords.

    - format -- output format ("GeoJSON", etc...)

    - bands -- list of output bands to burn values into

    - srcNodata -- source nodata value(s).

    - ovr -- overview index.

    - targetCoordinateSystem -- "pixel" or "georef"

    - dstSRS -- output SRS

    - datasetCreationOptions -- list or dict of dataset creation options

    - layerCreationOptions -- list or dict of layer creation options

    - splitPolys -- whether to split multipolygons as several polygons

    - convexHull -- whether to compute the convex hull of polygons/multipolygons

    - densify -- tolerance value for polygon densification

    - simplify -- tolerance value for polygon simplification

    - maxPoints -- maximum number of points (100 by default, "unlimited" for unlimited)

    - layerName -- output layer name

    - callback -- callback method

    - callback_data -- user data for callback

class osgeo.gdal.GCP(*args)

  Bases: `object`

  Proxy of C++ GDAL_GCP class.

  property GCPLine

    double

    Type:

      GCPLine

  property GCPPixel

    double

    Type:

      GCPPixel

  property GCPX

    double

    Type:

      GCPX

  property GCPY

    double

    Type:

      GCPY

  property GCPZ

    double

    Type:

      GCPZ

  property Id

    p.char

    Type:

      Id

  property Info

    p.char

    Type:

      Info

  serialize(with_Z=0)
  property thisown

    The membership flag

osgeo.gdal.GCPsToGeoTransform(int nGCPs, int bApproxOK=1) → RETURN_NONE

class osgeo.gdal.GDALBuildVRTOptions(*args)

  Bases: `object`

  Proxy of C++ GDALBuildVRTOptions class.

  property thisown

    The membership flag

class osgeo.gdal.GDALDEMProcessingOptions(*args)

  Bases: `object`

  Proxy of C++ GDALDEMProcessingOptions class.

  property thisown

    The membership flag

osgeo.gdal.GDALDestroyDriverManager()

class osgeo.gdal.GDALFootprintOptions(*args)

  Bases: `object`

  Proxy of C++ GDALFootprintOptions class.

  property thisown

    The membership flag

class osgeo.gdal.GDALGridOptions(*args)

  Bases: `object`

  Proxy of C++ GDALGridOptions class.

  property thisown

    The membership flag

class osgeo.gdal.GDALInfoOptions(*args)

  Bases: `object`

  Proxy of C++ GDALInfoOptions class.

  property thisown

    The membership flag

class osgeo.gdal.GDALMultiDimInfoOptions(*args)

  Bases: `object`

  Proxy of C++ GDALMultiDimInfoOptions class.

  property thisown

    The membership flag

class osgeo.gdal.GDALMultiDimTranslateOptions(*args)

  Bases: `object`

  Proxy of C++ GDALMultiDimTranslateOptions class.

  property thisown

    The membership flag

class osgeo.gdal.GDALNearblackOptions(*args)

  Bases: `object`

  Proxy of C++ GDALNearblackOptions class.

  property thisown

    The membership flag

class osgeo.gdal.GDALRasterizeOptions(*args)

  Bases: `object`

  Proxy of C++ GDALRasterizeOptions class.

  property thisown

    The membership flag

class osgeo.gdal.GDALTransformerInfoShadow(*args, **kwargs)

  Bases: `object`

  Proxy of C++ GDALTransformerInfoShadow class.

  TransformGeolocations(GDALTransformerInfoShadow self, Band xBand, Band yBand, Band zBand, GDALProgressFunc callback=0, void * callback_data=None, char ** options=None) → int
  TransformPoint(GDALTransformerInfoShadow self, int bDstToSrc, double [3] inout) → int
  TransformPoint(GDALTransformerInfoShadow self, int bDstToSrc, double x, double y, double z=0.0) → int
  TransformPoints(GDALTransformerInfoShadow self, int bDstToSrc, int nCount) → int
  property thisown

    The membership flag

class osgeo.gdal.GDALTranslateOptions(*args)

  Bases: `object`

  Proxy of C++ GDALTranslateOptions class.

  property thisown

    The membership flag

class osgeo.gdal.GDALVectorInfoOptions(*args)

  Bases: `object`

  Proxy of C++ GDALVectorInfoOptions class.

  property thisown

    The membership flag

class osgeo.gdal.GDALVectorTranslateOptions(*args)

  Bases: `object`

  Proxy of C++ GDALVectorTranslateOptions class.

  property thisown

    The membership flag

class osgeo.gdal.GDALWarpAppOptions(*args)

  Bases: `object`

  Proxy of C++ GDALWarpAppOptions class.

  property thisown

    The membership flag

osgeo.gdal.GDAL_GCP_GCPLine_get(GCP gcp) → double

osgeo.gdal.GDAL_GCP_GCPLine_set(GCP gcp, double dfGCPLine)

osgeo.gdal.GDAL_GCP_GCPPixel_get(GCP gcp) → double

osgeo.gdal.GDAL_GCP_GCPPixel_set(GCP gcp, double dfGCPPixel)

osgeo.gdal.GDAL_GCP_GCPX_get(GCP gcp) → double

osgeo.gdal.GDAL_GCP_GCPX_set(GCP gcp, double dfGCPX)

osgeo.gdal.GDAL_GCP_GCPY_get(GCP gcp) → double

osgeo.gdal.GDAL_GCP_GCPY_set(GCP gcp, double dfGCPY)

osgeo.gdal.GDAL_GCP_GCPZ_get(GCP gcp) → double

osgeo.gdal.GDAL_GCP_GCPZ_set(GCP gcp, double dfGCPZ)

osgeo.gdal.GDAL_GCP_Id_get(GCP gcp) → char const *

osgeo.gdal.GDAL_GCP_Id_set(GCP gcp, char const * pszId)

osgeo.gdal.GDAL_GCP_Info_get(GCP gcp) → char const *

osgeo.gdal.GDAL_GCP_Info_set(GCP gcp, char const * pszInfo)

osgeo.gdal.GOA2GetAccessToken(char const * pszRefreshToken, char const * pszScope) → retStringAndCPLFree *

osgeo.gdal.GOA2GetAuthorizationURL(char const * pszScope) → retStringAndCPLFree *

osgeo.gdal.GOA2GetRefreshToken(char const * pszAuthToken, char const * pszScope) → retStringAndCPLFree *

osgeo.gdal.GeneralCmdLineProcessor(char ** papszArgv, int nOptions=0) → char **

osgeo.gdal.GetActualURL(char const * utf8_path) → char const *

osgeo.gdal.GetCacheMax() → GIntBig

osgeo.gdal.GetCacheUsed() → GIntBig

osgeo.gdal.GetColorInterpretationName(GDALColorInterp eColorInterp) → char const *

osgeo.gdal.GetConfigOption(char const * pszKey, char const * pszDefault=None) → char const *

osgeo.gdal.GetConfigOptions() → char **

osgeo.gdal.GetCredential(char const * pszPathPrefix, char const * pszKey, char const * pszDefault=None) → char const *

osgeo.gdal.GetDataTypeByName(char const * pszDataTypeName) → GDALDataType

osgeo.gdal.GetDataTypeName(GDALDataType eDataType) → char const *

osgeo.gdal.GetDataTypeSize(GDALDataType eDataType) → int

osgeo.gdal.GetDriver(int i) → Driver

osgeo.gdal.GetDriverByName(char const * name) → Driver

osgeo.gdal.GetDriverCount() → int

osgeo.gdal.GetErrorCounter() → unsigned int

osgeo.gdal.GetFileMetadata(char const * utf8_path, char const * domain, char ** options=None) → char **

osgeo.gdal.GetFileSystemOptions(char const * utf8_path) → char const *

osgeo.gdal.GetFileSystemsPrefixes() → char **

osgeo.gdal.GetGlobalConfigOption(char const * pszKey, char const * pszDefault=None) → char const *

osgeo.gdal.GetJPEG2000Structure(char const * pszFilename, char ** options=None) → CPLXMLNode *

osgeo.gdal.GetJPEG2000StructureAsString(char const * pszFilename, char ** options=None) → retStringAndCPLFree *

osgeo.gdal.GetLastErrorMsg() → char const *

osgeo.gdal.GetLastErrorNo() → int

osgeo.gdal.GetLastErrorType() → int

osgeo.gdal.GetNextDirEntry(VSIDIR * dir) → DirEntry

osgeo.gdal.GetNumCPUs() → int

osgeo.gdal.GetPaletteInterpretationName(GDALPaletteInterp ePaletteInterp) → char const *

osgeo.gdal.GetPathSpecificOption(char const * pszPathPrefix, char const * pszKey, char const * pszDefault=None) → char const *

osgeo.gdal.GetSignedURL(char const * utf8_path, char ** options=None) → retStringAndCPLFree *

osgeo.gdal.GetSubdatasetInfo(char const * pszFileName) → GDALSubdatasetInfoShadow *

osgeo.gdal.GetThreadLocalConfigOption(char const * pszKey, char const * pszDefault=None) → char const *

osgeo.gdal.GetUsablePhysicalRAM() → GIntBig

osgeo.gdal.GetUseExceptions() → int

osgeo.gdal.Grid(destName, srcDS, **kwargs)

  Create raster from the scattered data.

  Parameters:

    - destName -- Output dataset name

    - srcDS -- a Dataset object or a filename

    - kwargs -- options: return of gdal.GridOptions(), string or array of strings, other keywords arguments of gdal.GridOptions() If options is provided as a gdal.GridOptions() object, other keywords are ignored.

osgeo.gdal.GridInternal(char const * dest, Dataset dataset, GDALGridOptions options, GDALProgressFunc callback=0, void * callback_data=None) → Dataset

osgeo.gdal.GridOptions(options=None, format=None, outputType=0, width=0, height=0, creationOptions=None, outputBounds=None, outputSRS=None, noData=None, algorithm=None, layers=None, SQLStatement=None, where=None, spatFilter=None, zfield=None, z_increase=None, z_multiply=None, callback=None, callback_data=None)

  Create a GridOptions() object that can be passed to gdal.Grid()

  Parameters:

    - options -- can be be an array of strings, a string or let empty and filled from other keywords.

    - format -- output format ("GTiff", etc...)

    - outputType -- output type (gdalconst.GDT_Byte, etc...)

    - width -- width of the output raster in pixel

    - height -- height of the output raster in pixel

    - creationOptions -- list or dict of creation options

    - outputBounds -- assigned output bounds: [ulx, uly, lrx, lry]

    - outputSRS -- assigned output SRS

    - noData -- nodata value

    - 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"

    - layers -- list of layers to convert

    - SQLStatement -- SQL statement to apply to the source dataset

    - where -- WHERE clause to apply to source layer(s)

    - spatFilter -- spatial filter as (minX, minY, maxX, maxY) bounding box

    - 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.

    - 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.

    - 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.

    - callback -- callback method

    - callback_data -- user data for callback

class osgeo.gdal.Group(*args, **kwargs)

  Bases: `object`

  Proxy of C++ GDALGroupHS class.

  CreateAttribute(Group self, char const * name, int dimensions, ExtendedDataType data_type, char ** options=None) → Attribute
  CreateDimension(Group self, char const * name, char const * type, char const * direction, GUIntBig size, char ** options=None) → Dimension
  CreateGroup(Group self, char const * name, char ** options=None) → Group
  CreateMDArray(Group self, char const * name, int dimensions, ExtendedDataType data_type, char ** options=None) → MDArray
  DeleteAttribute(Group self, char const * name, char ** options=None) → CPLErr
  DeleteGroup(Group self, char const * name, char ** options=None) → CPLErr
  DeleteMDArray(Group self, char const * name, char ** options=None) → CPLErr
  GetAttribute(Group self, char const * name) → Attribute
  GetAttributes(Group self, char ** options=None)
  GetDimensions(Group self, char ** options=None)
  GetFullName(Group self) → char const *
  GetGroupNames(options=[]) → list[str]
  GetMDArrayNames(options=[]) → list[str]
  GetName(Group self) → char const *
  GetStructuralInfo(Group self) → char **
  GetVectorLayerNames(Group self, char ** options=None) → char **
  OpenGroup(Group self, char const * name, char ** options=None) → Group
  OpenGroupFromFullname(Group self, char const * name, char ** options=None) → Group
  OpenMDArray(Group self, char const * name, char ** options=None) → MDArray
  OpenMDArrayFromFullname(Group self, char const * name, char ** options=None) → MDArray
  OpenVectorLayer(Group self, char const * name, char ** options=None) → Layer
  Rename(Group self, char const * newName) → CPLErr
  ResolveMDArray(Group self, char const * name, char const * starting_point, char ** options=None) → MDArray
  SubsetDimensionFromSelection(Group self, char const * selection, char ** options=None) → Group
  property thisown

    The membership flag

osgeo.gdal.HasThreadSupport() → int

osgeo.gdal.HasTriangulation() → int

osgeo.gdal.IdentifyDriver(char const * utf8_path, char ** papszSiblings=None) → Driver

osgeo.gdal.IdentifyDriverEx(char const * utf8_path, unsigned int nIdentifyFlags=0, char ** allowed_drivers=None, char ** sibling_files=None) → Driver

osgeo.gdal.Info(ds, **kwargs)

  Return information on a raster dataset.

  Parameters:

    - ds -- a Dataset object or a filename

    - kwargs -- options: return of gdal.InfoOptions(), string or array of strings other keywords arguments of gdal.InfoOptions(). If options is provided as a gdal.InfoOptions() object, other keywords are ignored.

osgeo.gdal.InfoInternal(Dataset hDataset, GDALInfoOptions infoOptions) → retStringAndCPLFree *

osgeo.gdal.InfoOptions(options=None, format='text', deserialize=True, computeMinMax=False, reportHistograms=False, reportProj4=False, stats=False, approxStats=False, computeChecksum=False, showGCPs=True, showMetadata=True, showRAT=True, showColorTable=True, listMDD=False, showFileList=True, allMetadata=False, extraMDDomains=None, wktFormat=None)

  Create a InfoOptions() object that can be passed to gdal.Info() options can be be an array of strings, a string or let empty and filled from other keywords.

osgeo.gdal.InvGeoTransform(double [6] gt_in) → RETURN_NONE

class osgeo.gdal.MDArray(*args, **kwargs)

  Bases: `object`

  Proxy of C++ GDALMDArrayHS class.

  AdviseRead(array_start_idx=None, count=None, options=[])
  AsClassicDataset(MDArray self, size_t iXDim, size_t iYDim, Group hRootGroup=None, char ** options=None) → Dataset
  Cache(MDArray self, char ** options=None) → bool
  ComputeStatistics(MDArray self, bool approx_ok=FALSE, GDALProgressFunc callback=0, void * callback_data=None, char ** options=None) → Statistics
  CreateAttribute(MDArray self, char const * name, int dimensions, ExtendedDataType data_type, char ** options=None) → Attribute
  DeleteAttribute(MDArray self, char const * name, char ** options=None) → CPLErr
  DeleteNoDataValue(MDArray self) → CPLErr
  GetAttribute(MDArray self, char const * name) → Attribute
  GetAttributes(MDArray self, char ** options=None)
  GetBlockSize(MDArray self)
  GetCoordinateVariables(MDArray self)
  GetDataType(MDArray self) → ExtendedDataType
  GetDimensionCount(MDArray self) → size_t
  GetDimensions(MDArray self)
  GetFullName(MDArray self) → char const *
  GetGridded(MDArray self, char const * pszGridOptions, MDArray xArray=None, MDArray yArray=None, char ** options=None) → MDArray
  GetMask(MDArray self, char ** options=None) → MDArray
  GetName(MDArray self) → char const *
  GetNoDataValue(MDArray self) → value
  GetNoDataValueAsDouble(MDArray self)
  GetNoDataValueAsInt64(MDArray self)
  GetNoDataValueAsRaw(MDArray self) → CPLErr
  GetNoDataValueAsString(MDArray self) → retStringAndCPLFree *
  GetNoDataValueAsUInt64(MDArray self)
  GetOffset(MDArray self)
  GetOffsetStorageType(MDArray self) → GDALDataType
  GetProcessingChunkSize(MDArray self, size_t nMaxChunkMemory)
  GetResampled(MDArray self, int nDimensions, GDALRIOResampleAlg resample_alg, OSRSpatialReferenceShadow ** srs, char ** options=None) → MDArray
  GetScale(MDArray self)
  GetScaleStorageType(MDArray self) → GDALDataType
  GetShape()

    Return the shape of the array

  GetSpatialRef(MDArray self) → SpatialReference
  GetStatistics(MDArray self, bool approx_ok=FALSE, bool force=TRUE, GDALProgressFunc callback=0, void * callback_data=None) → Statistics
  GetStructuralInfo(MDArray self) → char **
  GetTotalElementsCount(MDArray self) → GUIntBig
  GetUnit(MDArray self) → char const *
  GetUnscaled(MDArray self) → MDArray
  GetView(MDArray self, char const * viewExpr) → MDArray
  Read(array_start_idx=None, count=None, array_step=None, buffer_stride=None, buffer_datatype=None)
  ReadAsArray(array_start_idx=None, count=None, array_step=None, buffer_datatype=None, buf_obj=None)
  ReadAsMaskedArray(array_start_idx=None, count=None, array_step=None)

    Return a numpy masked array of ReadAsArray() with GetMask()

  Rename(MDArray self, char const * newName) → CPLErr
  Resize(MDArray self, int newDimensions, char ** options=None) → CPLErr
  SetNoDataValue(MDArray self, value) → CPLErr
  SetNoDataValueDouble(MDArray self, double d) → CPLErr
  SetNoDataValueInt64(MDArray self, GIntBig v) → CPLErr
  SetNoDataValueRaw(MDArray self, GIntBig nLen) → CPLErr
  SetNoDataValueString(MDArray self, char const * nodata) → CPLErr
  SetNoDataValueUInt64(MDArray self, GUIntBig v) → CPLErr
  SetOffset(MDArray self, double val, GDALDataType storageType=GDT_Unknown) → CPLErr
  SetScale(MDArray self, double val, GDALDataType storageType=GDT_Unknown) → CPLErr
  SetSpatialRef(MDArray self, SpatialReference srs) → OGRErr
  SetUnit(MDArray self, char const * unit) → CPLErr
  Transpose(MDArray self, int axisMap) → MDArray
  Write(buffer, array_start_idx=None, count=None, array_step=None, buffer_stride=None, buffer_datatype=None)
  WriteArray(array, array_start_idx=None, array_step=None)
  WriteStringArray(MDArray self, int nDims1, int nDims2, int nDims3, ExtendedDataType buffer_datatype, char ** options) → CPLErr
  property shape

    Returns the shape of the array.

  property thisown

    The membership flag

class osgeo.gdal.MajorObject(*args, **kwargs)

  Bases: `object`

  Proxy of C++ GDALMajorObjectShadow class.

  GetDescription(MajorObject self) → char const *
  GetMetadata(domain='')
  GetMetadataDomainList(MajorObject self) → char **
  GetMetadataItem(MajorObject self, char const * pszName, char const * pszDomain="") → char const *
  GetMetadata_Dict(MajorObject self, char const * pszDomain="") → char **
  GetMetadata_List(MajorObject self, char const * pszDomain="") → char **
  SetDescription(MajorObject self, char const * pszNewDesc)
  SetMetadata(MajorObject self, char ** papszMetadata, char const * pszDomain="") → CPLErr
  SetMetadata(MajorObject self, char * pszMetadataString, char const * pszDomain="") → CPLErr
  SetMetadataItem(MajorObject self, char const * pszName, char const * pszValue, char const * pszDomain="") → CPLErr
  property thisown

    The membership flag

osgeo.gdal.Mkdir(char const * utf8_path, int mode) → VSI_RETVAL

osgeo.gdal.MkdirRecursive(char const * utf8_path, int mode) → VSI_RETVAL

osgeo.gdal.MultiDimInfo(ds, **kwargs)

  Return information on a dataset.

  Parameters:

    - ds -- a Dataset object or a filename

    - kwargs -- options: return of gdal.MultiDimInfoOptions(), string or array of strings other keywords arguments of gdal.MultiDimInfoOptions(). If options is provided as a gdal.MultiDimInfoOptions() object, other keywords are ignored.

osgeo.gdal.MultiDimInfoInternal(Dataset hDataset, GDALMultiDimInfoOptions infoOptions) → retStringAndCPLFree *

osgeo.gdal.MultiDimInfoOptions(options=None, detailed=False, array=None, arrayoptions=None, limit=None, as_text=False)

  Create a MultiDimInfoOptions() object that can be passed to gdal.MultiDimInfo() options can be be an array of strings, a string or let empty and filled from other keywords.

osgeo.gdal.MultiDimTranslate(destName, srcDSOrSrcDSTab, **kwargs)

  MultiDimTranslate one or several datasets.

  Parameters:

    - destName -- Output dataset name

    - srcDSOrSrcDSTab -- an array of Dataset objects or filenames, or a Dataset object or a filename

    - kwargs -- options: return of gdal.MultiDimTranslateOptions(), string or array of strings other keywords arguments of gdal.MultiDimTranslateOptions(). If options is provided as a gdal.MultiDimTranslateOptions() object, other keywords are ignored.

osgeo.gdal.MultiDimTranslateOptions(options=None, format=None, creationOptions=None, arraySpecs=None, groupSpecs=None, subsetSpecs=None, scaleAxesSpecs=None, callback=None, callback_data=None)

  Create a MultiDimTranslateOptions() object that can be passed to gdal.MultiDimTranslate()

  Parameters:

    - options -- can be be an array of strings, a string or let empty and filled from other keywords.

    - format -- output format ("GTiff", etc...)

    - creationOptions -- list or dict of creation options

    - arraySpecs -- list of array specifications, each of them being an array name or "name={src_array_name},dstname={dst_name},transpose=[1,0],view=[:,::-1]"

    - groupSpecs -- list of group specifications, each of them being a group name or "name={src_array_name},dstname={dst_name},recursive=no"

    - subsetSpecs -- list of subset specifications, each of them being like "{dim_name}({min_val},{max_val})" or "{dim_name}({slice_va})"

    - scaleAxesSpecs -- list of dimension scaling specifications, each of them being like "{dim_name}({scale_factor})"

    - callback -- callback method

    - callback_data -- user data for callback

osgeo.gdal.Nearblack(destNameOrDestDS, srcDS, **kwargs)

  Convert nearly black/white borders to exact value.

  Parameters:

    - destNameOrDestDS -- Output dataset name or object

    - srcDS -- a Dataset object or a filename

    - kwargs -- options: return of gdal.NearblackOptions(), string or array of strings, other keywords arguments of gdal.NearblackOptions(). If options is provided as a gdal.NearblackOptions() object, other keywords are ignored.

osgeo.gdal.NearblackOptions(options=None, format=None, creationOptions=None, white=False, colors=None, maxNonBlack=None, nearDist=None, setAlpha=False, setMask=False, alg=None, callback=None, callback_data=None)

  Create a NearblackOptions() object that can be passed to gdal.Nearblack()

  Parameters:

    - options -- can be be an array of strings, a string or let empty and filled from other keywords.

    - format -- output format ("GTiff", etc...)

    - creationOptions -- list or dict of creation options

    - white -- whether to search for nearly white (255) pixels instead of nearly black pixels.

    - 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

    - 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.

    - 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.

    - setAlpha -- adds an alpha band to the output file.

    - setMask -- adds a mask band to the output file.

    - alg -- "twopasses" (default), or "floodfill"

    - callback -- callback method

    - callback_data -- user data for callback

osgeo.gdal.NetworkStatsGetAsSerializedJSON(char ** options=None) → retStringAndCPLFree *

osgeo.gdal.NetworkStatsReset()

osgeo.gdal.Open(char const * utf8_path, GDALAccess eAccess=GA_ReadOnly) → Dataset

osgeo.gdal.OpenDir(char const * utf8_path, int nRecurseDepth=-1, char ** options=None) → VSIDIR *

osgeo.gdal.OpenEx(char const * utf8_path, unsigned int nOpenFlags=0, char ** allowed_drivers=None, char ** open_options=None, char ** sibling_files=None) → Dataset

osgeo.gdal.OpenShared(char const * utf8_path, GDALAccess eAccess=GA_ReadOnly) → Dataset

osgeo.gdal.PackedDMSToDec(double dfPacked) → double

osgeo.gdal.ParseCommandLine(char const * utf8_path) → char **

osgeo.gdal.ParseXMLString(char * pszXMLString) → CPLXMLNode *

osgeo.gdal.Polygonize(Band srcBand, Band maskBand, Layer outLayer, int iPixValField, char ** options=None, GDALProgressFunc callback=0, void * callback_data=None) → int

osgeo.gdal.PopErrorHandler()

osgeo.gdal.PopFinderLocation()

osgeo.gdal.PushErrorHandler(CPLErrorHandler pfnErrorHandler=0) → CPLErr

osgeo.gdal.PushFinderLocation(char const * utf8_path)

osgeo.gdal.RGBFile2PCTFile(src_filename, dst_filename)

class osgeo.gdal.RasterAttributeTable(*args)

  Bases: `object`

  Proxy of C++ GDALRasterAttributeTableShadow class.

  ChangesAreWrittenToFile(RasterAttributeTable self) → int
  Clone(RasterAttributeTable self) → RasterAttributeTable
  CreateColumn(RasterAttributeTable self, char const * pszName, GDALRATFieldType eType, GDALRATFieldUsage eUsage) → int
  DumpReadable(RasterAttributeTable self)
  GetColOfUsage(RasterAttributeTable self, GDALRATFieldUsage eUsage) → int
  GetColumnCount(RasterAttributeTable self) → int
  GetLinearBinning(RasterAttributeTable self) → bool
  GetNameOfCol(RasterAttributeTable self, int iCol) → char const *
  GetRowCount(RasterAttributeTable self) → int
  GetRowOfValue(RasterAttributeTable self, double dfValue) → int
  GetTableType(RasterAttributeTable self) → GDALRATTableType
  GetTypeOfCol(RasterAttributeTable self, int iCol) → GDALRATFieldType
  GetUsageOfCol(RasterAttributeTable self, int iCol) → GDALRATFieldUsage
  GetValueAsDouble(RasterAttributeTable self, int iRow, int iCol) → double
  GetValueAsInt(RasterAttributeTable self, int iRow, int iCol) → int
  GetValueAsString(RasterAttributeTable self, int iRow, int iCol) → char const *
  ReadAsArray(field, start=0, length=None)
  SetLinearBinning(RasterAttributeTable self, double dfRow0Min, double dfBinSize) → int
  SetRowCount(RasterAttributeTable self, int nCount)
  SetTableType(RasterAttributeTable self, GDALRATTableType eTableType)
  SetValueAsDouble(RasterAttributeTable self, int iRow, int iCol, double dfValue)
  SetValueAsInt(RasterAttributeTable self, int iRow, int iCol, int nValue)
  SetValueAsString(RasterAttributeTable self, int iRow, int iCol, char const * pszValue)
  WriteArray(array, field, start=0)
  property thisown

    The membership flag

osgeo.gdal.Rasterize(destNameOrDestDS, srcDS, **kwargs)

  Burns vector geometries into a raster

  Parameters:

    - destNameOrDestDS -- Output dataset name or object

    - srcDS -- a Dataset object or a filename

    - kwargs -- options: return of gdal.RasterizeOptions(), string or array of strings, other keywords arguments of gdal.RasterizeOptions() If options is provided as a gdal.RasterizeOptions() object, other keywords are ignored.

osgeo.gdal.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

osgeo.gdal.RasterizeOptions(options=None, format=None, outputType=0, creationOptions=None, noData=None, initValues=None, outputBounds=None, outputSRS=None, transformerOptions=None, width=None, height=None, xRes=None, yRes=None, targetAlignedPixels=False, bands=None, inverse=False, allTouched=False, burnValues=None, attribute=None, useZ=False, layers=None, SQLStatement=None, SQLDialect=None, where=None, optim=None, add=None, callback=None, callback_data=None)

  Create a RasterizeOptions() object that can be passed to gdal.Rasterize()

  Parameters:

    - options -- can be be an array of strings, a string or let empty and filled from other keywords.

    - format -- output format ("GTiff", etc...)

    - outputType -- output type (gdalconst.GDT_Byte, etc...)

    - creationOptions -- list or dict of creation options

    - outputBounds -- assigned output bounds: [minx, miny, maxx, maxy]

    - outputSRS -- assigned output SRS

    - transformerOptions -- list or dict of transformer options

    - width -- width of the output raster in pixel

    - height -- height of the output raster in pixel

    - xRes -- output resolution in target SRS

    - yRes -- output resolution in target SRS

    - targetAlignedPixels -- whether to force output bounds to be multiple of output resolution

    - noData -- nodata value

    - 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.

    - bands -- list of output bands to burn values into

    - 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.

    - 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.

    - burnValues -- list of fixed values to burn into each band for all objects. Excusive with attribute.

    - 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.

    - 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.

    - layers -- list of layers from the datasource that will be used for input features.

    - SQLStatement -- SQL statement to apply to the source dataset

    - SQLDialect -- SQL dialect ('OGRSQL', 'SQLITE', ...)

    - where -- WHERE clause to apply to source layer(s)

    - optim -- optimization mode ('RASTER', 'VECTOR')

    - add -- set to True to use additive mode instead of replace when burning values

    - callback -- callback method

    - callback_data -- user data for callback

osgeo.gdal.ReadDir(char const * utf8_path, int nMaxFiles=0) → char **

osgeo.gdal.ReadDirRecursive(char const * utf8_path) → char **

osgeo.gdal.RegenerateOverview(Band srcBand, Band overviewBand, char const * resampling="average", GDALProgressFunc callback=0, void * callback_data=None) → int

osgeo.gdal.RegenerateOverviews(Band srcBand, int overviewBandCount, char const * resampling="average", GDALProgressFunc callback=0, void * callback_data=None) → int

class osgeo.gdal.Relationship(*args)

  Bases: `object`

  Proxy of C++ GDALRelationshipShadow class.

  GetBackwardPathLabel(Relationship self) → char const *
  GetCardinality(Relationship self) → GDALRelationshipCardinality
  GetForwardPathLabel(Relationship self) → char const *
  GetLeftMappingTableFields(Relationship self) → char **
  GetLeftTableFields(Relationship self) → char **
  GetLeftTableName(Relationship self) → char const *
  GetMappingTableName(Relationship self) → char const *
  GetName(Relationship self) → char const *
  GetRelatedTableType(Relationship self) → char const *
  GetRightMappingTableFields(Relationship self) → char **
  GetRightTableFields(Relationship self) → char **
  GetRightTableName(Relationship self) → char const *
  GetType(Relationship self) → GDALRelationshipType
  SetBackwardPathLabel(Relationship self, char const * pszLabel)
  SetForwardPathLabel(Relationship self, char const * pszLabel)
  SetLeftMappingTableFields(Relationship self, char ** pFields)
  SetLeftTableFields(Relationship self, char ** pFields)
  SetMappingTableName(Relationship self, char const * pszName)
  SetRelatedTableType(Relationship self, char const * pszType)
  SetRightMappingTableFields(Relationship self, char ** pFields)
  SetRightTableFields(Relationship self, char ** pFields)
  SetType(Relationship self, GDALRelationshipType type)
  property thisown

    The membership flag

osgeo.gdal.Rename(char const * pszOld, char const * pszNew) → VSI_RETVAL

osgeo.gdal.ReprojectImage(Dataset src_ds, Dataset dst_ds, char const * src_wkt=None, char const * dst_wkt=None, GDALResampleAlg eResampleAlg=GRA_NearestNeighbour, double WarpMemoryLimit=0.0, double maxerror=0.0, GDALProgressFunc callback=0, void * callback_data=None, char ** options=None) → CPLErr

osgeo.gdal.Rmdir(char const * utf8_path) → VSI_RETVAL

osgeo.gdal.RmdirRecursive(char const * utf8_path) → VSI_RETVAL

osgeo.gdal.SerializeXMLTree(CPLXMLNode * xmlnode) → retStringAndCPLFree *

osgeo.gdal.SetCacheMax(GIntBig nBytes)

osgeo.gdal.SetConfigOption(char const * pszKey, char const * pszValue)

osgeo.gdal.SetCredential(char const * pszPathPrefix, char const * pszKey, char const * pszValue)

osgeo.gdal.SetCurrentErrorHandlerCatchDebug(int bCatchDebug)

osgeo.gdal.SetErrorHandler(CPLErrorHandler pfnErrorHandler=0) → CPLErr

osgeo.gdal.SetFileMetadata(char const * utf8_path, char ** metadata, char const * domain, char ** options=None) → bool

osgeo.gdal.SetPathSpecificOption(char const * pszPathPrefix, char const * pszKey, char const * pszValue)

osgeo.gdal.SetThreadLocalConfigOption(char const * pszKey, char const * pszValue)

osgeo.gdal.SieveFilter(Band srcBand, Band maskBand, Band dstBand, int threshold, int connectedness=4, char ** options=None, GDALProgressFunc callback=0, void * callback_data=None) → int

class osgeo.gdal.StatBuf(*args)

  Bases: `object`

  Proxy of C++ StatBuf class.

  IsDirectory(StatBuf self) → int
  property mode

    int

    Type:

      mode

  property mtime

    GIntBig

    Type:

      mtime

  property size

    GIntBig

    Type:

      size

  property thisown

    The membership flag

class osgeo.gdal.Statistics(*args)

  Bases: `object`

  Proxy of C++ Statistics class.

  property max

    double

    Type:

      max

  property mean

    double

    Type:

      mean

  property min

    double

    Type:

      min

  property std_dev

    double

    Type:

      std_dev

  property thisown

    The membership flag

  property valid_count

    GIntBig

    Type:

      valid_count

class osgeo.gdal.SubdatasetInfo(*args, **kwargs)

  Bases: `object`

  Proxy of C++ GDALSubdatasetInfoShadow class.

  GetPathComponent(SubdatasetInfo self) → retStringAndCPLFree *
  GetSubdatasetComponent(SubdatasetInfo self) → retStringAndCPLFree *
  ModifyPathComponent(SubdatasetInfo self, char const * pszNewFileName) → retStringAndCPLFree *
  property thisown

    The membership flag

osgeo.gdal.SuggestedWarpOutput(*args)

  Suggest output dataset size and extent.

  SuggestedWarpOutput(src: Dataset, transformer: Transformer) -> SuggestedWarpOutputRes SuggestedWarpOutput(src: Dataset, options: list[str]) -> SuggestedWarpOutputRes

  This function is used to suggest the size, and georeferenced extents appropriate given the indicated transformation and input file. It walks the edges of the input file (approximately 20 sample points along each edge) transforming into output coordinates in order to get an extents box.

  Then a resolution is computed with the intent that the length of the distance from the top left corner of the output imagery to the bottom right corner would represent the same number of pixels as in the source image. Note that if the image is somewhat rotated the diagonal taken isn't of the whole output bounding rectangle, but instead of the locations where the top/left and bottom/right corners transform. The output pixel size is always square. This is intended to approximately preserve the resolution of the input data in the output file.

  There are 2 forms of this method:

  - one that takes the output of gdal.Transformer(src, dst, options) as the second argument. The src argument of the gdal.Transformer() call should nominally be the src argument passed to this function. The dst argument of the gdal.Transformer() call should nominally be None The third argument of the gdal.Transformer() call should be a list of strings, that are transforming options accepted by `GDALCreateGenImgProjTransformer2()` (e.g `DST_SRS`)

  - one that takes a list of strings as the second argument. Those strings are the transforming options accepted by `GDALCreateGenImgProjTransformer2()` (e.g `DST_SRS`)

  Parameters:

    - src (Dataset) -- Source dataset

    - transformer (Transformer) -- The return value of gdal.Transformer(src, None, options) (exclusive with below options parameter)

    - options (list[str]) -- List of strings that are the transforming options accepted by `GDALCreateGenImgProjTransformer2()` (e.g `DST_SRS`) (exclusive with above transformer parameter)

  Returns:

    - A SuggestedWarpOutputRes class instance with the following members

    - - width (number of pixels in width of the output dataset)

    - - height (number of pixels in height of the output dataset)

    - - xmin (minimum value of the georeferenced X coordinates)

    - - ymin (maximum value of the georeferenced Y coordinates)

    - - xmax (minimum value of the georeferenced X coordinates)

    - - ymax (maximum value of the georeferenced Y coordinates)

    - - geotransform (affine geotransformation matrix (6 values))

  Example

      >>> ds = gdal.Open("my.tif")
      ... res = gdal.SuggestedWarpOutput(ds, ["DST_SRS=EPSG:4326"])
      ... print(res.width, res.height, res.xmin, res.ymin, res.xmax, res.ymax, res.geotransform)

osgeo.gdal.SuggestedWarpOutputFromOptions(Dataset src, char ** options) → SuggestedWarpOutputRes

osgeo.gdal.SuggestedWarpOutputFromTransformer(Dataset src, GDALTransformerInfoShadow transformer) → SuggestedWarpOutputRes

class osgeo.gdal.SuggestedWarpOutputRes(*args, **kwargs)

  Bases: `object`

  Proxy of C++ SuggestedWarpOutputRes class.

  GetGeotransform(SuggestedWarpOutputRes self)
  property geotransform

    double[6]

    Type:

      geotransform

  property height

    int

    Type:

      height

  property thisown

    The membership flag

  property width

    int

    Type:

      width

  property xmax

    double

    Type:

      xmax

  property xmin

    double

    Type:

      xmin

  property ymax

    double

    Type:

      ymax

  property ymin

    double

    Type:

      ymin

osgeo.gdal.Sync(char const * pszSource, char const * pszTarget, char ** options=None, GDALProgressFunc callback=0, void * callback_data=None) → bool

osgeo.gdal.TermProgress_nocb(double dfProgress, char const * pszMessage=None, void * pData=None) → int

osgeo.gdal.Transformer(Dataset src, Dataset dst, char ** options) → GDALTransformerInfoShadow

osgeo.gdal.Translate(destName, srcDS, **kwargs)

  Convert a dataset.

  Parameters:

    - destName -- Output dataset name

    - srcDS -- a Dataset object or a filename

    - kwargs -- options: return of gdal.TranslateOptions(), string or array of strings other keywords arguments of gdal.TranslateOptions(). If options is provided as a gdal.TranslateOptions() object, other keywords are ignored.

osgeo.gdal.TranslateInternal(char const * dest, Dataset dataset, GDALTranslateOptions translateOptions, GDALProgressFunc callback=0, void * callback_data=None) → Dataset

osgeo.gdal.TranslateOptions(options=None, format=None, outputType=0, bandList=None, maskBand=None, width=0, height=0, widthPct=0.0, heightPct=0.0, xRes=0.0, yRes=0.0, creationOptions=None, srcWin=None, projWin=None, projWinSRS=None, strict=False, unscale=False, scaleParams=None, exponents=None, outputBounds=None, outputGeotransform=None, metadataOptions=None, outputSRS=None, nogcp=False, GCPs=None, noData=None, rgbExpand=None, stats=False, rat=True, xmp=True, resampleAlg=None, overviewLevel='AUTO', callback=None, callback_data=None)

  Create a TranslateOptions() object that can be passed to gdal.Translate()

  Parameters:

    - options -- can be be an array of strings, a string or let empty and filled from other keywords.

    - format -- output format ("GTiff", etc...)

    - outputType -- output type (gdalconst.GDT_Byte, etc...)

    - bandList -- array of band numbers (index start at 1)

    - maskBand -- mask band to generate or not ("none", "auto", "mask", 1, ...)

    - width -- width of the output raster in pixel

    - height -- height of the output raster in pixel

    - widthPct -- width of the output raster in percentage (100 = original width)

    - heightPct -- height of the output raster in percentage (100 = original height)

    - xRes -- output horizontal resolution

    - yRes -- output vertical resolution

    - creationOptions -- list or dict of creation options

    - srcWin -- subwindow in pixels to extract: [left_x, top_y, width, height]

    - projWin -- subwindow in projected coordinates to extract: [ulx, uly, lrx, lry]

    - projWinSRS -- SRS in which projWin is expressed

    - strict -- strict mode

    - unscale -- unscale values with scale and offset metadata

    - scaleParams -- list of scale parameters, each of the form [src_min,src_max] or [src_min,src_max,dst_min,dst_max]

    - exponents -- list of exponentiation parameters

    - outputBounds -- assigned output bounds: [ulx, uly, lrx, lry]

    - outputGeotransform -- assigned geotransform matrix (array of 6 values) (mutually exclusive with outputBounds)

    - metadataOptions -- list or dict of metadata options

    - outputSRS -- assigned output SRS

    - nogcp -- ignore GCP in the raster

    - GCPs -- list of GCPs

    - noData -- nodata value (or "none" to unset it)

    - rgbExpand -- Color palette expansion mode: "gray", "rgb", "rgba"

    - stats -- whether to calculate statistics

    - rat -- whether to write source RAT

    - xmp -- whether to copy XMP metadata

    - resampleAlg -- resampling mode

    - overviewLevel -- To specify which overview level of source files must be used

    - callback -- callback method

    - callback_data -- user data for callback

osgeo.gdal.Unlink(char const * utf8_path) → VSI_RETVAL

osgeo.gdal.UnlinkBatch(char ** files) → bool

osgeo.gdal.UseExceptions()

  Enable exceptions in all GDAL related modules (osgeo.gdal, osgeo.ogr, osgeo.osr, osgeo.gnm). Note: prior to GDAL 3.7, this only affected the calling module

osgeo.gdal.VSICurlClearCache()

osgeo.gdal.VSICurlPartialClearCache(char const * utf8_path)

osgeo.gdal.VSIErrorReset()

osgeo.gdal.VSIFCloseL(VSILFILE fp) → VSI_RETVAL

osgeo.gdal.VSIFEofL(VSILFILE fp) → int

osgeo.gdal.VSIFFlushL(VSILFILE fp) → int

osgeo.gdal.VSIFGetRangeStatusL(VSILFILE fp, GIntBig offset, GIntBig length) → int

osgeo.gdal.VSIFOpenExL(char const * utf8_path, char const * pszMode, int bSetError=FALSE, char ** options=None) → VSILFILE

osgeo.gdal.VSIFOpenL(char const * utf8_path, char const * pszMode) → VSILFILE

osgeo.gdal.VSIFReadL(unsigned int nMembSize, unsigned int nMembCount, VSILFILE fp) → unsigned int

osgeo.gdal.VSIFSeekL(VSILFILE fp, GIntBig offset, int whence) → int

osgeo.gdal.VSIFTellL(VSILFILE fp) → GIntBig

osgeo.gdal.VSIFTruncateL(VSILFILE fp, GIntBig length) → int

osgeo.gdal.VSIFWriteL(int nLen, int size, int memb, VSILFILE fp) → int

osgeo.gdal.VSIGetLastErrorMsg() → char const *

osgeo.gdal.VSIGetLastErrorNo() → int

osgeo.gdal.VSIGetMemFileBuffer_unsafe(char const * utf8_path)

class osgeo.gdal.VSILFILE(*args, **kwargs)

  Bases: `object`

  Proxy of C++ VSILFILE class.

  property thisown

    The membership flag

osgeo.gdal.VSIStatL(char const * utf8_path, int nFlags=0) → int

osgeo.gdal.VSISupportsSparseFiles(char const * utf8_path) → int

osgeo.gdal.VectorInfo(ds, **kwargs)

  Return information on a vector dataset.

  Parameters:

    - ds -- a Dataset object or a filename

    - kwargs -- options: return of gdal.VectorInfoOptions(), string or array of strings other keywords arguments of gdal.VectorInfoOptions(). If options is provided as a gdal.VectorInfoOptions() object, other keywords are ignored.

osgeo.gdal.VectorInfoInternal(Dataset hDataset, GDALVectorInfoOptions infoOptions) → retStringAndCPLFree *

osgeo.gdal.VectorInfoOptions(options=None, format='text', deserialize=True, layers=None, dumpFeatures=False, featureCount=True, extent=True, SQLStatement=None, SQLDialect=None, where=None, wktFormat=None)

  Create a VectorInfoOptions() object that can be passed to gdal.VectorInfo() options can be be an array of strings, a string or let empty and filled from other keywords.

  Parameters:

    - options -- can be be an array of strings, a string or let empty and filled from other keywords.

    - format -- "text" or "json"

    - deserialize -- if JSON output should be returned as a Python dictionary. Otherwise as a serialized representation.

    - SQLStatement -- SQL statement to apply to the source dataset

    - SQLDialect -- SQL dialect ('OGRSQL', 'SQLITE', ...)

    - where -- WHERE clause to apply to source layer(s)

    - layers -- list of layers of interest

    - featureCount -- whether to compute and display the feature count

    - extent -- whether to compute and display the layer extent

    - dumpFeatures -- set to True to get the dump of all features

osgeo.gdal.VectorTranslate(destNameOrDestDS, srcDS, **kwargs)

  Convert one vector dataset

  Parameters:

    - destNameOrDestDS -- Output dataset name or object

    - srcDS -- a Dataset object or a filename

    - kwargs -- options: return of gdal.VectorTranslateOptions(), string or array of strings, other keywords arguments of gdal.VectorTranslateOptions(). If options is provided as a gdal.VectorTranslateOptions() object, other keywords are ignored.

osgeo.gdal.VectorTranslateOptions(options=None, format=None, accessMode=None, srcSRS=None, dstSRS=None, reproject=True, coordinateOperation=None, SQLStatement=None, SQLDialect=None, where=None, selectFields=None, addFields=False, forceNullable=False, emptyStrAsNull=False, spatFilter=None, spatSRS=None, datasetCreationOptions=None, layerCreationOptions=None, layers=None, layerName=None, geometryType=None, dim=None, transactionSize=None, clipSrc=None, clipSrcSQL=None, clipSrcLayer=None, clipSrcWhere=None, clipDst=None, clipDstSQL=None, clipDstLayer=None, clipDstWhere=None, preserveFID=False, simplifyTolerance=None, segmentizeMaxDist=None, makeValid=False, mapFieldType=None, explodeCollections=False, zField=None, resolveDomains=False, skipFailures=False, limit=None, callback=None, callback_data=None)

  Create a VectorTranslateOptions() object that can be passed to gdal.VectorTranslate()

  Parameters:

    - options -- can be be an array of strings, a string or let empty and filled from other keywords.

    - format -- format ("ESRI Shapefile", etc...)

    - accessMode -- None for creation, 'update', 'append', 'upsert', 'overwrite'

    - srcSRS -- source SRS

    - dstSRS -- output SRS (with reprojection if reproject = True)

    - coordinateOperation -- coordinate operation as a PROJ string or WKT string

    - reproject -- whether to do reprojection

    - SQLStatement -- SQL statement to apply to the source dataset

    - SQLDialect -- SQL dialect ('OGRSQL', 'SQLITE', ...)

    - where -- WHERE clause to apply to source layer(s)

    - selectFields -- list of fields to select

    - addFields -- whether to add new fields found in source layers (to be used with accessMode == 'append' or 'upsert')

    - forceNullable -- whether to drop NOT NULL constraints on newly created fields

    - emptyStrAsNull -- whether to treat empty string values as NULL

    - spatFilter -- spatial filter as (minX, minY, maxX, maxY) bounding box

    - spatSRS -- SRS in which the spatFilter is expressed. If not specified, it is assumed to be the one of the layer(s)

    - datasetCreationOptions -- list or dict of dataset creation options

    - layerCreationOptions -- list or dict of layer creation options

    - layers -- list of layers to convert

    - layerName -- output layer name

    - geometryType -- output layer geometry type ('POINT', ....). May be an array of strings when using a special value like 'PROMOTE_TO_MULTI', 'CONVERT_TO_LINEAR', 'CONVERT_TO_CURVE' combined with another one or a geometry type.

    - dim -- output dimension ('XY', 'XYZ', 'XYM', 'XYZM', 'layer_dim')

    - transactionSize -- number of features to save per transaction (default 100 000). Increase the value for better performance when writing into DBMS drivers that have transaction support. Set to "unlimited" to load the data into a single transaction.

    - clipSrc -- clip geometries to the specified bounding box (expressed in source SRS), WKT geometry (POLYGON or MULTIPOLYGON), from a datasource or to the spatial extent of the -spat option if you use the "spat_extent" keyword. When specifying a datasource, you will generally want to use it in combination with the clipSrcLayer, clipSrcWhere or clipSrcSQL options.

    - clipSrcSQL -- select desired geometries using an SQL query instead.

    - clipSrcLayer -- select the named layer from the source clip datasource.

    - clipSrcWhere -- restrict desired geometries based on attribute query.

    - clipDst -- clip geometries after reprojection to the specified bounding box (expressed in dest SRS), WKT geometry (POLYGON or MULTIPOLYGON) or from a datasource. When specifying a datasource, you will generally want to use it in combination of the clipDstLayer, clipDstWhere or clipDstSQL options.

    - clipDstSQL -- select desired geometries using an SQL query instead.

    - clipDstLayer -- select the named layer from the destination clip datasource.

    - clipDstWhere -- restrict desired geometries based on attribute query.

    - simplifyTolerance -- distance tolerance for simplification. The algorithm used preserves topology per feature, in particular for polygon geometries, but not for a whole layer.

    - segmentizeMaxDist -- maximum distance between consecutive nodes of a line geometry

    - makeValid -- run MakeValid() on geometries

    - mapFieldType -- converts any field of the specified type to another type. Valid types are: Integer, Integer64, Real, String, Date, Time, DateTime, Binary, IntegerList, Integer64List, RealList, StringList. Types can also include subtype between parenthesis, such as Integer(Boolean), Real(Float32),... Special value All can be used to convert all fields to another type. This is an alternate way to using the CAST operator of OGR SQL, that may avoid typing a long SQL query. Note that this does not influence the field types used by the source driver, and is only an afterwards conversion.

    - explodeCollections -- produce one feature for each geometry in any kind of geometry collection in the source file, applied after any -sql option. This option is not compatible with preserveFID but a SQLStatement (e.g. SELECT fid AS original_fid, * FROM ...) can be used to store the original FID if needed.

    - preserveFID -- Use the FID of the source features instead of letting the output driver automatically assign a new one (for formats that require a FID). If not in append mode, this behavior is the default if the output driver has a FID layer creation option, in which case the name of the source FID column will be used and source feature IDs will be attempted to be preserved. This behavior can be disabled by setting -unsetFid. This option is not compatible with explodeCollections

    - zField -- name of field to use to set the Z component of geometries

    - resolveDomains -- whether to create an additional field for each field associated with a coded field domain.

    - skipFailures -- whether to skip failures

    - limit -- maximum number of features to read per layer

    - callback -- callback method

    - callback_data -- user data for callback

osgeo.gdal.VersionInfo(char const * request="VERSION_NUM") → char const *

osgeo.gdal.ViewshedGenerate(Band srcBand, char const * driverName, char const * targetRasterName, char ** creationOptions, double observerX, double observerY, double observerHeight, double targetHeight, double visibleVal, double invisibleVal, double outOfRangeVal, double noDataVal, double dfCurvCoeff, GDALViewshedMode mode, double maxDistance, GDALProgressFunc callback=0, void * callback_data=None, GDALViewshedOutputType heightMode=GVOT_NORMAL, char ** options=None) → Dataset

class osgeo.gdal.VirtualMem(*args, **kwargs)

  Bases: `object`

  Proxy of C++ CPLVirtualMemShadow class.

  GetAddr(VirtualMem self)
  Pin(VirtualMem self, size_t start_offset=0, size_t nsize=0, int bWriteOp=0)
  property thisown

    The membership flag

osgeo.gdal.Warp(destNameOrDestDS, srcDSOrSrcDSTab, **kwargs)

  Warp one or several datasets.

  Parameters:

    - destNameOrDestDS -- Output dataset name or object

    - srcDSOrSrcDSTab -- an array of Dataset objects or filenames, or a Dataset object or a filename

    - kwargs -- options: return of gdal.WarpOptions(), string or array of strings, other keywords arguments of gdal.WarpOptions(). If options is provided as a gdal.WarpOptions() object, other keywords are ignored.

osgeo.gdal.WarpOptions(options=None, format=None, srcBands=None, dstBands=None, outputBounds=None, outputBoundsSRS=None, xRes=None, yRes=None, targetAlignedPixels=False, width=0, height=0, srcSRS=None, dstSRS=None, coordinateOperation=None, srcAlpha=None, dstAlpha=False, warpOptions=None, errorThreshold=None, warpMemoryLimit=None, creationOptions=None, outputType=0, workingType=0, resampleAlg=None, srcNodata=None, dstNodata=None, multithread=False, tps=False, rpc=False, geoloc=False, polynomialOrder=None, transformerOptions=None, cutlineDSName=None, cutlineLayer=None, cutlineWhere=None, cutlineSQL=None, cutlineBlend=None, cropToCutline=False, copyMetadata=True, metadataConflictValue=None, setColorInterpretation=False, overviewLevel='AUTO', callback=None, callback_data=None)

  Create a WarpOptions() object that can be passed to gdal.Warp()

  Parameters:

    - options -- can be be an array of strings, a string or let empty and filled from other keywords.

    - format -- output format ("GTiff", etc...)

    - srcBands -- list of source band numbers (between 1 and the number of input bands)

    - dstBands -- list of output band numbers

    - outputBounds -- output bounds as (minX, minY, maxX, maxY) in target SRS

    - outputBoundsSRS -- SRS in which output bounds are expressed, in the case they are not expressed in dstSRS

    - xRes -- output resolution in target SRS

    - yRes -- output resolution in target SRS

    - targetAlignedPixels -- whether to force output bounds to be multiple of output resolution

    - width -- width of the output raster in pixel

    - height -- height of the output raster in pixel

    - srcSRS -- source SRS

    - dstSRS -- output SRS

    - coordinateOperation -- coordinate operation as a PROJ string or WKT string

    - srcAlpha -- whether to force the last band of the input dataset to be considered as an alpha band. If set to False, source alpha warping will be disabled.

    - dstAlpha -- whether to force the creation of an output alpha band

    - outputType -- output type (gdalconst.GDT_Byte, etc...)

    - workingType -- working type (gdalconst.GDT_Byte, etc...)

    - warpOptions -- list or dict of warping options

    - errorThreshold -- error threshold for approximation transformer (in pixels)

    - warpMemoryLimit -- size of working buffer in MB

    - resampleAlg -- resampling mode

    - creationOptions -- list or dict of creation options

    - srcNodata -- source nodata value(s)

    - dstNodata -- output nodata value(s)

    - multithread -- whether to multithread computation and I/O operations

    - tps -- whether to use Thin Plate Spline GCP transformer

    - rpc -- whether to use RPC transformer

    - geoloc -- whether to use GeoLocation array transformer

    - polynomialOrder -- order of polynomial GCP interpolation

    - transformerOptions -- list or dict of transformer options

    - cutlineDSName -- cutline dataset name

    - cutlineLayer -- cutline layer name

    - cutlineWhere -- cutline WHERE clause

    - cutlineSQL -- cutline SQL statement

    - cutlineBlend -- cutline blend distance in pixels

    - cropToCutline -- whether to use cutline extent for output bounds

    - copyMetadata -- whether to copy source metadata

    - metadataConflictValue -- metadata data conflict value

    - setColorInterpretation -- whether to force color interpretation of input bands to output bands

    - overviewLevel -- To specify which overview level of source files must be used

    - callback -- callback method

    - callback_data -- user data for callback

osgeo.gdal.config_option(key, value, thread_local=True)

  Temporarily define a configuration option.

  Parameters:

    - key (str) -- Name of the configuration option

    - value (str) -- Value of the configuration option

    - thread_local (bool) -- Whether the configuration option should be only set on the current thread. The default is True.

  Return type:

    A context manager

  Example

  with gdal.config_option("GDAL_NUM_THREADS", "ALL_CPUS"):

    gdal.Warp("out.tif", "in.tif", dstSRS="EPSG:4326")

osgeo.gdal.config_options(options, thread_local=True)

  Temporarily define a set of configuration options.

  Parameters:

    - options (dict) -- Dictionary of configuration options passed as key, value

    - thread_local (bool) -- Whether the configuration options should be only set on the current thread. The default is True.

  Return type:

    A context manager

  Example

  with gdal.config_options({"GDAL_NUM_THREADS": "ALL_CPUS"}):

    gdal.Warp("out.tif", "in.tif", dstSRS="EPSG:4326")

osgeo.gdal.deprecation_warn(module, sub_package=None, new_module=None)

osgeo.gdal.listdir(path, recursionLevel=-1, options=[])

  Iterate over a directory.

  recursionLevel = -1 means unlimited level of recursion.

osgeo.gdal.quiet_errors()

  Temporarily install an error handler that silents all warnings and errors.

  Return type:

    A context manager

  Example

  with gdal.ExceptionMgr(useExceptions=False), gdal.quiet_errors():

    gdal.Error(gdal.CE_Failure, gdal.CPLE_AppDefined, "you will never see me")

osgeo.gdal.wrapper_EscapeString(int len, int scheme=CPLES_SQL) → retStringAndCPLFree *

osgeo.gdal.wrapper_GDALFootprintDestDS(Dataset dstDS, Dataset srcDS, GDALFootprintOptions options, GDALProgressFunc callback=0, void * callback_data=None) → int

osgeo.gdal.wrapper_GDALFootprintDestName(char const * dest, Dataset srcDS, GDALFootprintOptions options, GDALProgressFunc callback=0, void * callback_data=None) → Dataset

osgeo.gdal.wrapper_GDALMultiDimTranslateDestName(char const * dest, int object_list_count, GDALMultiDimTranslateOptions multiDimTranslateOptions, GDALProgressFunc callback=0, void * callback_data=None) → Dataset

osgeo.gdal.wrapper_GDALNearblackDestDS(Dataset dstDS, Dataset srcDS, GDALNearblackOptions options, GDALProgressFunc callback=0, void * callback_data=None) → int

osgeo.gdal.wrapper_GDALNearblackDestName(char const * dest, Dataset srcDS, GDALNearblackOptions options, GDALProgressFunc callback=0, void * callback_data=None) → Dataset

osgeo.gdal.wrapper_GDALRasterizeDestDS(Dataset dstDS, Dataset srcDS, GDALRasterizeOptions options, GDALProgressFunc callback=0, void * callback_data=None) → int

osgeo.gdal.wrapper_GDALRasterizeDestName(char const * dest, Dataset srcDS, GDALRasterizeOptions options, GDALProgressFunc callback=0, void * callback_data=None) → Dataset

osgeo.gdal.wrapper_GDALVectorTranslateDestDS(Dataset dstDS, Dataset srcDS, GDALVectorTranslateOptions options, GDALProgressFunc callback=0, void * callback_data=None) → int

osgeo.gdal.wrapper_GDALVectorTranslateDestName(char const * dest, Dataset srcDS, GDALVectorTranslateOptions options, GDALProgressFunc callback=0, void * callback_data=None) → Dataset

osgeo.gdal.wrapper_GDALWarpDestDS(Dataset dstDS, int object_list_count, GDALWarpAppOptions warpAppOptions, GDALProgressFunc callback=0, void * callback_data=None) → int

osgeo.gdal.wrapper_GDALWarpDestName(char const * dest, int object_list_count, GDALWarpAppOptions warpAppOptions, GDALProgressFunc callback=0, void * callback_data=None) → Dataset