osgeo.gdal module

osgeo.gdal.AbortPendingUploads(char const * utf8_path) bool
class osgeo.gdal.Algorithm(*path)

Bases: object

Proxy of C++ GDALAlgorithmHS class.

Finalize(Algorithm self) bool
GetActualAlgorithm(Algorithm self) Algorithm
GetArg(Algorithm self, char const * argName) AlgorithmArg
GetArgNames(Algorithm self) char **
GetDescription(Algorithm self) char const *
GetHelpFullURL(Algorithm self) char const *
GetLongDescription(Algorithm self) char const *
GetName(Algorithm self) char const *
GetSubAlgorithmNames(Algorithm self) char **
GetUsageAsJSON(Algorithm self) retStringAndCPLFree *
HasSubAlgorithms(Algorithm self) bool
InstantiateSubAlgorithm(Algorithm self, char const * algName) Algorithm
Output(parse_json=True)

Return the single output value of this algorithm, after it has been run.

If there are multiple output values, this method will raise an exception, and the Outputs() (plural) method should be called instead.

Arguments of type GAAT_DATASET are returned as a osgeo.gdal.Dataset instance.

Parameters:

parse_json (bool, default=True) -- Whether a JSON string should be returned as a dict or list (instead of a string).

Return type:

The single output argument value

Example

>>> with gdal.Run("raster", "info", input="byte.tif") as alg:
...    print(alg.Output()["bands"])
Outputs(parse_json=True)

Return the output value(s) of this algorithm as a dict, after it has been run.

Most algorithms only return a single output, in which case the Output() method (singular) is preferable for easier use.

Arguments of type GAAT_DATASET are returned as a osgeo.gdal.Dataset instance.

Parameters:

parse_json (bool, default=True) -- Whether a JSON string should be returned as a dict or list (instead of a string).

Returns:

  • A dict whose keys are arguments that have outputs and whose values

  • are the argument values.

Example

>>> with gdal.Run("raster", "reproject", input="byte.tif", output_format="MEM", dst_crs="EPSG:4326") as alg:
...    print(alg.Outputs()["output"].ReadAsArray())
ParseCommandLineArguments(Algorithm self, char ** args) bool
ParseRunAndFinalize(Algorithm self, char ** args, GDALProgressFunc callback=0, void * callback_data=None) bool
Run(Algorithm self, GDALProgressFunc callback=0, void * callback_data=None) bool
class osgeo.gdal.AlgorithmArg(*args, **kwargs)

Bases: object

Proxy of C++ GDALAlgorithmArgHS class.

Get()

Return the argument value in its native type.

Note: using the [] operator of Algorithm is also a convenient way of getting the value of an argument.

Examples

>>> arg = alg.GetArg("output")
>>> arg.Get()
GetAliases(AlgorithmArg self) char **
GetAsBoolean(AlgorithmArg self) bool
GetAsDatasetValue(AlgorithmArg self) ArgDatasetValue
GetAsDouble(AlgorithmArg self) double
GetAsDoubleList(AlgorithmArg self)
GetAsInteger(AlgorithmArg self) int
GetAsIntegerList(AlgorithmArg self)
GetAsString(AlgorithmArg self) char const *
GetAsStringList(AlgorithmArg self) char **
GetCategory(AlgorithmArg self) char const *
GetChoices(AlgorithmArg self) char **
GetDatasetInputFlags(AlgorithmArg self) int
GetDatasetOutputFlags(AlgorithmArg self) int
GetDatasetType(AlgorithmArg self) int
GetDescription(AlgorithmArg self) char const *
GetMaxCount(AlgorithmArg self) int
GetMetaVar(AlgorithmArg self) char const *
GetMetadataItem(AlgorithmArg self, char const * item) char **
GetMinCount(AlgorithmArg self) int
GetMutualExclusionGroup(AlgorithmArg self) char const *
GetName(AlgorithmArg self) char const *
GetPackedValuesAllowed(AlgorithmArg self) bool
GetRepeatedArgAllowed(AlgorithmArg self) bool
GetShortName(AlgorithmArg self) char const *
GetType(AlgorithmArg self) GDALAlgorithmArgType
HasDefaultValue(AlgorithmArg self) bool
IsExplicitlySet(AlgorithmArg self) bool
IsHiddenForCLI(AlgorithmArg self) bool
IsInput(AlgorithmArg self) bool
IsOnlyForCLI(AlgorithmArg self) bool
IsOutput(AlgorithmArg self) bool
IsPositional(AlgorithmArg self) bool
IsRequired(AlgorithmArg self) bool
Set(value)

