Main Page   Class Hierarchy   Compound List   File List   Compound Members   File Members   Related Pages  

GDALDataset Class Reference

#include <gdal_priv.h>

Inheritance diagram for GDALDataset:

List of all members.

Public Methods

virtual ~GDALDataset ()
int GetRasterXSize ( void )
int GetRasterYSize ( void )
int GetRasterCount ( void )
GDALRasterBandGetRasterBand ( int )
virtual void FlushCache (void)
virtual const char* GetProjectionRef (void)
virtual CPLErr SetProjection ( const char * )
virtual CPLErr GetGeoTransform ( double * )
virtual CPLErr SetGeoTransform ( double * )
virtual CPLErr AddBand ( GDALDataType eType, char **papszOptions=NULL )
virtual void* GetInternalHandle ( const char * )
virtual GDALDriverGetDriver (void)
virtual int GetGCPCount ()
virtual const char* GetGCPProjection ()
virtual const GDAL_GCPGetGCPs ()
virtual CPLErr SetGCPs ( int nGCPCount, const GDAL_GCP *pasGCPList, const char *pszGCPProjection )
int Reference ()
int Dereference ()
GDALAccess GetAccess ()
int GetShared ()
void MarkAsShared ()
CPLErr BuildOverviews ( const char *, int, int *, int, int *, GDALProgressFunc, void * )

Static Public Methods

GDALDataset** GetOpenDatasets ( int *pnDatasetCount )

Protected Methods

 GDALDataset (void)
void RasterInitialize ( int, int )
void SetBand ( int, GDALRasterBand * )
virtual CPLErr IBuildOverviews ( const char *, int, int *, int, int *, GDALProgressFunc, void * )

Protected Attributes

GDALDriverpoDriver
GDALAccess eAccess
int nRasterXSize
int nRasterYSize
int nBands
GDALRasterBand** papoBands
int nRefCount
int bShared
GDALDefaultOverviews oOvManager

Friends

class  GDALDriver
class  GDALRasterBand
GDALDatasetH GDALOpen ( const char *, GDALAccess)
GDALDatasetH GDALOpenShared ( const char *, GDALAccess)

Detailed Description

A dataset encapsulating one or more raster bands.

Use GDALOpen to create a GDALDataset for a named file.


Constructor & Destructor Documentation

GDALDataset::~GDALDataset ( ) [virtual]
 

Destroy an open GDALDataset.

This is the accepted method of closing a GDAL dataset and deallocating all resources associated with it.

Equivelent of the C callable GDALClose(). Except that GDALClose() first decrements the reference count, and then closes only if it has dropped to zero.


Member Function Documentation

CPLErr GDALDataset::AddBand ( GDALDataType eType,
char ** papszOptions = NULL ) [virtual]
 

Add a band to a dataset.

This method will add a new band to the dataset if the underlying format supports this action. Most formats do not.

Note that the new GDALRasterBand is not returned. It may be fetched after successful completion of the method by calling GDALDataset::GetRasterBand(GDALDataset::GetRasterCount()-1) as the newest band will always be the last band.

Parameters:
eType   the data type of the pixels in the new band.
papszOptions   a list of NAME=VALUE option strings. The supported options are format specific. NULL may be passed by default.

Returns:
CE_None on success or CE_Failure on failure.

CPLErr GDALDataset::BuildOverviews ( const char * pszResampling,
int nOverviews,
int * panOverviewList,
int nListBands,
int * panBandList,
GDALProgressFunc pfnProgress,
void * pProgressData )
 

Build raster overview(s)

If the operation is unsupported for the indicated dataset, then CE_Failure is returned, and CPLGetLastError() will return CPLE_NonSupported.

This method is the same as the C function GDALBuildOverviews().

Parameters:
pszResampling   one of "NEAREST", "AVERAGE" or "MODE" controlling the downsampling method applied.
nOverviews   number of overviews to build.
panOverviewList   the list of overview decimation factors to build.
nBand   number of bands to build overviews for in panBandList. Build for all bands if this is 0.
panBandList   list of band numbers.
pfnProgress   a function to call to report progress, or NULL.
pProgressData   application data to pass to the progress function.

Returns:
CE_None on success or CE_Failure if the operation doesn't work.

For example, to build overview level 2, 4 and 8 on all bands the following call could be made:
   int       anOverviewList[3] = { 2, 4, 8 };
   
   poDataset->BuildOverviews( "NEAREST", 3, anOverviewList, 0, NULL, 
                              GDALDummyProgress, NULL );
 

