Python Raster API

This page contains classes, methods, functions that relate to the GDAL ラスターデータモデル:

Driver

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

Proxy of C++ GDALDriverShadow class.

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

p.q(const).char

Type:

HelpTopic

property LongName

p.q(const).char

Type:

LongName

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

p.q(const).char

Type:

ShortName

osgeo.gdal.AllRegister()
osgeo.gdal.GetDriver(int i) Driver
osgeo.gdal.GetDriverByName(char const * name) Driver
osgeo.gdal.GetDriverCount() int
osgeo.gdal.IdentifyDriver(char const * utf8_path, char ** papszSiblings=None) Driver
osgeo.gdal.IdentifyDriverEx(char const * utf8_path, unsigned int nIdentifyFlags=0, char ** allowed_drivers=None, char ** sibling_files=None) Driver

Dataset

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

Proxy of C++ GDALDatasetShadow class.

AbortSQL(Dataset self) OGRErr
AddBand(Dataset self, GDALDataType datatype=GDT_Byte, char ** options=None) CPLErr
AddFieldDomain(Dataset self, FieldDomain fieldDomain) bool
AdviseRead(Dataset self, int xoff, int yoff, int xsize, int ysize, int * buf_xsize=None, int * buf_ysize=None, GDALDataType * buf_type=None, int band_list=0, char ** options=None) CPLErr
BeginAsyncReader(xoff, yoff, xsize, ysize, buf_obj=None, buf_xsize=None, buf_ysize=None, buf_type=None, band_list=None, options=None)
BuildOverviews(Dataset self, char const * resampling="NEAREST", int overviewlist=0, GDALProgressFunc callback=0, void * callback_data=None) int
ClearStatistics(Dataset self)
CommitTransaction(Dataset self) OGRErr
CopyLayer(Dataset self, Layer src_layer, char const * new_name, char ** options=None) Layer
CreateLayer(Dataset self, char const * name, SpatialReference srs=None, OGRwkbGeometryType geom_type=wkbUnknown, char ** options=None) Layer
CreateMaskBand(Dataset self, int nFlags) CPLErr
DeleteLayer(value)

Deletes the layer given an index or layer name

EndAsyncReader(Dataset self, AsyncReader ario)
ExecuteSQL(Dataset self, char const * statement, Geometry spatialFilter=None, char const * dialect="") Layer
FlushCache(Dataset self)
GetDriver(Dataset self) Driver
GetFieldDomain(Dataset self, char const * name) FieldDomain
GetFileList(Dataset self) char **
GetGCPCount(Dataset self) int
GetGCPProjection(Dataset self) char const *
GetGCPSpatialRef(Dataset self) SpatialReference
GetGCPs(Dataset self)
GetGeoTransform(Dataset self, int * can_return_null=None)
GetLayer(iLayer=0)

Return the layer given an index or a name

GetLayerByIndex(Dataset self, int index=0) Layer
GetLayerByName(Dataset self, char const * layer_name) Layer
GetLayerCount(Dataset self) int
GetNextFeature(Dataset self, bool include_layer=True, bool include_pct=False, GDALProgressFunc callback=0, void * callback_data=None) Feature
GetProjection(Dataset self) char const *
GetProjectionRef(Dataset self) char const *
GetRasterBand(Dataset self, int nBand) Band
GetRootGroup(Dataset self) Group
GetSpatialRef(Dataset self) SpatialReference
GetStyleTable(Dataset self) StyleTable
GetSubDatasets()
GetTiledVirtualMem(Dataset self, GDALRWFlag eRWFlag, int nXOff, int nYOff, int nXSize, int nYSize, int nTileXSize, int nTileYSize, GDALDataType eBufType, int band_list, GDALTileOrganization eTileOrganization, size_t nCacheSize, char ** options=None) VirtualMem
GetTiledVirtualMemArray(eAccess=0, xoff=0, yoff=0, xsize=None, ysize=None, tilexsize=256, tileysize=256, datatype=None, band_list=None, tile_organization=2, cache_size=10485760, options=None)

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