Sets the value of an argument.

Note: using the [] operator of Algorithm is also a convenient way of setting the value of an argument.

Examples

>>> arg = alg.GetArg("input")
>>> arg.Set("in.tif")
SetAsBoolean(AlgorithmArg self, bool value) bool
SetAsDatasetValue(AlgorithmArg self, ArgDatasetValue value) bool
SetAsDouble(AlgorithmArg self, double value) bool
SetAsDoubleList(AlgorithmArg self, int nList) bool
SetAsInteger(AlgorithmArg self, int value) bool
SetAsIntegerList(AlgorithmArg self, int nList) bool
SetAsString(AlgorithmArg self, char const * value) bool
SetAsStringList(AlgorithmArg self, char ** value) bool
SetDataset(AlgorithmArg self, Dataset ds) bool
SetDatasetNames(AlgorithmArg self, char ** names) bool
SetDatasets(AlgorithmArg self, int object_list_count) bool
osgeo.gdal.AlgorithmArgTypeIsList(GDALAlgorithmArgType type) bool
osgeo.gdal.AlgorithmArgTypeName(GDALAlgorithmArgType type) char const *
class osgeo.gdal.AlgorithmRegistry(*args, **kwargs)

Bases: object

Proxy of C++ GDALAlgorithmRegistryHS class.

GetAlgNames(AlgorithmRegistry self) char **
InstantiateAlg(AlgorithmRegistry self, char const * algName) Algorithm
osgeo.gdal.ApplyGeoTransform(double [6] padfGeoTransform, double dfPixel, double dfLine)

Apply a geotransform to convert a (col, row) location into a georeferenced (x, y) coordinate. To perform the inverse transformation, see InvGeoTransform().

See ApplyGeoTransform().

Parameters:
  • gt (tuple) -- Geotransform array, as described in Geotransform Tutorial.

  • dfPixel (float) -- (Fractional) column in image coordinates (0.0 at the left edge of the image)

  • dfLine (float) -- (Fractional) row in image coordinates (0.0 at the top of the image)

Returns:

x, y values corresponding to the input location

Return type:

List

Examples

>>> ds = gdal.Open('byte.tif')
>>> gt = ds.GetGeoTransform()
>>> gdal.ApplyGeoTransform(gt, 5, 7)
[441020.0, 3750900.0]
osgeo.gdal.ApplyHomography(double [9] padfHomography, double dfPixel, double dfLine) int
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.ArgDatasetValue(*args, **kwargs)

Bases: object

Proxy of C++ GDALArgDatasetValueHS class.

GetDataset(ArgDatasetValue self) Dataset
GetName(ArgDatasetValue self) char const *
SetDataset(ArgDatasetValue self, Dataset ds)
SetName(ArgDatasetValue self, char const * name)
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.CPLReadLineL(VSILFILE fp) char const *
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.Contour(destNameOrDestDS, srcDS, **kwargs)

Create contour lines or polygons from raster data.

Parameters:
  • destNameOrDestDS --

    Output dataset name or object

    If passed as a dataset name, a potentially existing output dataset of the same name will be overwritten. To update an existing output dataset, it must be passed as a dataset object.

  • srcDS -- a Dataset object or a filename

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

osgeo.gdal.ContourOptions(options=None, format=None, band=1, elevationName=None, minName=None, maxName=None, with3d=False, srcNodata=None, offset=None, datasetCreationOptions=None, layerCreationOptions=None, interval=None, fixedLevels=None, exponentialBase=None, layerName='contour', polygonize=False, groupTransactions=100000, callback=None, callback_data=None)

