Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Friends

GDALDataset Class Reference

A set of associated raster bands, usually from one file. More...

#include <gdal_priv.h>

Inheritance diagram for GDALDataset:
GDALMajorObject GDALPamDataset GDALProxyDataset VRTDataset GDALGeorefPamDataset GDALProxyPoolDataset VRTWarpedDataset GDALJP2AbstractDataset

List of all members.

Public Member Functions

virtual ~GDALDataset ()
 Destroy an open GDALDataset.
int GetRasterXSize (void)
 Fetch raster width in pixels.
int GetRasterYSize (void)
 Fetch raster height in pixels.
int GetRasterCount (void)
 Fetch the number of raster bands on this dataset.
GDALRasterBandGetRasterBand (int)
 Fetch a band object for a dataset.
virtual void FlushCache (void)
 Flush all write cached data to disk.
virtual const char * GetProjectionRef (void)
 Fetch the projection definition string for this dataset.
virtual CPLErr SetProjection (const char *)
 Set the projection reference string for this dataset.
virtual CPLErr GetGeoTransform (double *)
 Fetch the affine transformation coefficients.
virtual CPLErr SetGeoTransform (double *)
 Set the affine transformation coefficients.
virtual CPLErr AddBand (GDALDataType eType, char **papszOptions=NULL)
 Add a band to a dataset.
virtual void * GetInternalHandle (const char *)
 Fetch a format specific internally meaningful handle.
virtual GDALDriverGetDriver (void)
 Fetch the driver to which this dataset relates.
virtual char ** GetFileList (void)
 Fetch files forming dataset.
virtual int GetGCPCount ()
 Get number of GCPs.
virtual const char * GetGCPProjection ()
 Get output projection for GCPs.
virtual const GDAL_GCPGetGCPs ()
 Fetch GCPs.
virtual CPLErr SetGCPs (int nGCPCount, const GDAL_GCP *pasGCPList, const char *pszGCPProjection)
 Assign GCPs.
virtual CPLErr AdviseRead (int nXOff, int nYOff, int nXSize, int nYSize, int nBufXSize, int nBufYSize, GDALDataType eDT, int nBandCount, int *panBandList, char **papszOptions)
 Advise driver of upcoming read requests.
virtual CPLErr CreateMaskBand (int nFlags)
 Adds a mask band to the dataset.
virtual GDALAsyncReaderBeginAsyncReader (int nXOff, int nYOff, int nXSize, int nYSize, void *pBuf, int nBufXSize, int nBufYSize, GDALDataType eBufType, int nBandCount, int *panBandMap, int nPixelSpace, int nLineSpace, int nBandSpace, char **papszOptions)
 Sets up an asynchronous data request.
virtual void EndAsyncReader (GDALAsyncReader *)
 End asynchronous request.
CPLErr RasterIO (GDALRWFlag, int, int, int, int, void *, int, int, GDALDataType, int, int *, int, int, int)
 Read/write a region of image data from multiple bands.
int Reference ()
 Add one to dataset reference count.
int Dereference ()
 Subtract one from dataset reference count.
GDALAccess GetAccess ()
int GetShared ()
 Returns shared flag.
void MarkAsShared ()
 Mark this dataset as available for sharing.
CPLErr BuildOverviews (const char *, int, int *, int, int *, GDALProgressFunc, void *)
 Build raster overview(s).
void ReportError (CPLErr eErrClass, int err_no, const char *fmt,...)
 Emits an error related to a dataset.

Static Public Member Functions

static GDALDataset ** GetOpenDatasets (int *pnDatasetCount)
 Fetch all open GDAL dataset handles.

Protected Member Functions

void RasterInitialize (int, int)
void SetBand (int, GDALRasterBand *)
virtual CPLErr IBuildOverviews (const char *, int, int *, int, int *, GDALProgressFunc, void *)
virtual CPLErr IRasterIO (GDALRWFlag, int, int, int, int, void *, int, int, GDALDataType, int, int *, int, int, int)
CPLErr BlockBasedRasterIO (GDALRWFlag, int, int, int, int, void *, int, int, GDALDataType, int, int *, int, int, int)
void BlockBasedFlushCache ()
CPLErr ValidateRasterIOOrAdviseReadParameters (const char *pszCallingFunc, int *pbStopProcessingOnCENone, int nXOff, int nYOff, int nXSize, int nYSize, int nBufXSize, int nBufYSize, int nBandCount, int *panBandMap)
virtual int CloseDependentDatasets ()
 Drop references to any other datasets referenced by this dataset.