int GDALDataset::Dereference ( )
 

Subtract one from dataset reference count.

The reference is one after instantiation. Generally when the reference count has dropped to zero the dataset may be safely deleted (closed).

This method is the same as the C GDALDereferenceDataset() function.

Returns:
the post-decrement reference count.

void GDALDataset::FlushCache ( void ) [virtual]
 

Flush all write cached data to disk.

Any raster (or other GDAL) data written via GDAL calls, but buffered internally will be written to disk.

GDALDriver * GDALDataset::GetDriver ( void ) [virtual]
 

Fetch the driver to which this dataset relates.

This method is the same as the C GDALGetDatasetDriver() function.

Returns:
the driver on which the dataset was created with GDALOpen or GDALCreate().

int GDALDataset::GetGCPCount ( ) [virtual]
 

Get number of GCPs.

This method is the same as the C function GDALGetGCPCount().

Returns:
number of GCPs for this dataset. Zero if there are none.

const char * GDALDataset::GetGCPProjection ( ) [virtual]
 

Get output projection for GCPs.

This method is the same as the C function GDALGetGCPProjection().

The projection string follows the normal rules from GetProjectionRef().

Returns:
internal projection string or "" if there are no GCPs.

const GDAL_GCP * GDALDataset::GetGCPs ( ) [virtual]
 

Fetch GCPs.

This method is the same as the C function GDALGetGCPs().

Returns:
pointer to internal GCP structure list. It should not be modified, and may change on the next GDAL call.

CPLErr GDALDataset::GetGeoTransform ( double * padfTransform ) [virtual]
 

Fetch the affine transformation coefficients.

Fetches the coefficients for transforming between pixel/line (P,L) raster space, and projection coordinates (Xp,Yp) space.

Xp = padfTransform[0] + P*padfTransform[1] + L*padfTransform[2]; Yp = padfTransform[3] + P*padfTransform[4] + L*padfTransform[5];

In a north up image, padfTransform[1] is the pixel width, and padfTransform[5] is the pixel height. The upper left corner of the upper left pixel is at position (padfTransform[0],padfTransform[3]).

The default transform is (0,1,0,0,0,1) and should be returned even when a CE_Failure error is returned, such as for formats that don't support transformation to projection coordinates.

NOTE: GetGeoTransform() isn't expressive enough to handle the variety of OGC Grid Coverages pixel/line to projection transformation schemes. Eventually this method will be depreciated in favour of a more general scheme.

This method does the same thing as the C GDALGetGeoTransform() function.

Parameters:
padfTransform   an existing six double buffer into which the transformation will be placed.

Returns:
CE_None on success, or CE_Failure if no transform can be fetched.

void * GDALDataset::GetInternalHandle ( const char * ) [virtual]
 

Fetch a format specific internally meaningful handle.

This method is the same as the C GDALGetInternalHandle() method.

Parameters:
pszHandleName   the handle name desired. The meaningful names will be specific to the file format.

Returns:
the desired handle value, or NULL if not recognised/supported.

GDALDataset ** GDALDataset::GetOpenDatasets ( int * pnCount ) [static]
 

Fetch all open GDAL dataset handles.

This method is the same as the C function GDALGetOpenDatasets().

Parameters:
pnCount   integer into which to place the count of dataset pointers being returned.

Returns:
a pointer to an array of dataset handles.

const char * GDALDataset::GetProjectionRef ( void ) [virtual]
 

Fetch the projection definition string for this dataset.

Same as the C function GDALGetProjectionRef().

The returned string defines the projection coordinate system of the image in either PROJ.4 format or OpenGIS WKT format. It should be suitable for use with the GDALProjDef object to reproject positions.

When a projection definition is not available an empty (but not NULL) string is returned.

Returns:
a pointer to an internal projection reference string. It should not be altered, freed or expected to last for long.

GDALRasterBand * GDALDataset::GetRasterBand ( int nBandId )
 

Fetch a band object for a dataset.

Equivelent of the C function GDALGetRasterBand().

Parameters:
nBandId   the index number of the band to fetch, from 1 to GetRasterCount().

Returns:
the height in pixels of raster bands in this GDALDataset.

int GDALDataset::GetRasterCount ( void )
 

Fetch the number of raster bands on this dataset.