Create a ContourOptions() object that can be passed to gdal.Contour()

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

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

  • band -- band number to use (default = 1)

  • elevationName -- name of the attribute in which to put the elevation. If not provided no elevation attribute is attached. Ignored in polygonal contouring (polygonize) mode.

  • minName -- name for the attribute in which to put the minimum elevation of contour polygon. If not provided no minimum elevation attribute is attached. Ignored in default line contouring mode.

  • maxName -- name for the attribute in which to put the maximum elevation of contour polygon. If not provided no maximum elevation attribute is attached. Ignored in default line contouring mode.

  • with3d -- Force production of 3D vectors instead of 2D. Includes elevation at every vertex.

  • srcNodata -- Input pixel value to treat as "nodata".

  • offset -- Offset to apply to the elevation values.

  • datasetCreationOptions -- List or dict of dataset creation options.

  • layerCreationOptions -- List or dict of layer creation options.

  • interval -- Elevation interval between contours. Must specify either "interval" or "fixedLevels" or "exponentialBase".

  • fixedLevels -- Name one or more "fixed levels" to extract. Must specify either "interval" or "fixedLevels" or "exponentialBase".

  • exponentialBase -- Generate levels on an exponential scale: base ^ k, for k an integer. Must specify either. Must specify either "interval" or "fixedLevels" or "exponentialBase".

  • layerName -- Name for the output vector layer, defaults to "contour".

  • polygonize -- Produce polygons instead of lines (default = False).

  • groupTransactions -- Group n features per transaction (default 100 000). Increase the value for better performance when writing into DBMS drivers that have transaction support. n can be set to unlimited to load the data into a single transaction. If set to 0, no explicit transaction is done.

  • callback -- Callback method.

  • callback_data -- User data for callback.

osgeo.gdal.CopyFileRestartable(char const * pszSource, char const * pszTarget, char const * pszInputPayload, char ** options=None, GDALProgressFunc callback=0, void * callback_data=None)
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.GCPsToHomography(int nGCPs) RETURN_NONE
class osgeo.gdal.GDALContourOptions(*args)

Bases: object

Proxy of C++ GDALContourOptions class.

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.GetColorInterpretationByName(char const * pszColorInterpName) GDALColorInterp
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.GetGlobalAlgorithmRegistry() AlgorithmRegistry
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.GetTranformerOptionList() char const *
osgeo.gdal.HasTriangulation() int
osgeo.gdal.InvGeoTransform(double [6] gt_in) RETURN_NONE

Invert a geotransform array so that it represents a conversion from georeferenced (x, y) coordinates to image (col, row) coordinates.

Parameters:

gt (tuple) -- Geotransform array, as described in Geotransform Tutorial.

Returns:

Geotransform array representing the inverse transformation

Return type:

tuple

Examples

>>> ds = gdal.Open('byte.tif')
>>> inv_gt = gdal.InvGeoTransform(ds.GetGeoTransform())
>>> inv_gt
(-7345.333333333333, 0.016666666666666666, 0.0, 62522.0, 0.0, -0.016666666666666666)
>>> gdal.ApplyGeoTransform(inv_gt, 441020, 3750900)
[5.0, 7.0]
osgeo.gdal.InvHomography(double [9] h_in) RETURN_NONE
osgeo.gdal.IsLineOfSightVisible(Band band, int xA, int yA, double zA, int xB, int yB, double zB, char ** options=None)

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

Added 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:

collections.namedtuple(is_visible -- is_visible is True if the two points are within Line of Sight. col_intersection is the raster column index where the LOS line intersects with terrain (will be set in the future, currently set to -1). row_intersection is the raster row index where the LOS line intersects with terrain (will be set in the future, currently set to -1).

Return type:

bool, col_intersection: int, row_intersection: int)