Protected Attributes

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

Friends

class GDALDriver
class GDALDefaultOverviews
class GDALProxyDataset
class GDALDriverManager
class GDALRasterBand
GDALDatasetH GDALOpen (const char *, GDALAccess)
 Open a raster file as a GDALDataset.
GDALDatasetH GDALOpenShared (const char *, GDALAccess)
 Open a raster file as a GDALDataset.
GDALDatasetH GDALOpenInternal (const char *, GDALAccess, const char *const *papszAllowedDrivers)
GDALDatasetH GDALOpenInternal (GDALOpenInfo &oOpenInfo, const char *const *papszAllowedDrivers)

Detailed Description

A set of associated raster bands, usually from one file.

A dataset encapsulating one or more raster bands.

Details are further discussed in the GDAL Data Model.

Use GDALOpen() or GDALOpenShared() to create a GDALDataset for a named file, or GDALDriver::Create() or GDALDriver::CreateCopy() to create a new dataset.


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.

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

For Windows users, it is not recommended to use the delete operator on the dataset object because of known issues when allocating and freeing memory across module boundaries. Calling GDALClose() is then a better option.


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

Reimplemented in VRTDataset, and VRTWarpedDataset.

CPLErr GDALDataset::AdviseRead ( int  nXOff,
int  nYOff,
int  nXSize,
int  nYSize,
int  nBufXSize,
int  nBufYSize,
GDALDataType  eBufType,
int  nBandCount,
int *  panBandMap,
char **  papszOptions 
) [virtual]

Advise driver of upcoming read requests.

Some GDAL drivers operate more efficiently if they know in advance what set of upcoming read requests will be made. The AdviseRead() method allows an application to notify the driver of the region and bands of interest, and at what resolution the region will be read.

Many drivers just ignore the AdviseRead() call, but it can dramatically accelerate access via some drivers.

Parameters:
nXOff The pixel offset to the top left corner of the region of the band to be accessed. This would be zero to start from the left side.
nYOff The line offset to the top left corner of the region of the band to be accessed. This would be zero to start from the top.
nXSize The width of the region of the band to be accessed in pixels.
nYSize The height of the region of the band to be accessed in lines.
nBufXSize the width of the buffer image into which the desired region is to be read, or from which it is to be written.
nBufYSize the height of the buffer image into which the desired region is to be read, or from which it is to be written.
eBufType the type of the pixel values in the pData data buffer. The pixel values will automatically be translated to/from the GDALRasterBand data type as needed.
nBandCount the number of bands being read or written.
panBandMap the list of nBandCount band numbers being read/written. Note band numbers are 1 based. This may be NULL to select the first nBandCount bands.
papszOptions a list of name=value strings with special control options. Normally this is NULL.
Returns:
CE_Failure if the request is invalid and CE_None if it works or is ignored.

Reimplemented in GDALProxyDataset.

GDALAsyncReader * GDALDataset::BeginAsyncReader ( int  nXOff,
int  nYOff,
int  nXSize,
int  nYSize,
void *  pBuf,
int  nBufXSize,
int  nBufYSize,
GDALDataType  eBufType,
int  nBandCount,
int *  panBandMap,
int  nPixelSpace,
int  nLineSpace,
int  nBandSpace,
char **  papszOptions 
) [virtual]

Sets up an asynchronous data request.

This method establish an asynchronous raster read request for the indicated window on the dataset into the indicated buffer. The parameters for windowing, buffer size, buffer type and buffer organization are similar to those for GDALDataset::RasterIO(); however, this call only launches the request and filling the buffer is accomplished via calls to GetNextUpdatedRegion() on the return GDALAsyncReader session object.

Once all processing for the created session is complete, or if no further refinement of the request is required, the GDALAsyncReader object should be destroyed with the GDALDataset::EndAsyncReader() method.

Note that the data buffer (pData) will potentially continue to be updated as long as the session lives, but it is not deallocated when the session (GDALAsyncReader) is destroyed with EndAsyncReader(). It should be deallocated by the application at that point.