Same as the C function GDALGetRasterCount().

Returns:
the number of raster bands.

int GDALDataset::GetRasterXSize ( void )
 

Fetch raster width in pixels.

Equivelent of the C function GDALGetRasterXSize().

Returns:
the width in pixels of raster bands in this GDALDataset.

int GDALDataset::GetRasterYSize ( void )
 

Fetch raster height in pixels.

Equivelent of the C function GDALGetRasterYSize().

Returns:
the height in pixels of raster bands in this GDALDataset.

int GDALDataset::GetShared ( )
 

Returns shared flag.

Returns:
TRUE if the GDALDataset is available for sharing, or FALSE if not.

void GDALDataset::MarkAsShared ( )
 

Mark this dataset as available for sharing.

int GDALDataset::Reference ( )
 

Add one to dataset reference count.

The reference is one after instantiation.

This method is the same as the C GDALReferenceDataset() function.

Returns:
the post-increment reference count.

CPLErr GDALDataset::SetGCPs ( int nGCPCount,
const GDAL_GCP * pasGCPList,
const char * pszGCPProjection ) [virtual]
 

Assign GCPs.

This method is the same as the C function GDALSetGCPs().

This method assigns the passed set of GCPs to this dataset, as well as setting their coordinate system. Internally copies are made of the coordinate system and list of points, so the caller remains resposible for deallocating these arguments if appropriate.

Most formats do not support setting of GCPs, even foramts that can handle GCPs. These formats will return CE_Failure.

Parameters:
nGCPCount   number of GCPs being assigned.
pasGCPList   array of GCP structures being assign (nGCPCount in array).
pszGCPProjection   the new OGC WKT coordinate system to assign for the GCP output coordinates. This parameter should be "" if no output coordinate system is known.

Returns:
CE_None on success, CE_Failure on failure (including if action is not supported for this format).

CPLErr GDALDataset::SetGeoTransform ( double * ) [virtual]
 

Set the affine transformation coefficients.

See GetGeoTransform() for details on the meaning of the padfTransform coefficients.

This method does the same thing as the C GDALSetGeoTransform() function.

Parameters:
padfTransform   a six double buffer containing the transformation coefficients to be written with the dataset.

Returns:
CE_None on success, or CE_Failure if this transform cannot be written.

CPLErr GDALDataset::SetProjection ( const char * ) [virtual]
 

Set the projection reference string for this dataset.

The string should be in OGC WKT or PROJ.4 format. An error may occur because of incorrectly specified projection strings, because the dataset is not writable, or because the dataset does not support the indicated projection. Many formats do not support writing projections.

This method is the same as the C GDALSetProjection() function.

Parameters:
pszProjection   projection reference string.

Returns:
CE_Failure if an error occurs, otherwise CE_None.


Friends And Related Function Documentation

GDALDatasetH GDALOpen ( const char * pszFilename,
GDALAccess eAccess ) [friend]
 

Open a raster file as a GDALDataset.

See Also: GDALOpenShared

Parameters:
pszFilename   the name of the file to access. In the case of exotic drivers this may not refer to a physical file, but instead contain information for the driver on how to access a dataset.
eAccess   the desired access, either GA_Update or GA_ReadOnly. Many drivers support only read only access.

Returns:
A GDALDatasetH handle or NULL on failure. For C++ applications this handle can be cast to a GDALDataset *.

GDALDatasetH GDALOpenShared ( const char * pszFilename,
GDALAccess eAccess ) [friend]
 

Open a raster file as a GDALDataset.

This function works the same as GDALOpen, but allows the sharing of GDALDataset handles for a dataset with other callers to GDALOpenShared.

In particular, GDALOpenShared will first consult it's list of currently open and shared GDALDataset's, and if the GetDescription() name for one exactly matches the pszFilename passed to GDALOpenShared it

Parameters:
pszFilename   the name of the file to access. In the case of exotic drivers this may not refer to a physical file, but instead contain information for the driver on how to access a dataset.
eAccess   the desired access, either GA_Update or GA_ReadOnly. Many drivers support only read only access.

Returns:
A GDALDatasetH handle or NULL on failure. For C++ applications this handle can be cast to a GDALDataset *.


The documentation for this class was generated from the following files:
Generated at Sat Dec 21 14:02:02 2002 for GDAL by doxygen1.2.3-20001105 written by Dimitri van Heesch, © 1997-2000