osgeo.gdal module

osgeo.gdal.AbortPendingUploads(char const * utf8_path) bool
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)
osgeo.gdal.CPLBinaryToHex(int nBytes) retStringAndCPLFree *
osgeo.gdal.CPLHexToBinary(char const * pszHex, int * pnBytes) GByte *
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.CreateRasterAttributeTableFromMDArrays(GDALRATTableType eTableType, int nArrays, int nUsages=0) RasterAttributeTable
osgeo.gdal.DataTypeIsComplex(GDALDataType eDataType) int
osgeo.gdal.DataTypeUnion(GDALDataType a, GDALDataType b) GDALDataType
osgeo.gdal.DecToDMS(double arg1, char const * arg2, int arg3=2) char const *
osgeo.gdal.DecToPackedDMS(double dfDec) double
osgeo.gdal.DitherRGB2PCT(Band red, Band green, Band blue, Band target, ColorTable colors, GDALProgressFunc callback=0, void * callback_data=None) int
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
osgeo.gdal.EDTComponent_Create(char const * name, size_t offset, ExtendedDataType type) EDTComponent
osgeo.gdal.EscapeBinary(int len, int scheme=CPLES_SQL)
osgeo.gdal.EscapeString(string_or_bytes, scheme=gdal.CPLES_SQL)
osgeo.gdal.ExtendedDataType_Create(GDALDataType dt) ExtendedDataType
osgeo.gdal.ExtendedDataType_CreateCompound(char const * name, size_t nTotalSize, int nComps) ExtendedDataType
osgeo.gdal.ExtendedDataType_CreateString(size_t nMaxStringLength=0, GDALExtendedDataTypeSubType eSubType=GEDTST_NONE) ExtendedDataType
osgeo.gdal.FPolygonize(Band srcBand, Band maskBand, Layer outLayer, int iPixValField, char ** options=None, GDALProgressFunc callback=0, void * callback_data=None) int
osgeo.gdal.FinderClean()
osgeo.gdal.GCPsToGeoTransform(int nGCPs, int bApproxOK=1) RETURN_NONE
osgeo.gdal.GDALDestroyDriverManager()
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
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.GetColorInterpretationName(GDALColorInterp eColorInterp) char const *
osgeo.gdal.GetDataTypeByName(char const * pszDataTypeName) GDALDataType

Return the data type for a given name.

Parameters:

pszDataTypeName (str) -- data type name

Returns:

data type code

Return type:

int

Examples

>>> gdal.GetDataTypeByName('Int16') == gdal.GDT_Int16
True
osgeo.gdal.GetDataTypeName(GDALDataType eDataType) char const *

Return the name of the data type.

Parameters:

eDataType (int) -- data type code

Return type:

str

Examples

>>> gdal.GetDataTypeName(gdal.GDT_Int16)
'Int16'
>>> gdal.GetDataTypeName(gdal.GDT_Float64)
'Float64'
osgeo.gdal.GetDataTypeSize(GDALDataType eDataType) int

Return the size of the data type in bits.

Parameters:

eDataType (int) -- data type code

Return type:

int

Examples

>>> gdal.GetDataTypeSize(gdal.GDT_Byte)
8
>>> gdal.GetDataTypeSize(gdal.GDT_Int32)
32
osgeo.gdal.GetJPEG2000Structure(char const * pszFilename, char ** options=None) CPLXMLNode *
osgeo.gdal.GetJPEG2000StructureAsString(char const * pszFilename, char ** options=None) retStringAndCPLFree *
osgeo.gdal.GetNextDirEntry(VSIDIR * dir) DirEntry
osgeo.gdal.GetPaletteInterpretationName(GDALPaletteInterp ePaletteInterp) char const *
osgeo.gdal.GetSignedURL(char const * utf8_path, char ** options=None) retStringAndCPLFree *
osgeo.gdal.GetSubdatasetInfo(char const * pszFileName) GDALSubdatasetInfoShadow *
osgeo.gdal.HasTriangulation() int
osgeo.gdal.InvGeoTransform(double [6] gt_in) RETURN_NONE
osgeo.gdal.IsLineOfSightVisible(Band band, int xA, int yA, double zA, int xB, int yB, double zB, char ** options=None) bool

Check Line of Sight between two points. Both input coordinates must be within the raster coordinate bounds.

New in version 3.9.

Parameters:
  • band (gdal.RasterBand) -- The band to read the DEM data from. This must NOT be null.

  • xA (int) -- The X location (raster column) of the first point to check on the raster.

  • yA (int) -- The Y location (raster row) of the first point to check on the raster.

  • zA (float) -- The Z location (height) of the first point to check.

  • xB (int) -- The X location (raster column) of the second point to check on the raster.

  • yB (int) -- The Y location (raster row) of the second point to check on the raster.

  • zB (float) -- The Z location (height) of the second point to check.

  • options (dict/list, optional) -- A dict or list of name=value of options for the line of sight algorithm (currently ignored).

Returns:

True if the two points are within Line of Sight.

Return type:

bool

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
osgeo.gdal.NetworkStatsGetAsSerializedJSON(char ** options=None) retStringAndCPLFree *
osgeo.gdal.NetworkStatsReset()
osgeo.gdal.PackedDMSToDec(double dfPacked) double
osgeo.gdal.ParseCommandLine(char const * utf8_path) char **
osgeo.gdal.ParseXMLString(char * pszXMLString) CPLXMLNode *
osgeo.gdal.PopFinderLocation()
osgeo.gdal.PushFinderLocation(char const * utf8_path)
osgeo.gdal.RGBFile2PCTFile(src_filename, dst_filename)
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.SerializeXMLTree(CPLXMLNode * xmlnode) retStringAndCPLFree *
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

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

osgeo.gdal.VSIStatL(char const * utf8_path, int nFlags=0) int
osgeo.gdal.VSISupportsSparseFiles(char const * utf8_path) int
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)
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.