Additional information on asynchronous IO in GDAL may be found at: http://trac.osgeo.org/gdal/wiki/rfc24_progressive_data_support

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

Parameters:
nXOff The pixel offset to the top left corner of the region of the band to be accessed. This would be zero to start from the left side.
nYOff The line offset to the top left corner of the region of the band to be accessed. This would be zero to start from the top.
nXSize The width of the region of the band to be accessed in pixels.
nYSize The height of the region of the band to be accessed in lines.
pBuf The buffer into which the data should be read. This buffer must contain at least nBufXSize * nBufYSize * nBandCount words of type eBufType. It is organized in left to right,top to bottom pixel order. Spacing is controlled by the nPixelSpace, and nLineSpace parameters.
nBufXSize the width of the buffer image into which the desired region is to be read, or from which it is to be written.
nBufYSize the height of the buffer image into which the desired region is to be read, or from which it is to be written.
eBufType the type of the pixel values in the pData data buffer. The pixel values will automatically be translated to/from the GDALRasterBand data type as needed.
nBandCount the number of bands being read or written.
panBandMap the list of nBandCount band numbers being read/written. Note band numbers are 1 based. This may be NULL to select the first nBandCount bands.
nPixelSpace The byte offset from the start of one pixel value in pData to the start of the next pixel value within a scanline. If defaulted (0) the size of the datatype eBufType is used.
nLineSpace The byte offset from the start of one scanline in pData to the start of the next. If defaulted the size of the datatype eBufType * nBufXSize is used.
nBandSpace the byte offset from the start of one bands data to the start of the next. If defaulted (zero) the value will be nLineSpace * nBufYSize implying band sequential organization of the data buffer.
papszOptions Driver specific control options in a string list or NULL. Consult driver documentation for options supported.
Returns:
The GDALAsyncReader object representing the request.
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 CPLGetLastErrorNo() will return CPLE_NotSupported.

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

Parameters:
pszResampling one of "NEAREST", "GAUSS", "CUBIC", "AVERAGE", "MODE", "AVERAGE_MAGPHASE" or "NONE" controlling the downsampling method applied.
nOverviews number of overviews to build.
panOverviewList the list of overview decimation factors to build.
nListBands 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 );
 
See also:
GDALRegenerateOverviews()
int GDALDataset::CloseDependentDatasets (  )  [protected, virtual]

Drop references to any other datasets referenced by this dataset.

This method should release any reference to other datasets (e.g. a VRT dataset to its sources), but not close the current dataset itself.

If at least, one reference to a dependent dataset has been dropped, this method should return TRUE. Otherwise it *should* return FALSE. (Failure to return the proper value might result in infinite loop)

This method can be called several times on a given dataset. After the first time, it should not do anything and return FALSE.

The driver implementation may choose to destroy its raster bands, so be careful not to call any method on the raster bands afterwards.

Basically the only safe action you can do after calling CloseDependantDatasets() is to call the destructor.

Note: the only legitimate caller of CloseDependantDatasets() is GDALDriverManager::~GDALDriverManager()

Returns:
TRUE if at least one reference to another dataset has been dropped.

Reimplemented in VRTDataset, and VRTWarpedDataset.

CPLErr GDALDataset::CreateMaskBand ( int  nFlags  )  [virtual]

Adds a mask band to the dataset.

The default implementation of the CreateMaskBand() method is implemented based on similar rules to the .ovr handling implemented using the GDALDefaultOverviews object. A TIFF file with the extension .msk will be created with the same basename as the original file, and it will have one band. The mask images will be deflate compressed tiled images with the same block size as the original image if possible.

Note that if you got a mask band with a previous call to GetMaskBand(), it might be invalidated by CreateMaskBand(). So you have to call GetMaskBand() again.

Since:
GDAL 1.5.0
Parameters:
nFlags ignored. GMF_PER_DATASET will be assumed.
Returns:
CE_None on success or CE_Failure on an error.
See also:
http://trac.osgeo.org/gdal/wiki/rfc15_nodatabitmask

Reimplemented in GDALProxyDataset, and VRTDataset.

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::EndAsyncReader ( GDALAsyncReader poARIO  )  [virtual]

End asynchronous request.

This method destroys an asynchronous io request and recovers all resources associated with it.

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

