class documentation

class Layer(GDALBase):

View In Hierarchy

A class that wraps an OGR Layer, needs to be instantiated from a DataSource object.
Method __getitem__ Get the Feature at the specified index.
Method __init__ No summary
Method __iter__ Iterate over each Feature in the Layer.
Method __len__ The length is the number of features.
Method __str__ The string name of the layer.
Method ​_get​_spatial​_filter Undocumented
Method ​_make​_feature No summary
Method ​_set​_spatial​_filter Undocumented
Method get​_fields Return a list containing the given field name for every Feature in the Layer.
Method get​_geoms Return a list containing the OGRGeometry for every Feature in the Layer.
Method test​_capability No summary
Class Variable spatial​_filter Undocumented
Instance Variable ​_ds Undocumented
Instance Variable ​_ldefn Undocumented
Instance Variable ​_random​_read Undocumented
Instance Variable ptr Undocumented
Property extent Return the extent (an Envelope) of this layer.
Property field​_precisions Return the field precisions for the features.
Property field​_types Return a list of the types of fields in this Layer. For example, return the list [OFTInteger, OFTReal, OFTString] for an OGR layer that has an integer, a floating-point, and string fields.
Property field​_widths Return a list of the maximum field widths for the features.
Property fields Return a list of string names corresponding to each of the Fields available in this Layer.
Property geom​_type Return the geometry type (OGRGeomType) of the Layer.
Property name Return the name of this layer in the Data Source.
Property num​_feat Return the number of features in the Layer.
Property num​_fields Return the number of fields in the Layer.
Property srs Return the Spatial Reference used in this Layer.

Inherited from CPointerBase (via GDALBase):

Method __del__ Free the memory used by the C++ object.
Method ptr.setter Undocumented
Class Variable destructor Undocumented
Instance Variable ​_ptr Undocumented
def __getitem__(self, index):
Get the Feature at the specified index.
def __init__(self, layer_ptr, ds):
Initialize on an OGR C pointer to the Layer and the DataSource object that owns this layer. The DataSource object is required so that a reference to it is kept with this Layer. This prevents garbage collection of the DataSource while this Layer is still active.
def __iter__(self):
Iterate over each Feature in the Layer.
def __len__(self):
The length is the number of features.
def __str__(self):
The string name of the layer.
def _get_spatial_filter(self):

Undocumented

def _make_feature(self, feat_id):
Helper routine for __getitem__ that constructs a Feature from the given Feature ID. If the OGR Layer does not support random-access reading, then each feature of the layer will be incremented through until the a Feature is found matching the given feature ID.
def _set_spatial_filter(self, filter):

Undocumented

def get_fields(self, field_name):
Return a list containing the given field name for every Feature in the Layer.
def get_geoms(self, geos=False):
Return a list containing the OGRGeometry for every Feature in the Layer.
def test_capability(self, capability):

Return a bool indicating whether the this Layer supports the given capability (a string). Valid capability strings include:

'RandomRead', 'SequentialWrite', 'RandomWrite', 'FastSpatialFilter', 'FastFeatureCount', 'FastGetExtent', 'CreateField', 'Transactions', 'DeleteFeature', and 'FastSetNextByIndex'.
spatial_filter =

Undocumented

_ds =

Undocumented

_ldefn =

Undocumented

_random_read =

Undocumented

ptr =
@property
extent =
Return the extent (an Envelope) of this layer.
@property
field_precisions =
Return the field precisions for the features.
@property
field_types =
Return a list of the types of fields in this Layer. For example, return the list [OFTInteger, OFTReal, OFTString] for an OGR layer that has an integer, a floating-point, and string fields.
@property
field_widths =
Return a list of the maximum field widths for the features.
@property
fields =
Return a list of string names corresponding to each of the Fields available in this Layer.
@property
geom_type =
Return the geometry type (OGRGeomType) of the Layer.
@property
name =
Return the name of this layer in the Data Source.
@property
num_feat =
Return the number of features in the Layer.
@property
num_fields =
Return the number of fields in the Layer.
@property
srs =
Return the Spatial Reference used in this Layer.