Package osgeo :: Module ogr :: Class DataSource
[hide private]
[frames] | no frames]

Class DataSource

source code


Proxy of C++ OGRDataSourceShadow class

Instance Methods [hide private]
 
__init__(self, *args, **kwargs) source code
 
__repr__(self) source code
int
GetRefCount(self)
int OGR_DS_GetRefCount(OGRDataSourceH hDataSource)
source code
int
GetSummaryRefCount(self)
int OGR_DS_GetSummaryRefCount(OGRDataSourceH hDataSource)
source code
int
GetLayerCount(self)
int OGR_DS_GetLayerCount(OGRDataSourceH hDS)
source code
Driver
GetDriver(self)
OGRSFDriverH OGR_DS_GetDriver(OGRDataSourceH hDS)
source code
char
GetName(self)
const char* OGR_DS_GetName(OGRDataSourceH hDS)
source code
OGRErr
SyncToDisk(self)
OGRErr OGR_DS_SyncToDisk(OGRDataSourceH hDS)
source code
 
CreateLayer(self, *args, **kwargs)
CreateLayer(self, char name, SpatialReference srs = None, OGRwkbGeometryType geom_type = wkbUnknown, char options = None) -> Layer
source code
 
CopyLayer(self, *args, **kwargs)
CopyLayer(self, Layer src_layer, char new_name, char options = None) -> Layer
source code
 
GetLayerByIndex(self, *args)
GetLayerByIndex(self, int index = 0) -> Layer
source code
 
GetLayerByName(self, *args)
GetLayerByName(self, char layer_name) -> Layer
source code
 
TestCapability(self, *args)
TestCapability(self, char cap) -> bool
source code
 
ExecuteSQL(self, *args, **kwargs)
ExecuteSQL(self, char statement, Geometry spatialFilter = None, char dialect = "") -> Layer
source code
 
ReleaseResultSet(self, *args)
ReleaseResultSet(self, Layer layer)
source code
 
Destroy(self)
Once called, self has effectively been destroyed.
source code
 
Release(self)
Once called, self has effectively been destroyed.
source code
 
Reference(self)
For backwards compatibility only.
source code
 
Dereference(self)
For backwards compatibility only.
source code
 
__len__(self)
Returns the number of layers on the datasource
source code
 
__getitem__(self, value)
Support dictionary, list, and slice -like access to the datasource.
source code
 
GetLayer(self, iLayer=0)
Return the layer given an index or a name
source code
 
DeleteLayer(self, value)
Deletes the layer given an index or layer name
source code
Class Variables [hide private]
  __swig_setmethods__ = {}
  __setattr__ = lambda self, name, value:
  __swig_getmethods__ = {}
  __getattr__ = lambda self, name:
  __swig_destroy__ = _ogr.delete_DataSource
  __del__ = lambda self:
Method Details [hide private]

GetLayerCount(self)

source code 
int
OGR_DS_GetLayerCount(OGRDataSourceH hDS)

Get the number of layers in this data source.

This function is the same as the C++ method
OGRDataSource::GetLayerCount().

Parameters:
-----------

hDS:  handle to the data source from which to get the number of
layers.

layer count. 

Returns: int

GetDriver(self)

source code 
OGRSFDriverH
OGR_DS_GetDriver(OGRDataSourceH hDS)

Returns the driver that the dataset was opened with.

This method is the same as the C++ method OGRDataSource::GetDriver()

Parameters:
-----------

hDS:  handle to the datasource

NULL if driver info is not available, or pointer to a driver owned by
the OGRSFDriverManager. 

Returns: Driver

GetName(self)

source code 
const char*
OGR_DS_GetName(OGRDataSourceH hDS)

Returns the name of the data source.

This string should be sufficient to open the data source if passed to
the same OGRSFDriver that this data source was opened with, but it
need not be exactly the same string that was used to open the data
source. Normally this is a filename.

This function is the same as the C++ method OGRDataSource::GetName().

Parameters:
-----------

hDS:  handle to the data source to get the name from.

pointer to an internal name string which should not be modified or
freed by the caller. 

Returns: char

SyncToDisk(self)

source code 
OGRErr
OGR_DS_SyncToDisk(OGRDataSourceH hDS)

Flush pending changes to disk.

This call is intended to force the datasource to flush any pending
writes to disk, and leave the disk file in a consistent state. It
would not normally have any effect on read-only datasources.

Some data sources do not implement this method, and will still return
OGRERR_NONE. An error is only returned if an error occurs while
attempting to flush to disk.

The default implementation of this method just calls the SyncToDisk()
method on each of the layers. Conceptionally, calling SyncToDisk() on
a datasource should include any work that might be accomplished by
calling SyncToDisk() on layers in that data source.

In any event, you should always close any opened datasource with
OGR_DS_Destroy() that will ensure all data is correctly flushed.

This method is the same as the C++ method OGRDataSource::SyncToDisk()

Parameters:
-----------

hDS:  handle to the data source

OGRERR_NONE if no error occurs (even if nothing is done) or an error
code. 

Returns: OGRErr

CreateLayer(self, *args, **kwargs)

source code 

CreateLayer(self, char name, SpatialReference srs = None, OGRwkbGeometryType geom_type = wkbUnknown, 
    char options = None) -> Layer

OGRLayerH
OGR_DS_CreateLayer(OGRDataSourceH hDS, const char *pszName,
OGRSpatialReferenceH hSpatialRef, OGRwkbGeometryType eType, char
**papszOptions)

This function attempts to create a new layer on the data source with
the indicated name, coordinate system, geometry type.

