# Utilities / Algorithms API

## Raster Utilities

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

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

  Build a VRT from a list of datasets.

  Parameters:

    - destName (any) -- Output dataset name.

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

    - **kwargs (any) -- 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.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, nodataMaxMaskThreshold=None, strict=False, writeAbsolutePath=False, pixelFunction=None, pixelFunctionArgs=None, creationOptions=None, callback=None, callback_data=None)

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

  Parameters:

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

    - resolution (any) -- 'highest', 'lowest', 'average', 'user'.

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

    - xRes (any) -- output resolution in target SRS.

    - yRes (any) -- output resolution in target SRS.

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

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

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

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

    - resampleAlg (any) -- resampling mode.

    - outputSRS (any) -- assigned output SRS.

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

    - srcNodata (any) -- source nodata value(s).

    - VRTNodata (any) -- nodata values at the VRT band level.

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

    - nodataMaxMaskThreshold (any) -- value of the mask band of a source below which the source band values should be replaced by VRTNodata (or 0 if not specified)

    - strict (any) -- set to True if warnings should be failures

    - pixelFunction (any) -- a pixel function to use to calculate output pixel values when multiple sources overlap. For a list of available pixel functions, see Built-in Pixel Functions.

    - pixelFunctionArgs (any) -- list or dict of pixel function arguments

    - creationOptions (any) -- list or dict of creation options

    - writeAbsolutePath (any) -- Enables writing the absolute path of the input datasets. By default, input filenames are written in a relative way with respect to the VRT filename (when possible)

    - callback (any) -- callback method.

    - callback_data (any) -- user data for callback.

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 (any) --

      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 (any) -- a Dataset object or a filename

    - **kwargs (any) -- 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 (any) -- can be an array of strings, a string or let empty and filled from other keywords.

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

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

    - elevationName (any) -- 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 (any) -- 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 (any) -- 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 (any) -- Force production of 3D vectors instead of 2D. Includes elevation at every vertex.

    - srcNodata (any) -- Input pixel value to treat as "nodata".

    - offset (any) -- Offset to apply to the elevation values.

    - datasetCreationOptions (any) -- List or dict of dataset creation options.

    - layerCreationOptions (any) -- List or dict of layer creation options.

    - interval (any) -- Elevation interval between contours. Must specify either "interval" or "fixedLevels" or "exponentialBase".

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

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

    - layerName (any) -- Name for the output vector layer, defaults to "contour".

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

    - groupTransactions (any) -- 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 (any) -- Callback method.

    - callback_data (any) -- User data for callback.

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.CreatePansharpenedVRT(char const * pszXML, Band panchroBand, int nInputSpectralBands) → Dataset

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

  Apply a DEM processing.

  Parameters:

    - destName (any) -- Output dataset name

    - srcDS (any) -- a Dataset object or a filename

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

    - **kwargs (any) -- 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.DEMProcessingOptions(options=None, colorFilename=None, format=None, creationOptions=None, computeEdges=False, alg=None, band=1, zFactor=None, scale=None, xscale=None, yscale=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 (any) -- can be an array of strings, a string or let empty and filled from other keywords.

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

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

    - creationOptions (any) -- list or dict of creation options

    - computeEdges (any) -- whether to compute values at raster edges.

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

    - band (any) -- source band number to use

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

    - scale (any) -- ratio of vertical units to horizontal.

    - xscale (any) -- Ratio of vertical units to horizontal X axis units.

    - yscale (any) -- Ratio of vertical units to horizontal Y axis units.

    - azimuth (any) -- (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 (any) -- (hillshade only) altitude of the light, in degrees. 90 if the light comes from above the DEM, 0 if it is raking light.

    - combined (any) -- (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 (any) -- (hillshade only) whether to compute multi-directional shading. Only one of combined, multiDirectional and igor can be specified.

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

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

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

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

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

    - colorSelection (any) -- (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 (any) -- callback method

    - callback_data (any) -- user data for callback

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

  Compute the footprint of a raster

  Parameters:

    - destNameOrDestDS (any) --

      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 (any) -- a Dataset object or a filename

    - **kwargs (any) -- 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.Footprint("out.gpkg", src_ds, format="GPKG")
      <osgeo.gdal.Dataset; proxy of <Swig Object of type 'GDALDatasetShadow *' at 0x...> >

osgeo.gdal.FootprintOptions(options=None, format=None, bands=None, combineBands=None, srcNodata=None, ovr=None, targetCoordinateSystem=None, dstSRS=None, splitPolys=None, convexHull=None, densify=None, simplify=None, maxPoints=None, minRingArea=None, layerName=None, locationFieldName='location', writeAbsolutePath=False, layerCreationOptions=None, datasetCreationOptions=None, callback=None, callback_data=None)

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

  Parameters:

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

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

    - bands (any) -- list of output bands to burn values into

    - combineBands (any) -- how to combine bands: "union" (default) or "intersection"

    - srcNodata (any) -- source nodata value(s).

    - ovr (any) -- overview index.

    - targetCoordinateSystem (any) -- "pixel" or "georef"

    - dstSRS (any) -- output SRS

    - datasetCreationOptions (any) -- list or dict of dataset creation options

    - layerCreationOptions (any) -- list or dict of layer creation options

    - splitPolys (any) -- whether to split multipolygons as several polygons

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

    - densify (any) -- tolerance value for polygon densification

    - simplify (any) -- tolerance value for polygon simplification

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

    - minRingArea (any) -- Minimum value for the area of a ring The unit of the area is in square pixels if targetCoordinateSystem equals "pixel", or otherwise in georeferenced units of the target vector dataset. This option is applied after the reprojection implied by dstSRS

    - locationFieldName (any) -- Specifies the name of the field in the resulting vector dataset where the path of the input dataset will be stored. The default field name is "location". Can be set to None to disable creation of such field.

    - writeAbsolutePath (any) -- Enables writing the absolute path of the input dataset. By default, the filename is written in the location field exactly as the dataset name.

    - layerName (any) -- output layer name

    - callback (any) -- callback method

    - callback_data (any) -- user data for callback

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

  Fill selected raster regions by interpolation from the edges.

  This algorithm will interpolate values for all designated nodata pixels (marked by zeros in `maskBand`). For each pixel a four direction conic search is done to find values to interpolate from (using inverse distance weighting by default). Once all values are interpolated, zero or more smoothing iterations (3x3 average filters on interpolated pixels) are applied to smooth out artifacts.

  This algorithm is generally suitable for interpolating missing regions of fairly continuously varying rasters (such as elevation models for instance). It is also suitable for filling small holes and cracks in more irregularly varying images (like airphotos). It is generally not so great for interpolating a raster from sparse point data. See `Grid()` for that case.

  See `GDALFillNodata()`.

  Parameters:

    - targetBand (Band) -- Band containing values to fill. Will be modified in-place.

    - maskBand (Band) -- Mask band with a value of 0 indicating values that should be filled. If not specified, the mask band associated with `targetBand` will be used.

    - maxSearchDist (float) -- the maximum number of pixels to search in all directions to find values to interpolate from.

    - smoothingIterations (int) -- the number of 3x3 smoothing filter passes to run (0 or more)

    - options (dict or list, optional) -- A dict or list of name=value options. Available options are described in `GDALFillNodata()`.

    - callback (callable, optional) -- A progress callback function

    - callback_data (any, optional) -- Optional data to be passed to callback function

  Returns:

    `CE_None` on success or `CE_Failure` on failure.

  Return type:

    int

  Examples

      >>> import numpy as np
      >>> data = np.array([[1, 2], [9, 9], [9, 9], [3, 4]], dtype=np.float32)
      >>> ds = gdal.GetDriverByName('MEM').Create('', 2, 4, eType=gdal.GDT_Float32)
      >>> ds.WriteArray(data)
      0
      >>> mask = data != 9  # replace pixels with value = 9
      >>> mask_ds = gdal.GetDriverByName('MEM').Create('', 2, 4, eType=gdal.GDT_Byte)
      >>> mask_ds.WriteArray(mask)
      0
      >>> gdal.FillNodata(ds.GetRasterBand(1), mask_ds.GetRasterBand(1), 5, 0)
      0
      >>> ds.ReadAsArray()
      array([[1.       , 2.       ],
             [2.1485982, 2.6666667],
             [2.721169 , 3.3333333],
             [3.       , 4.       ]], dtype=float32)
      >>> gdal.FillNodata(ds.GetRasterBand(1), mask_ds.GetRasterBand(1), 5, 0, {'INTERPOLATION':'NEAREST'})
      0
      >>> ds.ReadAsArray()
      array([[1., 2.],
             [1., 2.],
             [3., 4.],
             [3., 4.]], dtype=float32)

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

  Create raster from the scattered data.

  Parameters:

    - destName (any) -- Output dataset name

    - srcDS (any) -- a Dataset object or a filename

    - **kwargs (any) -- 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.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 (any) -- can be an array of strings, a string or let empty and filled from other keywords.

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

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

    - width (any) -- width of the output raster in pixel

    - height (any) -- height of the output raster in pixel

    - creationOptions (any) -- list or dict of creation options

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

    - outputSRS (any) -- assigned output SRS

    - noData (any) -- nodata value

    - algorithm (any) -- 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 (any) -- list of layers to convert

    - SQLStatement (any) -- SQL statement to apply to the source dataset

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

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

    - zfield (any) -- 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 (any) -- 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 (any) -- 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 (any) -- callback method

    - callback_data (any) -- user data for callback

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

  Return information on a raster dataset.

  Parameters:

    - ds (any) -- a Dataset object or a filename

    - **kwargs (any) -- 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.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, showNodata=True, showMask=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 an array of strings, a string or let empty and filled from other keywords.

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

  Convert nearly black/white borders to exact value.

  Parameters:

    - destNameOrDestDS (any) --

      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 (any) -- a Dataset object or a filename

    - **kwargs (any) -- 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 (any) -- can be an array of strings, a string or let empty and filled from other keywords.

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

    - creationOptions (any) -- list or dict of creation options

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

    - colors (any) -- 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 (any) -- 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 (any) -- 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 (any) -- adds an alpha band to the output file.

    - setMask (any) -- adds a mask band to the output file.

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

    - callback (any) -- callback method

    - callback_data (any) -- user data for callback

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

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

  Burns vector geometries into a raster

  Parameters:

    - destNameOrDestDS (any) --

      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 (any) -- a Dataset object or a filename

    - **kwargs (any) -- 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.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 (any) -- can be an array of strings, a string or let empty and filled from other keywords.

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

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

    - creationOptions (any) -- list or dict of creation options

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

    - outputSRS (any) -- assigned output SRS

    - transformerOptions (any) -- list or dict of transformer options

    - width (any) -- width of the output raster in pixel

    - height (any) -- height of the output raster in pixel

    - xRes (any) -- output resolution in target SRS

    - yRes (any) -- output resolution in target SRS

    - targetAlignedPixels (any) -- whether to force output bounds to be multiple of output resolution

    - noData (any) -- nodata value

    - initValues (any) --

      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 (any) -- list of output bands to burn values into

    - inverse (any) -- 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 (any) -- 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 (any) -- list of fixed values to burn into each band for all objects. Exclusive with attribute.

    - attribute (any) -- identifies an attribute field on the features to be used for a burn-in value. The value will be burned into all output bands. Exclusive with burnValues.

    - useZ (any) -- 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 (any) -- list of layers from the datasource that will be used for input features.

    - SQLStatement (any) -- SQL statement to apply to the source dataset

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

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

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

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

    - callback (any) -- callback method

    - callback_data (any) -- user data for callback

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.SieveFilter(Band srcBand, Band maskBand, Band dstBand, int threshold, int connectedness=4, char ** options=None, GDALProgressFunc callback=0, void * callback_data=None) → int

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:

    An instance of the SuggestedWarpOutputRes class with the following members:

    - `width` (int): Number of pixels in width of the output dataset.

    - `height` (int): Number of pixels in height of the output dataset.

    - `xmin` (float): Minimum value of the georeferenced X coordinates.

    - `ymin` (float): Minimum value of the georeferenced Y coordinates.

    - `xmax` (float): Maximum value of the georeferenced X coordinates.

    - `ymax` (float): Maximum value of the georeferenced Y coordinates.

    - `geotransform` (tuple of 6 floats): Affine geotransformation matrix.

  Return type:

    SuggestedWarpOutputRes

  Examples

      >>> ds = gdal.Open("byte.tif")
      >>> res = gdal.SuggestedWarpOutput(ds, ["DST_SRS=EPSG:4326"])
      >>> print(res.width, res.height, res.xmin, res.ymin, res.xmax, res.ymax, res.geotransform)
          22 18 -117.642 33.891 -117.629 33.902 (-117.642, 0.000598, 0.0, 33.902, 0.0, -0.000598)

osgeo.gdal.TileIndex(destName, srcFilenames, **kwargs)

  Build a tileindex from a list of datasets.

  Parameters:

    - destName (any) -- Output dataset name.

    - srcFilenames (any) -- An array of filenames.

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

osgeo.gdal.TileIndexOptions(options=None, overwrite=None, recursive=None, filenameFilter=None, minPixelSize=None, maxPixelSize=None, format=None, layerName=None, layerCreationOptions=None, locationFieldName='location', outputSRS=None, writeAbsolutePath=None, skipDifferentProjection=None, gtiFilename=None, xRes=None, yRes=None, outputBounds=None, colorInterpretation=None, noData=None, bandCount=None, mask=None, metadataOptions=None, fetchMD=None)

  Create a TileIndexOptions() object that can be passed to gdal.TileIndex()

  Parameters:

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

    - overwrite (any) -- Whether to overwrite the existing tile index

    - recursive (any) -- Whether directories specified in source filenames should be explored recursively

    - filenameFilter (any) -- Pattern that the filenames contained in directories pointed by <file_or_dir> should follow. '*' and '?' wildcard can be used. String or list of strings.

    - minPixelSize (any) -- Minimum pixel size in term of geospatial extent per pixel (resolution) that a raster should have to be selected.

    - maxPixelSize (any) -- Maximum pixel size in term of geospatial extent per pixel (resolution) that a raster should have to be selected.

    - format (any) -- output format ("ESRI Shapefile", "GPKG", etc...)

    - layerName (any) -- output layer name

    - layerCreationOptions (any) -- list or dict of layer creation options

    - locationFieldName (any) -- Specifies the name of the field in the resulting vector dataset where the path of the input dataset will be stored. The default field name is "location". Can be set to None to disable creation of such field.

    - outputSRS (any) -- assigned output SRS

    - writeAbsolutePath (any) -- Enables writing the absolute path of the input dataset. By default, the filename is written in the location field exactly as the dataset name.

    - skipDifferentProjection (any) -- Whether to skip sources that have a different SRS

    - gtiFilename (any) -- Filename of the GDAL XML Tile Index file

    - xRes (any) -- output horizontal resolution

    - yRes (any) -- output vertical resolution

    - outputBounds (any) -- output bounds as [minx, miny, maxx, maxy]

    - colorInterpretation (any) -- Tile color interpretation, as a single value or a list, of the following values ("red", "green", "blue", "alpha", "grey", "undefined", etc.) or their GCI_xxxx symbolic names

    - noData (any) -- tile nodata value, as a single value or a list

    - bandCount (any) -- number of band of tiles in the index

    - mask (any) -- whether tiles have a band mask

    - metadataOptions (any) -- list or dict of metadata options

    - fetchMD (any) -- Fetch a metadata item from the raster tile and write it as a field in the tile index. Tuple (raster metadata item name, target field name, target field type), or list of such tuples, with target field type in "String", "Integer", "Integer64", "Real", "Date", "DateTime";

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

  Convert a dataset.

  Parameters:

    - destName (str) -- Output dataset name

    - srcDS (any) -- a Dataset object or a filename

    - **kwargs (any) -- 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.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', colorInterpretation=None, callback=None, callback_data=None, domainMetadataOptions=None, errorIfWindowOutsideSource=False)

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

  Parameters:

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

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

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

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

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

    - width (int) -- width of the output raster in pixel

    - height (int) -- height of the output raster in pixel

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

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

    - xRes (int) -- output horizontal resolution

    - yRes (int) -- output vertical resolution

    - creationOptions (list or dict) -- list or dict of creation options

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

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

    - projWinSRS (any) -- SRS in which projWin is expressed

    - strict (any) -- strict mode

    - unscale (any) -- unscale values with scale and offset metadata

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

    - exponents (any) -- list of exponentiation parameters

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

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

    - metadataOptions (any) -- list or dict of metadata options

    - outputSRS (any) -- assigned output SRS

    - nogcp (any) -- ignore GCP in the raster

    - GCPs (any) -- list of GCPs

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

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

    - stats (any) -- whether to calculate statistics

    - rat (any) -- whether to write source RAT

    - xmp (any) -- whether to copy XMP metadata

    - resampleAlg (any) -- resampling mode

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

    - colorInterpretation (any) -- Band color interpretation, as a single value or a list, of the following values ("red", "green", "blue", "alpha", "grey", "undefined", etc.) or their GCI_xxxx symbolic names

    - callback (any) -- callback method

    - callback_data (any) -- user data for callback

    - domainMetadataOptions (any) -- list or dict of domain-specific metadata options

    - errorIfWindowOutsideSource ({True, False, "partially", "completely"}, default=True) -- raise an error if the requested window is partially or completely outside the source dataset. ("True" is a synonym for "partially"). This corresponds to the `-epo` and `-eco` options of `gdal_translate`.

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

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

  Warp one or several datasets.

  Parameters:

    - destNameOrDestDS (any) --

      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.

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

    - **kwargs (any) -- 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, cutlineWKT=None, cutlineSRS=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 (any) -- can be an array of strings, a string or let empty and filled from other keywords.

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

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

    - dstBands (any) -- list of output band numbers

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

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

    - xRes (any) -- output resolution in target SRS

    - yRes (any) -- output resolution in target SRS

    - targetAlignedPixels (any) -- whether to force output bounds to be multiple of output resolution

    - width (int) -- width of the output raster in pixel

    - height (int) -- height of the output raster in pixel

    - srcSRS (any) -- source SRS

    - dstSRS (any) -- output SRS

    - coordinateOperation (any) -- coordinate operation as a PROJ string or WKT string

    - srcAlpha (any) -- 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 (any) -- whether to force the creation of an output alpha band

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

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

    - warpOptions (any) -- list or dict of warping options. For a list of available options, see `GDALWarpOptions::papszWarpOptions`.

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

    - warpMemoryLimit (any) -- size of working buffer in MB

    - resampleAlg (any) -- resampling mode

    - creationOptions (list or dict) -- list or dict of creation options

    - srcNodata (any) -- source nodata value(s)

    - dstNodata (any) -- output nodata value(s)

    - multithread (any) -- whether to multithread computation and I/O operations

    - tps (any) -- whether to use Thin Plate Spline GCP transformer

    - rpc (any) -- whether to use RPC transformer

    - geoloc (any) -- whether to use GeoLocation array transformer

    - polynomialOrder (any) -- order of polynomial GCP interpolation

    - transformerOptions (any) -- list or dict of transformer options

    - cutlineDSName (any) -- cutline dataset name (mutually exclusive with cutlineWKT)

    - cutlineWKT (any) -- cutline WKT geometry (POLYGON or MULTIPOLYGON) (mutually exclusive with cutlineDSName)

    - cutlineSRS (any) -- set/override cutline SRS

    - cutlineLayer (any) -- cutline layer name

    - cutlineWhere (any) -- cutline WHERE clause

    - cutlineSQL (any) -- cutline SQL statement

    - cutlineBlend (any) -- cutline blend distance in pixels

    - cropToCutline (any) -- whether to use cutline extent for output bounds

    - copyMetadata (any) -- whether to copy source metadata

    - metadataConflictValue (any) -- metadata data conflict value

    - setColorInterpretation (any) -- whether to force color interpretation of input bands to output bands

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

    - callback (any) -- callback method

    - callback_data (any) -- user data for callback

## Multidimensional Raster Utilities

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

  Return information on a dataset.

  Parameters:

    - ds (any) -- a Dataset object or a filename

    - **kwargs (any) -- 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.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 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 (any) -- Output dataset name

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

    - **kwargs (any) -- 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, arrayOptions=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 (any) -- can be an array of strings, a string or let empty and filled from other keywords.

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

    - creationOptions (any) -- list or dict of creation options

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

    - arrayOptions (any) -- list of options passed to GDALGroup.GetMDArrayNames to filter reported arrays.

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

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

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

    - callback (any) -- callback method

    - callback_data (any) -- user data for callback

## Vector Utilities

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

  Return information on a vector dataset.

  Parameters:

    - ds (any) -- a Dataset object or a filename

    - **kwargs (any) -- 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.VectorInfoOptions(options=None, format='text', deserialize=True, layers=None, dumpFeatures=False, limit=None, 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 an array of strings, a string or let empty and filled from other keywords.

  Parameters:

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

    - format (any) -- "text" or "json"

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

    - SQLStatement (str) -- SQL statement to apply to the source dataset

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

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

    - layers (any) -- list of layers of interest

    - featureCount (any) -- whether to compute and display the feature count

    - extent (any) -- whether to compute and display the layer extent. Can also be set to the string '3D' to request a 3D extent

    - dumpFeatures (any) -- set to True to get the dump of all features

    - limit (int) -- maximum number of features to read per layer

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

  Convert one vector dataset

  Parameters:

    - destNameOrDestDS (any) --

      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. Note that the accessMode parameter also controls, at the layer level, if existing layers must be overwritten or updated.

    - srcDS (any) -- a Dataset object or a filename

    - **kwargs (any) -- 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, coordinateOperationOptions=None, SQLStatement=None, SQLDialect=None, where=None, selectFields=None, addFields=False, relaxedFieldNameMatch=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, skipInvalid=False, mapFieldType=None, explodeCollections=False, zField=None, resolveDomains=False, skipFailures=False, limit=None, xyRes=None, zRes=None, mRes=None, setCoordPrecision=True, callback=None, callback_data=None)

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

  Parameters:

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

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

    - accessMode (any) -- None for creation, 'update', 'append', 'upsert', 'overwrite'

    - srcSRS (any) -- source SRS

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

    - coordinateOperation (any) -- coordinate operation as a PROJ string or WKT string

    - coordinateOperationOptions (any) -- list or dict of coordinate operation options (ALLOW_BALLPARK=NO, ONLY_BEST=YES, WARN_ABOUT_DIFFERENT_COORD_OP=NO)

    - reproject (any) -- whether to do reprojection

    - SQLStatement (any) -- SQL statement to apply to the source dataset

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

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

    - selectFields (any) -- list of fields to select

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

    - relaxedFieldNameMatch (any) -- Do field name matching between source and existing target layer in a more relaxed way if the target driver has an implementation for it.

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

    - emptyStrAsNull (any) -- whether to treat empty string values as NULL

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

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

    - datasetCreationOptions (any) -- list or dict of dataset creation options

    - layerCreationOptions (any) -- list or dict of layer creation options

    - layers (any) -- list of layers to convert

    - layerName (any) -- output layer name

    - geometryType (any) -- 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 (any) -- output dimension ('XY', 'XYZ', 'XYM', 'XYZM', 'layer_dim')

    - transactionSize (any) -- 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 (any) -- 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 (any) -- select desired geometries using an SQL query instead.

    - clipSrcLayer (any) -- select the named layer from the source clip datasource.

    - clipSrcWhere (any) -- restrict desired geometries based on attribute query.

    - clipDst (any) -- 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 (any) -- select desired geometries using an SQL query instead.

    - clipDstLayer (any) -- select the named layer from the destination clip datasource.

    - clipDstWhere (any) -- restrict desired geometries based on attribute query.

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

    - segmentizeMaxDist (any) -- maximum distance between consecutive nodes of a line geometry

    - makeValid (any) -- run MakeValid() on geometries

    - skipInvalid (any) -- whether to skip features with invalid geometries regarding the rules of the Simple Features specification.

    - mapFieldType (any) -- 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 (any) -- 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 (any) -- 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 (any) -- name of field to use to set the Z component of geometries

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

    - skipFailures (any) -- whether to skip failures

    - limit (int) -- maximum number of features to read per layer

    - xyRes (any) -- Geometry X,Y coordinate resolution. Numeric value, or numeric value suffixed with " m", " mm" or "deg".

    - zRes (any) -- Geometry Z coordinate resolution. Numeric value, or numeric value suffixed with " m" or " mm".

    - mRes (any) -- Geometry M coordinate resolution. Numeric value.

    - setCoordPrecision (any) -- Set to False to unset the geometry coordinate precision.

    - callback (any) -- callback method

    - callback_data (any) -- user data for callback

## Algorithms

class osgeo.gdal.Algorithm(*path)

  Python proxy of a `GDALAlgorithm`.

  Finalize(Algorithm self) → bool

    Close any dataset arguments or outputs of the algorithm.

    Return type:

      bool

  GetActualAlgorithm(Algorithm self) → Algorithm

    Return the actual algorithm that is going to be invoked, if the current algorithm has sub-algorithms.

    Return type:

      Algorithm

    Examples

        >>> alg = gdal.GetGlobalAlgorithmRegistry().InstantiateAlg("raster")
        >>> alg.ParseCommandLineArguments(["convert" ,"--input", "byte.tif", "--output",  "/tmp/byte.png"])
        True
        >>> alg.GetActualAlgorithm().GetDescription()
        'Convert a raster dataset.'

  GetArg(Algorithm self, char const * argName) → AlgorithmArg

    Get an `AlgorithmArg` object that can be queried for information about an argument.

    Parameters:

      argName (str)

    Return type:

      AlgorithmArg

    Examples

        >>> alg = gdal.Algorithm("raster", "polygonize")
        >>> arg = alg.GetArg("connect-diagonal-pixels")
        >>> arg.GetDescription()
        'Consider diagonal pixels as connected'

  GetArgNames(Algorithm self) → char **

    Get a list of arguments understood by the Algorithm.

    Return type:

      list

    Examples

        >>> alg = gdal.Algorithm("raster", "convert")
        >>> sorted(alg.GetArgNames())
        ['append', 'config', 'creation-option', ..., 'progress', 'quiet']

  GetDescription(Algorithm self) → char const *

    Get a human-readable description of the Algorithm.

    Return type:

      str

    Examples

        >>> alg = gdal.Algorithm("raster", "convert")
        >>> alg.GetDescription()
        'Convert a raster dataset.'

  GetHelpFullURL(Algorithm self) → char const *

    Get a URL for the algorithm's documentation.

    Return type:

      str

    Examples

        >>> alg = gdal.Algorithm("raster", "convert")
        >>> alg.GetHelpFullURL()
        'https://gdal.org/programs/gdal_raster_convert.html'

  GetName(Algorithm self) → char const *

    Get the name of the algorithm.

    Return type:

      str

    Examples

        >>> gdal.Algorithm("raster", "info").GetName()
        'info'

  GetSubAlgorithmNames(Algorithm self) → char **

    Return a list of names of sub-algorithms.

    Return type:

      list or None

    Examples

        >>> alg = gdal.Algorithm("raster")
        >>> alg.GetSubAlgorithmNames()
        ['as-features', 'aspect', ..., 'viewshed', 'zonal-stats']

  GetUsageAsJSON(Algorithm self) → retStringAndCPLFree *

    Returns a JSON representation of an algorithm's usage information, serialized to a string.

    Return type:

      str

    Examples

        >>> import json
        >>> import pprint
        >>> usage = json.loads(gdal.Algorithm("vector", "info").GetUsageAsJSON())
        >>> pprint.pprint(usage)
        {'description': 'Return information on a vector dataset.',
         'full_path': ['gdal', 'vector', 'info'],
         'input_arguments': [{'category': 'Base',
                              'choices': ['json', 'text'],
                              'description': 'Output format',
                              'name': 'output-format',
                              'required': False,
                              'type': 'string'},
                             {'category': 'Advanced',
                              'description': 'Open options',
                              'max_count': 2147483647,
                              'metavar': '<KEY>=<VALUE>',
                              'min_count': 0,
                              'name': 'open-option',
                              'packed_values_allowed': False,
                              'repeated_arg_allowed': True,
                              'required': False,
                              'type': 'string_list'},
                             {'category': 'Advanced',
                              'description': 'Input formats',
                              'max_count': 2147483647,
                              'metadata': {'required_capabilities': ['DCAP_VECTOR']},
                              'min_count': 0,
                              'name': 'input-format',
                              'packed_values_allowed': True,
                              'repeated_arg_allowed': True,
                              'required': False,
                              'type': 'string_list'},
                             {'category': 'Base',
                              'dataset_type': ['vector'],
                              'description': 'Input vector datasets',
                              'input_flags': ['name', 'dataset'],
                              'max_count': 2147483647,
                              'min_count': 0,
                              'name': 'input',
                              'packed_values_allowed': False,
                              'repeated_arg_allowed': True,
                              'required': True,
                              'type': 'dataset_list'},
                             {'category': 'Base',
                              'description': 'Input layer name',
                              'max_count': 2147483647,
                              'min_count': 0,
                              'mutual_exclusion_group': 'layer-sql',
                              'name': 'input-layer',
                              'packed_values_allowed': True,
                              'repeated_arg_allowed': True,
                              'required': False,
                              'type': 'string_list'},
                             {'category': 'Base',
                              'description': 'List all features (beware of RAM '
                                             'consumption on large layers)',
                              'mutual_exclusion_group': 'summary-features',
                              'name': 'features',
                              'required': False,
                              'type': 'boolean'},
                             {'category': 'Base',
                              'description': 'List the layer names and the geometry '
                                             'type',
                              'mutual_exclusion_group': 'summary-features',
                              'name': 'summary',
                              'required': False,
                              'type': 'boolean'},
                             {'category': 'Base',
                              'description': 'Limit the number of features per layer '
                                             '(implies --features)',
                              'metavar': 'FEATURE-COUNT',
                              'min_value': 0,
                              'min_value_is_included': True,
                              'name': 'limit',
                              'required': False,
                              'type': 'integer'},
                             {'category': 'Base',
                              'description': 'Execute the indicated SQL statement and '
                                             'return the result',
                              'metavar': '<statement>|@<filename>',
                              'mutual_exclusion_group': 'layer-sql',
                              'name': 'sql',
                              'required': False,
                              'type': 'string'},
                             {'category': 'Base',
                              'description': 'Attribute query in a restricted form of '
                                             'the queries used in the SQL WHERE '
                                             'statement',
                              'metavar': '<WHERE>|@<filename>',
                              'name': 'where',
                              'required': False,
                              'type': 'string'},
                             {'category': 'Base',
                              'description': 'SQL dialect',
                              'name': 'dialect',
                              'required': False,
                              'type': 'string'},
                             {'category': 'Base',
                              'description': 'Open the dataset in update mode',
                              'name': 'update',
                              'required': False,
                              'type': 'boolean'}],
         'input_output_arguments': [],
         'name': 'info',
         'output_arguments': [{'category': 'Base',
                               'description': 'Output string, in which the result is '
                                              'placed',
                               'name': 'output-string',
                               'required': False,
                               'type': 'string'}],
         'short_url': '/programs/gdal_vector_info.html',
         'sub_algorithms': [],
         'supports_streamed_output': True,
         'url': 'https://gdal.org/programs/gdal_vector_info.html'}

  HasSubAlgorithms(Algorithm self) → bool

    Returns whether the algorithm has sub-algorithms.

    Return type:

      bool

    Examples

        >>> alg = gdal.Algorithm("raster")
        >>> alg.HasSubAlgorithms()
        True
        >>> subalg = alg.InstantiateSubAlgorithm("convert")
        >>> subalg.HasSubAlgorithms()
        False

  InstantiateSubAlgorithm(Algorithm self, char const * algName) → Algorithm

    Instantiate a sub-algorithm if available.

    Return type:

      Algorithm or None

    Examples

        >>> alg = gdal.Algorithm("raster")
        >>> alg.InstantiateSubAlgorithm("convert")
        <osgeo.gdal.Algorithm; proxy of <Swig Object of type 'GDALAlgorithmHS *' at ...> >
        >>> subalg = alg.InstantiateSubAlgorithm("does_not_exist")

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

    Returns:

      The single output argument value.

    Return type:

      any

    Examples

        >>> with gdal.Run("raster", "info", input="byte.tif") as alg:
        ...    print(alg.Output()["bands"])
        [{'band': 1, 'block': [20, 20], 'type': 'Byte', 'colorInterpretation': 'Gray', 'metadata': {}}]

  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.

    Return type:

      dict

    Examples

        >>> with gdal.Run("raster", "reproject", input="byte.tif", output_format="MEM", dst_crs="EPSG:4326") as alg:
        ...    print(alg.Outputs()["output"].ReadAsArray())
        [[107 123 132 ... 115 99 107]]

  ParseCommandLineArguments(Algorithm self, char ** args) → bool

    Parse a list of arguments for the algorithm, setting the appropriate parameters. May only be called once per algorithm.

    Parameters:

      args (list) -- List of named or positional arguments

    Returns:

      Whether the arguments were successfully parsed

    Return type:

      bool

    Examples

        >>> alg = gdal.Algorithm("vector", "info")
        >>> alg.ParseCommandLineArguments(['poly.shp', '--format', 'text'])
        True

  ParseRunAndFinalize(Algorithm self, char ** args, GDALProgressFunc callback=0, void * callback_data=None) → bool

    Convenience method that calls `ParseCommandLineArguments()`, `Run()`, and `Finalize()`.

    Parameters:

      - args (list) -- List of command line arguments

      - callback (callable, optional) -- Optional progress callback function

      - callback_data -- Optional value to be provided as final argument to callback function

    Returns:

      `True` if the algorithm succeeded, `False` otherwise

    Return type:

      bool

  Run(Algorithm self, GDALProgressFunc callback=0, void * callback_data=None) → bool

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

  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

        >>> alg = gdal.Algorithm("raster convert")
        >>> arg = alg.GetArg("output")
        >>> arg.Get()
        <osgeo.gdal.ArgDatasetValue; proxy of <Swig Object of type 'GDALArgDatasetValueHS *' at 0x...> >

  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
  GetDefaultAsBoolean(AlgorithmArg self) → bool
  GetDefaultAsDouble(AlgorithmArg self) → double
  GetDefaultAsDoubleList(AlgorithmArg self)
  GetDefaultAsInteger(AlgorithmArg self) → int
  GetDefaultAsIntegerList(AlgorithmArg self)
  GetDefaultAsString(AlgorithmArg self) → char const *
  GetDefaultAsStringList(AlgorithmArg self) → char **
  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
  IsHidden(AlgorithmArg self) → bool
  IsHiddenForAPI(AlgorithmArg self) → bool
  IsHiddenForCLI(AlgorithmArg self) → bool
  IsInput(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.

    Returns:

      `True` if the argument was successfully set

    Return type:

      bool

    Examples

        >>> alg = gdal.Algorithm("raster info")
        >>> arg = alg.GetArg("input")
        >>> arg.Set("in.tif")
        True

  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

  Test whether an argument type represents a list.

  Parameters:

    type (int)

  Return type:

    bool

  Examples

      >>> gdal.AlgorithmArgTypeIsList(gdal.GAAT_REAL)
      False
      >>> gdal.AlgorithmArgTypeIsList(gdal.GAAT_REAL_LIST)
      True

osgeo.gdal.AlgorithmArgTypeName(GDALAlgorithmArgType type) → char const *

  Return a text representation of an argument type code.

  Parameters:

    type (int)

  Return type:

    str

  Examples

      >>> gdal.AlgorithmArgTypeName(gdal.GAAT_REAL)
      'real'

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

  Python proxy of a `GDALAlgorithmRegistry`. Typically, the global algorithm registry is used (accessed via `GetGlobalAlgorithmRegistry()`.)

  GetAlgNames(AlgorithmRegistry self) → char **

    Return the names of available algorithms.

    Return type:

      list

    Examples

        >>> gdal.GetGlobalAlgorithmRegistry().GetAlgNames()
        ['convert', 'dataset', 'info', 'mdim', 'pipeline', 'raster', 'vector', 'vsi']

  InstantiateAlg(AlgorithmRegistry self, char const * algName) → Algorithm

    Instantiate an `Algorithm`.

    Most useful algorithms are accessed as a sub-algorithm of another algorithm. For example, `polygonize` is a sub-algorithm of `raster` and can be instantiated by first instantiating the primary algorithm, then using `Algorithm.InstantiateSubAlgorithm()`.

    Return type:

      Algorithm

    Examples

        >>> alg = gdal.GetGlobalAlgorithmRegistry().InstantiateAlg('pipeline')    # or alg= gdal.Algorithm("pipeline")
        >>> alg.GetName()
        'pipeline'
        >>> alg.GetArgNames()
        ['help', 'help-doc', 'json-usage', 'config', 'quiet', 'progress', 'input', 'output', 'output-format', 'pipeline', 'output-string', 'stdout']

        >>> subalg = gdal.GetGlobalAlgorithmRegistry().InstantiateAlg('raster').InstantiateSubAlgorithm('polygonize')
        >>> subalg.GetArgNames()
        ['help', 'help-doc', 'json-usage', 'config', 'quiet', 'progress', 'input-format', 'open-option', 'input', 'output-format', 'output-open-option', 'output', 'creation-option', 'layer-creation-option', 'overwrite', 'update', 'overwrite-layer', 'append', 'output-layer', 'band', 'attribute-name', 'connect-diagonal-pixels', 'commit-interval']

osgeo.gdal.GetGlobalAlgorithmRegistry() → AlgorithmRegistry

  Return the default algorithm registry.

  Return type:

    AlgorithmRegistry

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

  Run a GDAL algorithm and return it.

  Added in version 3.11.

  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 `osgeo.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 (any) -- 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:

    Algorithm

  Examples

      >>> alg = gdal.Run(["raster", "info"], {"input": "byte.tif"})
      >>> print(alg.Output()["bands"])
      [{'band': 1, 'block': [20, 20], 'type': 'Byte', 'colorInterpretation': 'Gray', 'metadata': {}}]

      >>> with gdal.Run("raster", "reproject", input="byte.tif", output_format="MEM", dst_crs="EPSG:4326") as alg:
      ...     print(alg.Output().ReadAsArray().shape)
      (18, 22)