GetVirtualMem(Dataset self, GDALRWFlag eRWFlag, int nXOff, int nYOff, int nXSize, int nYSize, int nBufXSize, int nBufYSize, GDALDataType eBufType, int band_list, int bIsBandSequential, size_t nCacheSize, size_t nPageSizeHint, char ** options=None) VirtualMem
GetVirtualMemArray(eAccess=0, xoff=0, yoff=0, xsize=None, ysize=None, bufxsize=None, bufysize=None, datatype=None, band_list=None, band_sequential=True, cache_size=10485760, page_size_hint=0, options=None)

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

IsLayerPrivate(Dataset self, int index) bool
property RasterCount

int

Type:

RasterCount

property RasterXSize

int

Type:

RasterXSize

property RasterYSize

int

Type:

RasterYSize

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

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

ReadRaster(xoff=0, yoff=0, xsize=None, ysize=None, buf_xsize=None, buf_ysize=None, buf_type=None, band_list=None, buf_pixel_space=None, buf_line_space=None, buf_band_space=None, resample_alg=0, callback=None, callback_data=None, buf_obj=None)
ReadRaster1(Dataset self, double xoff, double yoff, double xsize, double ysize, int * buf_xsize=None, int * buf_ysize=None, GDALDataType * buf_type=None, int band_list=0, GIntBig * buf_pixel_space=None, GIntBig * buf_line_space=None, GIntBig * buf_band_space=None, GDALRIOResampleAlg resample_alg=GRIORA_NearestNeighbour, GDALProgressFunc callback=0, void * callback_data=None, void * inputOutputBuf=None) CPLErr
ReleaseResultSet(Dataset self, Layer layer)
ResetReading(Dataset self)
RollbackTransaction(Dataset self) OGRErr
SetGCPs(gcps, wkt_or_spatial_ref)
SetGeoTransform(Dataset self, double [6] argin) CPLErr
SetProjection(Dataset self, char const * prj) CPLErr
SetSpatialRef(Dataset self, SpatialReference srs) CPLErr
SetStyleTable(Dataset self, StyleTable table)
StartTransaction(Dataset self, int force=FALSE) OGRErr
TestCapability(Dataset self, char const * cap) bool
WriteArray(array, xoff=0, yoff=0, band_list=None, interleave='band', resample_alg=0, callback=None, callback_data=None)
WriteRaster(xoff, yoff, xsize, ysize, buf_string, buf_xsize=None, buf_ysize=None, buf_type=None, band_list=None, buf_pixel_space=None, buf_line_space=None, buf_band_space=None)
osgeo.gdal.Open(char const * utf8_path, GDALAccess eAccess=GA_ReadOnly) Dataset
osgeo.gdal.OpenEx(char const * utf8_path, unsigned int nOpenFlags=0, char ** allowed_drivers=None, char ** open_options=None, char ** sibling_files=None) Dataset
osgeo.gdal.OpenShared(char const * utf8_path, GDALAccess eAccess=GA_ReadOnly) Dataset

Band

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

Proxy of C++ GDALRasterBandShadow class.

AdviseRead(Band self, int xoff, int yoff, int xsize, int ysize, int * buf_xsize=None, int * buf_ysize=None, GDALDataType * buf_type=None, char ** options=None) CPLErr
AsMDArray(Band self) MDArray
Checksum(Band self, int xoff=0, int yoff=0, int * xsize=None, int * ysize=None) int
ComputeBandStats(Band self, int samplestep=1)
ComputeRasterMinMax(Band self, int approx_ok=0)
ComputeStatistics(Band self, bool approx_ok, GDALProgressFunc callback=0, void * callback_data=None) CPLErr
CreateMaskBand(Band self, int nFlags) CPLErr
property DataType

GDALDataType

Type:

DataType