osgeo.gdal.MDArray_GetMeshGrid(int nInputArrays, char ** options=None)
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.Move(char const * old_path, char const * new_path, char ** options=None, GDALProgressFunc callback=0, void * callback_data=None) VSI_RETVAL
osgeo.gdal.MoveFile(char const * pszSource, char const * pszTarget) int
osgeo.gdal.MultipartUploadAbort(char const * pszFilename, char const * pszUploadId, char ** options=None) bool
osgeo.gdal.MultipartUploadAddPart(char const * pszFilename, char const * pszUploadId, int nPartNumber, GUIntBig nFileOffset, size_t nDataLength, char ** options=None) retStringAndCPLFree *
osgeo.gdal.MultipartUploadEnd(char const * pszFilename, char const * pszUploadId, char ** partIds, GUIntBig nTotalSize, char ** options=None) bool
osgeo.gdal.MultipartUploadGetCapabilities(char const * pszFilename)
osgeo.gdal.MultipartUploadStart(char const * pszFilename, char ** options=None) retStringAndCPLFree *
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

Reproject image.

See GDALReprojectImage().

Consider using osgeo.gdal.Warp() and osgeo.gdal.WarpOptions() instead

osgeo.gdal.Run(*alg, arguments={}, progress=None, **kwargs)

Run a GDAL algorithm and return it.

This method can also be used within a context manager, in which case osgeo.gdal.Algorithm.Finalize() will be called at the exit of the context manager. An exception will be raised if the algorithm fails, even if gdal.UseExceptions() has not been called.

Parameters:
  • alg (str, list[str], tuple[str] or Algorithm) -- Path to the algorithm or algorithm instance itself. For example "raster info", ["raster", "info"] or "raster", "info".

  • arguments (dict) -- Input arguments of the algorithm. For example {"format": "json", "input": "byte.tif"}

  • progress (callable) -- Progress function whose arguments are a progress ratio, a string and a user data

  • kwargs -- Instead of using the arguments parameter, it is possible to pass algorithm arguments directly as named parameters of gdal.Run(). If the named argument has dash characters in it, the corresponding parameter must replace them with an underscore character. For example dst_crs as a a parameter of gdal.Run(), instead of dst-crs which is the name to use on the command line.

Return type:

An algorithm

Example

>>> alg = gdal.Run(["raster", "info"], {"input": "byte.tif"})
>>> print(alg.output()["bands"])
>>> with gdal.Run("raster", "reproject", input="byte.tif", output_format="MEM", dst_crs="EPSG:4326") as alg
...     print(alg.output().ReadAsArray())
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.VSIFClearErrL(VSILFILE fp)
osgeo.gdal.VSIFCloseL(VSILFILE fp) VSI_RETVAL
osgeo.gdal.VSIFEofL(VSILFILE fp) int
osgeo.gdal.VSIFErrorL(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
class osgeo.gdal.VSIFile(path, mode, encoding='utf-8')

Bases: BytesIO

Class wrapping a GDAL VSILFILE instance as a Python BytesIO instance

Since:

GDAL 3.11

close()

Disable all I/O operations.

read(size=-1)

Read at most size bytes, returned as a bytes object.

If the size argument is negative, read until EOF is reached. Return an empty bytes object at EOF.

seek(offset, whence=0)

Change stream position.

Seek to byte offset pos relative to position indicated by whence:

  • 0: Start of stream (the default). pos should be >= 0;

  • 1: Current position - pos may be negative;

  • 2: End of stream - pos usually negative.

Returns the new absolute position.

tell()

Current file position, an integer.

write(x)

Write bytes to file.

Return the number of bytes written.

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.WarpGetOptionList() char const *
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_warnings()

Temporarily install an error handler that silences all warnings.

Return type:

A context manager

Example

>>> with gdal.ExceptionMgr(useExceptions=False), gdal.quiet_warnings():
...     gdal.Error(gdal.CE_Warning, gdal.CPLE_AppDefined, "you will never see me")
osgeo.gdal.wrapper_GDALContourDestDS(Dataset dstDS, Dataset srcDS, GDALContourOptions options, GDALProgressFunc callback=0, void * callback_data=None) int
osgeo.gdal.wrapper_GDALContourDestName(char const * dest, Dataset srcDS, GDALContourOptions options, GDALProgressFunc callback=0, void * callback_data=None) Dataset