The papszOptions argument can be used to control driver specific
creation options. These options are normally documented in the format
specific documentation.

This function is the same as the C++ method
OGRDataSource::CreateLayer().

Parameters:
-----------

hDS:  The dataset handle.

pszName:  the name for the new layer. This should ideally not match
any existing layer on the datasource.

hSpatialRef:  handle to the coordinate system to use for the new
layer, or NULL if no coordinate system is available.

eType:  the geometry type for the layer. Use wkbUnknown if there are
no constraints on the types geometry to be written.

papszOptions:  a StringList of name=value options. Options are driver
specific, and driver information can be found at the following
url:http://www.gdal.org/ogr/ogr_formats.html

NULL is returned on failure, or a new OGRLayer handle on success.
Example: 

CopyLayer(self, *args, **kwargs)

source code 

CopyLayer(self, Layer src_layer, char new_name, char options = None) -> Layer

OGRLayerH
OGR_DS_CopyLayer(OGRDataSourceH hDS, OGRLayerH hSrcLayer, const char
*pszNewName, char **papszOptions)

Duplicate an existing layer.

This function creates a new layer, duplicate the field definitions of
the source layer and then duplicate each features of the source layer.
The papszOptions argument can be used to control driver specific
creation options. These options are normally documented in the format
specific documentation. The source layer may come from another
dataset.

This function is the same as the C++ method OGRDataSource::CopyLayer

Parameters:
-----------

hDS:  handle to the data source where to create the new layer

hSrcLayer:  handle to the source layer.

pszNewName:  the name of the layer to create.

papszOptions:  a StringList of name=value options. Options are driver
specific.

an handle to the layer, or NULL if an error occurs. 

GetLayerByName(self, *args)

source code 

GetLayerByName(self, char layer_name) -> Layer

OGRLayerH
OGR_DS_GetLayerByName(OGRDataSourceH hDS, const char *pszName)

Fetch a layer by name.

The returned layer remains owned by the OGRDataSource and should not
be deleted by the application.

This function is the same as the C++ method
OGRDataSource::GetLayerByName().

Parameters:
-----------

hDS:  handle to the data source from which to get the layer.

pszLayerName:  Layer the layer name of the layer to fetch.

an handle to the layer, or NULL if the layer is not found or an error
occurs. 

TestCapability(self, *args)

source code 

TestCapability(self, char cap) -> bool

int
OGR_DS_TestCapability(OGRDataSourceH hDS, const char *pszCap)

Test if capability is available.

One of the following data source capability names can be passed into
this function, and a TRUE or FALSE value will be returned indicating
whether or not the capability is available for this object.

ODsCCreateLayer: True if this datasource can create new layers.

The #define macro forms of the capability names should be used in
preference to the strings themselves to avoid mispelling.

This function is the same as the C++ method
OGRDataSource::TestCapability().

Parameters:
-----------

hDS:  handle to the data source against which to test the capability.

pszCapability:  the capability to test.

TRUE if capability available otherwise FALSE. 

ExecuteSQL(self, *args, **kwargs)

source code 

ExecuteSQL(self, char statement, Geometry spatialFilter = None, char dialect = "") -> Layer

OGRLayerH
OGR_DS_ExecuteSQL(OGRDataSourceH hDS, const char *pszStatement,
OGRGeometryH hSpatialFilter, const char *pszDialect)

Execute an SQL statement against the data store.

The result of an SQL query is either NULL for statements that are in
error, or that have no results set, or an OGRLayer handle representing
a results set from the query. Note that this OGRLayer is in addition
to the layers in the data store and must be destroyed with
OGR_DS_ReleaseResultSet() before the data source is closed
(destroyed).

For more information on the SQL dialect supported internally by OGR
review theOGR SQL document. Some drivers (ie. Oracle and PostGIS) pass
the SQL directly through to the underlying RDBMS.

This function is the same as the C++ method
OGRDataSource::ExecuteSQL();

Parameters:
-----------

hDS:  handle to the data source on which the SQL query is executed.

pszSQLCommand:  the SQL statement to execute.

hSpatialFilter:  handle to a geometry which represents a spatial
filter. Can be NULL.

pszDialect:  allows control of the statement dialect. If set to NULL,
the OGR SQL engine will be used, except for RDBMS drivers that will
use their dedicated SQL engine, unless OGRSQL is explicitely passed as
the dialect.

an handle to a OGRLayer containing the results of the query.
Deallocate with OGR_DS_ReleaseResultSet(). 

ReleaseResultSet(self, *args)

source code 

ReleaseResultSet(self, Layer layer)

void
OGR_DS_ReleaseResultSet(OGRDataSourceH hDS, OGRLayerH hLayer)

Release results of OGR_DS_ExecuteSQL().

This function should only be used to deallocate OGRLayers resulting
from an OGR_DS_ExecuteSQL() call on the same OGRDataSource. Failure to
deallocate a results set before destroying the OGRDataSource may cause
errors.

This function is the same as the C++ method
OGRDataSource::ReleaseResultSet().

Parameters:
-----------

hDS:  an handle to the data source on which was executed an SQL query.

hLayer:  handle to the result of a previous OGR_DS_ExecuteSQL() call.

Destroy(self)

source code 

Once called, self has effectively been destroyed. Do not access. For backwards compatiblity only

Release(self)

source code 

Once called, self has effectively been destroyed. Do not access. For backwards compatiblity only

__getitem__(self, value)
(Indexing operator)

source code 

Support dictionary, list, and slice -like access to the datasource. ] would return the first layer on the datasource. aname'] would return the layer named "aname". :4] would return a list of the first four layers.