Parameters:
poARIO pointer to a GDALAsyncReader
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.

Using this method does not prevent use from calling GDALClose() to properly close a dataset and ensure that important data not addressed by FlushCache() is written in the file.

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

Reimplemented in GDALPamDataset, GDALProxyDataset, and VRTDataset.

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

Reimplemented in GDALProxyDataset.

char ** GDALDataset::GetFileList ( void   )  [virtual]

Fetch files forming dataset.

Returns a list of files believed to be part of this dataset. If it returns an empty list of files it means there is believed to be no local file system files associated with the dataset (for instance a virtual dataset). The returned file list is owned by the caller and should be deallocated with CSLDestroy().

The returned filenames will normally be relative or absolute paths depending on the path used to originally open the dataset. The strings will be UTF-8 encoded.

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

Returns:
NULL or a NULL terminated array of file names.

Reimplemented in GDALPamDataset, GDALProxyDataset, VRTDataset, and VRTWarpedDataset.

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.

Reimplemented in GDALPamDataset, GDALProxyDataset, GDALGeorefPamDataset, and VRTDataset.

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. It should not be altered, freed or expected to last for long.

Reimplemented in GDALPamDataset, GDALProxyDataset, GDALProxyPoolDataset, GDALGeorefPamDataset, and VRTDataset.

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.

Reimplemented in GDALPamDataset, GDALProxyDataset, GDALProxyPoolDataset, GDALGeorefPamDataset, and VRTDataset.

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.

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.

Reimplemented in GDALPamDataset, GDALProxyDataset, GDALProxyPoolDataset, GDALGeorefPamDataset, and VRTDataset.

void * GDALDataset::GetInternalHandle ( const char *  pszHandleName  )  [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.

Reimplemented in GDALProxyDataset, and GDALProxyPoolDataset.

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

Fetch all open GDAL dataset handles.

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

NOTE: This method is not thread safe. The returned list may change at any time and it should not be freed.

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 OpenGIS WKT format. It should be suitable for use with the OGRSpatialReference class.

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.
See also:
http://www.gdal.org/ogr/osr_tutorial.html

Reimplemented in GDALPamDataset, GDALProxyDataset, GDALProxyPoolDataset, GDALGeorefPamDataset, and VRTDataset.

GDALRasterBand * GDALDataset::GetRasterBand ( int  nBandId  ) 

Fetch a band object for a dataset.

Equivalent of the C function GDALGetRasterBand().

Parameters:
nBandId the index number of the band to fetch, from 1 to GetRasterCount().
Returns:
the nBandId th band object
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.

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

Equivalent 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.
CPLErr GDALDataset::RasterIO ( GDALRWFlag  eRWFlag,
int  nXOff,
int  nYOff,
int  nXSize,
int  nYSize,
void *  pData,
int  nBufXSize,
int  nBufYSize,
GDALDataType  eBufType,
int  nBandCount,
int *  panBandMap,
int  nPixelSpace,
int  nLineSpace,
int  nBandSpace 
)

Read/write a region of image data from multiple bands.

This method allows reading a region of one or more GDALRasterBands from this dataset into a buffer, or writing data from a buffer into a region of the GDALRasterBands. It automatically takes care of data type translation if the data type (eBufType) of the buffer is different than that of the GDALRasterBand. The method also takes care of image decimation / replication if the buffer size (nBufXSize x nBufYSize) is different than the size of the region being accessed (nXSize x nYSize).

The nPixelSpace, nLineSpace and nBandSpace parameters allow reading into or writing from various organization of buffers.

For highest performance full resolution data access, read and write on "block boundaries" as returned by GetBlockSize(), or use the ReadBlock() and WriteBlock() methods.

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

Parameters:
eRWFlag Either GF_Read to read a region of data, or GF_Write to write a region of data.
nXOff The pixel offset to the top left corner of the region of the band to be accessed. This would be zero to start from the left side.
nYOff The line offset to the top left corner of the region of the band to be accessed. This would be zero to start from the top.
nXSize The width of the region of the band to be accessed in pixels.
nYSize The height of the region of the band to be accessed in lines.
pData The buffer into which the data should be read, or from which it should be written. This buffer must contain at least nBufXSize * nBufYSize * nBandCount words of type eBufType. It is organized in left to right,top to bottom pixel order. Spacing is controlled by the nPixelSpace, and nLineSpace parameters.
nBufXSize the width of the buffer image into which the desired region is to be read, or from which it is to be written.
nBufYSize the height of the buffer image into which the desired region is to be read, or from which it is to be written.
eBufType the type of the pixel values in the pData data buffer. The pixel values will automatically be translated to/from the GDALRasterBand data type as needed.
nBandCount the number of bands being read or written.
panBandMap the list of nBandCount band numbers being read/written. Note band numbers are 1 based. This may be NULL to select the first nBandCount bands.
nPixelSpace The byte offset from the start of one pixel value in pData to the start of the next pixel value within a scanline. If defaulted (0) the size of the datatype eBufType is used.
nLineSpace The byte offset from the start of one scanline in pData to the start of the next. If defaulted (0) the size of the datatype eBufType * nBufXSize is used.
nBandSpace the byte offset from the start of one bands data to the start of the next. If defaulted (0) the value will be nLineSpace * nBufYSize implying band sequential organization of the data buffer.
Returns:
CE_Failure if the access fails, otherwise CE_None.
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.
void GDALDataset::ReportError ( CPLErr  eErrClass,
int  err_no,
const char *  fmt,
  ... 
)

Emits an error related to a dataset.

This function is a wrapper for regular CPLError(). The only difference with CPLError() is that it prepends the error message with the dataset name.

Parameters:
eErrClass one of CE_Warning, CE_Failure or CE_Fatal.
err_no the error number (CPLE_*) from cpl_error.h.
fmt a printf() style format string. Any additional arguments will be treated as arguments to fill in this format in a manner similar to printf().
Since:
GDAL 1.9.0
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 responsible for deallocating these arguments if appropriate.

Most formats do not support setting of GCPs, even formats 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).