DeleteNoDataValue(Band self) CPLErr
Fill(Band self, double real_fill, double imag_fill=0.0) CPLErr
FlushCache(Band self)
GetActualBlockSize(Band self, int nXBlockOff, int nYBlockOff)
GetBand(Band self) int
GetBlockSize(Band self)
GetCategoryNames(Band self) char **
GetColorInterpretation(Band self) GDALColorInterp
GetColorTable(Band self) ColorTable
GetDataCoverageStatus(Band self, int nXOff, int nYOff, int nXSize, int nYSize, int nMaskFlagStop=0) int
GetDataset(Band self) Dataset
GetDefaultHistogram(Band self, double * min_ret=None, double * max_ret=None, int * buckets_ret=None, GUIntBig ** ppanHistogram=None, int force=1, GDALProgressFunc callback=0, void * callback_data=None) CPLErr
GetDefaultRAT(Band self) RasterAttributeTable
GetHistogram(Band self, double min=-0.5, double max=255.5, int buckets=256, int include_out_of_range=0, int approx_ok=1, GDALProgressFunc callback=0, void * callback_data=None) CPLErr
GetMaskBand(Band self) Band
GetMaskFlags(Band self) int
GetMaximum(Band self)
GetMinimum(Band self)
GetNoDataValue(Band self)
GetOffset(Band self)
GetOverview(Band self, int i) Band
GetOverviewCount(Band self) int
GetRasterCategoryNames(Band self) char **
GetRasterColorInterpretation(Band self) GDALColorInterp
GetRasterColorTable(Band self) ColorTable
GetScale(Band self)
GetStatistics(Band self, int approx_ok, int force) CPLErr
GetTiledVirtualMem(Band self, GDALRWFlag eRWFlag, int nXOff, int nYOff, int nXSize, int nYSize, int nTileXSize, int nTileYSize, GDALDataType eBufType, size_t nCacheSize, char ** options=None) VirtualMem
GetTiledVirtualMemArray(eAccess=0, xoff=0, yoff=0, xsize=None, ysize=None, tilexsize=256, tileysize=256, datatype=None, cache_size=10485760, options=None)

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

GetUnitType(Band self) char const *
GetVirtualMem(Band self, GDALRWFlag eRWFlag, int nXOff, int nYOff, int nXSize, int nYSize, int nBufXSize, int nBufYSize, GDALDataType eBufType, size_t nCacheSize, size_t nPageSizeHint, char ** options=None) VirtualMem
GetVirtualMemArray(eAccess=0, xoff=0, yoff=0, xsize=None, ysize=None, bufxsize=None, bufysize=None, datatype=None, cache_size=10485760, page_size_hint=0, options=None)

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

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

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

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

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

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

int

Type:

XSize

property YSize

int

Type:

YSize

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

Other

class osgeo.gdal.RasterAttributeTable(*args)

Proxy of C++ GDALRasterAttributeTableShadow class.

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

Proxy of C++ GDALColorTableShadow class.

Clone(ColorTable self) ColorTable
CreateColorRamp(ColorTable self, int nStartIndex, ColorEntry startcolor, int nEndIndex, ColorEntry endcolor)
GetColorEntry(ColorTable self, int entry) ColorEntry
GetColorEntryAsRGB(ColorTable self, int entry, ColorEntry centry) int
GetCount(ColorTable self) int
GetPaletteInterpretation(ColorTable self) GDALPaletteInterp
SetColorEntry(ColorTable self, int entry, ColorEntry centry)
class osgeo.gdal.ColorEntry(*args, **kwargs)

Proxy of C++ GDALColorEntry class.

property c1

short

Type:

c1

property c2

short

Type:

c2

property c3

short

Type:

c3

property c4

short

Type:

c4

class osgeo.gdal.GCP(*args)

Proxy of C++ GDAL_GCP class.

property GCPLine

double

Type:

GCPLine

property GCPPixel

double

Type:

GCPPixel

property GCPX

double

Type:

GCPX

property GCPY

double

Type:

GCPY

property GCPZ

double

Type:

GCPZ

property Id

p.char

Type:

Id

property Info

p.char

Type:

Info

serialize(with_Z=0)