Reimplemented in GDALPamDataset, GDALProxyDataset, and VRTDataset.

CPLErr GDALDataset::SetGeoTransform ( double *  padfTransform  )  [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.

Reimplemented in GDALPamDataset, GDALProxyDataset, GDALProxyPoolDataset, and VRTDataset.

CPLErr GDALDataset::SetProjection ( const char *  pszProjection  )  [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.

Reimplemented in GDALPamDataset, GDALProxyDataset, GDALProxyPoolDataset, and VRTDataset.


Friends And Related Function Documentation

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

Open a raster file as a GDALDataset.

This function will try to open the passed file, or virtual dataset name by invoking the Open method of each registered GDALDriver in turn. The first successful open will result in a returned dataset. If all drivers fail then NULL is returned and an error is issued.

Several recommendations :

  • If you open a dataset object with GA_Update access, it is not recommended to open a new dataset on the same underlying file.
  • The returned dataset should only be accessed by one thread at a time. If you want to use it from different threads, you must add all necessary code (mutexes, etc.) to avoid concurrent use of the object. (Some drivers, such as GeoTIFF, maintain internal state variables that are updated each time a new block is read, thus preventing concurrent use.)

For drivers supporting the VSI virtual file API, it is possible to open a file in a .zip archive (see VSIInstallZipFileHandler()), in a .tar/.tar.gz/.tgz archive (see VSIInstallTarFileHandler()) or on a HTTP / FTP server (see VSIInstallCurlFileHandler())

In some situations (dealing with unverified data), the datasets can be opened in another process through the GDAL API Proxy mechanism.

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. It should be in UTF-8 encoding.
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 will be referenced and returned.

Starting with GDAL 1.6.0, if GDALOpenShared() is called on the same pszFilename from two different threads, a different GDALDataset object will be returned as it is not safe to use the same dataset from different threads, unless the user does explicitely use mutexes in its code.

For drivers supporting the VSI virtual file API, it is possible to open a file in a .zip archive (see VSIInstallZipFileHandler()), in a .tar/.tar.gz/.tgz archive (see VSIInstallTarFileHandler()) or on a HTTP / FTP server (see VSIInstallCurlFileHandler())

In some situations (dealing with unverified data), the datasets can be opened in another process through the GDAL API Proxy mechanism.

See also:
GDALOpen()
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. It should be in UTF-8 encoding.
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 for GDAL by doxygen 1.7.1.