# osgeo.ogr module

osgeo.ogr.ApproximateArcAngles(double dfCenterX, double dfCenterY, double dfZ, double dfPrimaryRadius, double dfSecondaryAxis, double dfRotation, double dfStartAngle, double dfEndAngle, double dfMaxAngleStepSizeDegrees) → Geometry

class osgeo.ogr.ArrowArray(*args, **kwargs)

  Bases: `object`

  Proxy of C++ ArrowArray class.

  GetChildrenCount(ArrowArray self) → GIntBig
  GetLength(ArrowArray self) → GIntBig
  property thisown

    The membership flag

class osgeo.ogr.ArrowArrayStream(*args, **kwargs)

  Bases: `object`

  Proxy of C++ ArrowArrayStream class.

  GetNextRecordBatch(ArrowArrayStream self, char ** options=None) → ArrowArray
  GetSchema(ArrowArrayStream self) → ArrowSchema
  property thisown

    The membership flag

class osgeo.ogr.ArrowSchema(*args, **kwargs)

  Bases: `object`

  Proxy of C++ ArrowSchema class.

  GetChildrenCount(ArrowSchema self) → GIntBig
  property thisown

    The membership flag

osgeo.ogr.BuildPolygonFromEdges(Geometry hLineCollection, int bBestEffort=0, int bAutoClose=0, double dfTolerance=0) → Geometry

osgeo.ogr.CreateCodedFieldDomain(char const * name, char const * description, OGRFieldType type, OGRFieldSubType subtype, OGRCodedValue const * enumeration) → FieldDomain

osgeo.ogr.CreateGeometryFromEsriJson(char const * input_string) → Geometry

osgeo.ogr.CreateGeometryFromGML(char const * input_string) → Geometry

osgeo.ogr.CreateGeometryFromJson(char const * input_string) → Geometry

osgeo.ogr.CreateGeometryFromWkb(size_t len, SpatialReference reference=None) → Geometry

osgeo.ogr.CreateGeometryFromWkt(char ** val, SpatialReference reference=None) → Geometry

osgeo.ogr.CreateGlobFieldDomain(char const * name, char const * description, OGRFieldType type, OGRFieldSubType subtype, char const * glob) → FieldDomain

osgeo.ogr.CreateRangeFieldDomain(char const * name, char const * description, OGRFieldType type, OGRFieldSubType subtype, double min, bool minIsInclusive, double max, double maxIsInclusive) → FieldDomain

class osgeo.ogr.DataSource(*args, **kwargs)

  Bases: `MajorObject`

  Proxy of C++ OGRDataSourceShadow class.

  AbortSQL(DataSource self) → OGRErr
  CommitTransaction(DataSource self) → OGRErr
  CopyLayer(DataSource self, Layer src_layer, char const * 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.

    Deprecated Use GDALDatasetCopyLayer() in GDAL 2.0

    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.

    Returns:

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

    Return type:

      OGRLayerH

  CreateLayer(DataSource self, char const * 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.

    Deprecated Use GDALDatasetCreateLayer() in GDAL 2.0

    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. The driver might only increase the reference counter of the object to take ownership, and not make a full copy, so do not use OSRDestroySpatialReference(), but OSRRelease() instead when you are done with the object.

      - 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_formats.html

    Returns:

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

    Return type:

      OGRLayerH

  DeleteLayer(DataSource self, value) → OGRErr

    Delete the indicated layer from the datasource.

    For more details: `OGR_DS_DeleteLayer()`

    Parameters:

      value (str | int) – index or name of the layer to delete.

    Returns:

      `osgeo.ogr.OGRERR_NONE` on success, or `osgeo.ogr.OGRERR_UNSUPPORTED_OPERATION` if deleting layers is not supported for this datasource.

    Return type:

      int

  Dereference()

    For backwards compatibility only.

  Destroy()

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

  ExecuteSQL(self, statement, spatialFilter: ogr.Geometry = None, dialect: Optional[str] = '', keep_ref_on_ds=False) → ogr.Layer

    Execute a SQL statement against the dataset

    The result of a SQL query is:

      - None (or an exception if exceptions are enabled) for statements that are in error

      - or None for statements that have no results set,

      - or a ogr.Layer handle representing a results set from the query.

    Note that this ogr.Layer is in addition to the layers in the data store and must be released with ReleaseResultSet() before the data source is closed (destroyed).

    Starting with GDAL 3.7, this method can also be used as a context manager, as a convenient way of automatically releasing the returned result layer.

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

    The SQLITE dialect can also be used (SQL SQLite dialect)

    Parameters:

      - statement – the SQL statement to execute (e.g “SELECT * FROM layer”)

      - spatialFilter – a geometry which represents a spatial filter. Can be None

      - dialect – allows control of the statement dialect. If set to None or empty string, the OGR SQL engine will be used, except for RDBMS drivers that will use their dedicated SQL engine, unless OGRSQL is explicitly passed as the dialect. The SQLITE dialect can also be used.

      - keep_ref_on_ds – whether the returned layer should keep a (strong) reference on the current dataset. Cf example 2 for a use case.

    Returns:

      a ogr.Layer containing the results of the query, that will be automatically released when the context manager goes out of scope.

    Return type:

      ogr.Layer

    Examples

    1. Use as a context manager:

        >>> with ds.ExecuteSQL("SELECT * FROM layer") as lyr:
        ...     print(lyr.GetFeatureCount())

    2. Use keep_ref_on_ds=True to return an object that keeps a reference to its dataset:

        >>> def get_sql_lyr():
        ...     return gdal.OpenEx("test.shp").ExecuteSQL("SELECT * FROM test", keep_ref_on_ds=True)
        ...
        ... with get_sql_lyr() as lyr:
        ...     print(lyr.GetFeatureCount())

  FlushCache(DataSource self)
  GetDriver(DataSource self) → Driver

    OGRSFDriverH OGR_DS_GetDriver(OGRDataSourceH hDS)

    Returns the driver that the dataset was opened with.

    NOTE: Starting with GDAL 2.0, it is NOT safe to cast the returned handle to OGRSFDriver*. If a C++ object is needed, the handle should be cast to GDALDriver*.

    Deprecated Use GDALGetDatasetDriver() in GDAL 2.0

    Parameters:

      hDS – handle to the datasource

    Returns:

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

    Return type:

      OGRSFDriverH

  GetLayer(iLayer=0)

    Return the layer given an index or a name

  GetLayerByIndex(DataSource self, int index=0) → Layer
  GetLayerByName(DataSource self, char const * layer_name) → Layer

    OGRLayerH OGR_DS_GetLayerByName(OGRDataSourceH hDS, const char *pszLayerName)

    Fetch a layer by name.

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

    Deprecated Use GDALDatasetGetLayerByName() in GDAL 2.0

    Parameters:

      - hDS – handle to the data source from which to get the layer.

      - pszLayerName – Layer the layer name of the layer to fetch.

    Returns:

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

    Return type:

      OGRLayerH

  GetLayerCount(DataSource self) → int

    int OGR_DS_GetLayerCount(OGRDataSourceH hDS)

    Get the number of layers in this data source.

    Deprecated Use GDALDatasetGetLayerCount() in GDAL 2.0

    Parameters:

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

    Returns:

      layer count.

    Return type:

      int

  GetName(DataSource self) → char const *

    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.

    Deprecated Use GDALGetDescription() in GDAL 2.0

    Parameters:

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

    Returns:

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

    Return type:

      str

  GetRefCount(DataSource self) → int

    int OGR_DS_GetRefCount(OGRDataSourceH hDataSource)

  GetStyleTable(DataSource self) → StyleTable

    OGRStyleTableH OGR_DS_GetStyleTable(OGRDataSourceH hDS)

    Get style table.

  GetSummaryRefCount(DataSource self) → int

    int OGR_DS_GetSummaryRefCount(OGRDataSourceH hDataSource)

  Reference()

    For backwards compatibility only.

  Release()

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

  ReleaseResultSet(self, sql_lyr: ogr.Layer)

    Release ogr.Layer returned by ExecuteSQL() (when not called as an execution manager)

    The sql_lyr object is invalidated after this call.

    Parameters:

      sql_lyr – ogr.Layer got with ExecuteSQL()

  RollbackTransaction(DataSource self) → OGRErr
  SetStyleTable(DataSource self, StyleTable table)

    void OGR_DS_SetStyleTable(OGRDataSourceH hDS, OGRStyleTableH hStyleTable)

    Set style table.

  StartTransaction(DataSource self, int force=FALSE) → OGRErr
  SyncToDisk(DataSource self) → OGRErr

    OGRErr OGR_DS_SyncToDisk(OGRDataSourceH hDS)

    Flush pending changes to disk.

    See GDALDataset::FlushCache()

  TestCapability(DataSource self, char const * cap) → bool

    int OGR_DS_TestCapability(OGRDataSourceH hDS, const char *pszCapability)

    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.

    ODsCDeleteLayer: True if this datasource can delete existing layers.

    ODsCCreateGeomFieldAfterCreateLayer: True if the layers of this datasource support CreateGeomField() just after layer creation.

    ODsCCurveGeometries: True if this datasource supports writing curve geometries. (GDAL 2.0). In that case, OLCCurveGeometries must also be declared in layers of that dataset.

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

    Deprecated Use GDALDatasetTestCapability() in GDAL 2.0

    Parameters:

      - hDS – handle to the data source against which to test the capability.

      - pszCapability – the capability to test.

    Returns:

      TRUE if capability available otherwise FALSE.

    Return type:

      int

  property name

    p.q(const).char

    Type:

      name

  property thisown

    The membership flag

osgeo.ogr.DontUseExceptions()

  Disable exceptions in all GDAL related modules (osgeo.gdal, osgeo.ogr, osgeo.osr, osgeo.gnm). Note: prior to GDAL 3.7, this only affected the calling module

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

  Bases: `MajorObject`

  Proxy of C++ OGRDriverShadow class.

  CopyDataSource(Driver self, DataSource copy_ds, char const * utf8_path, char ** options=None) → DataSource
  CreateDataSource(Driver self, char const * utf8_path, char ** options=None) → DataSource
  DeleteDataSource(Driver self, char const * utf8_path) → int
  Deregister(Driver self)
  GetName(Driver self) → char const *
  Open(Driver self, char const * utf8_path, int update=0) → DataSource
  Register(Driver self)
  TestCapability(Driver self, char const * cap) → bool
  property name

    p.q(const).char

    Type:

      name

  property thisown

    The membership flag

class osgeo.ogr.ExceptionMgr(useExceptions=True)

  Bases: `object`

  Context manager to manage Python Exception state for GDAL/OGR/OSR/GNM.

  Separate exception state is maintained for each module (gdal, ogr, etc), and this class appears independently in all of them. This is built in top of calls to the older UseExceptions()/DontUseExceptions() functions.

  Example:

      >>> print(gdal.GetUseExceptions())
      0
      >>> with gdal.ExceptionMgr():
      ...     # Exceptions are now in use
      ...     print(gdal.GetUseExceptions())
      1
      >>>
      >>> # Exception state has now been restored
      >>> print(gdal.GetUseExceptions())
      0

class osgeo.ogr.Feature(*args, **kwargs)

  Bases: `object`

  Proxy of C++ OGRFeatureShadow class.

  Clone(Feature self) → Feature

    OGRFeatureH OGR_F_Clone(OGRFeatureH hFeat)

    Duplicate feature.

    The newly created feature is owned by the caller, and will have its own reference to the OGRFeatureDefn.

    This function is the same as the C++ method OGRFeature::Clone().

    Parameters:

      hFeat – handle to the feature to clone.

    Returns:

      a handle to the new feature, exactly matching this feature.

    Return type:

      OGRFeatureH

  Dereference()
  Destroy()

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

  DumpReadable(Feature self)

    void OGR_F_DumpReadable(OGRFeatureH hFeat, FILE *fpOut)

    Dump this feature in a human readable form.

    This dumps the attributes, and geometry; however, it doesn’t definition information (other than field types and names), nor does it report the geometry spatial reference system.

    This function is the same as the C++ method OGRFeature::DumpReadable().

    Parameters:

      - hFeat – handle to the feature to dump.

      - fpOut – the stream to write to, such as strout.

  Equal(Feature self, Feature feature) → bool

    int OGR_F_Equal(OGRFeatureH hFeat, OGRFeatureH hOtherFeat)

    Test if two features are the same.

    Two features are considered equal if the share them (handle equality) same OGRFeatureDefn, have the same field values, and the same geometry (as tested by OGR_G_Equal()) as well as the same feature id.

    This function is the same as the C++ method OGRFeature::Equal().

    Parameters:

      - hFeat – handle to one of the feature.

      - hOtherFeat – handle to the other feature to test this one against.

    Returns:

      TRUE if they are equal, otherwise FALSE.

    Return type:

      int

  ExportToJson(as_object=False, options=None)

    Exports a GeoJSON object which represents the Feature. The as_object parameter determines whether the returned value should be a Python object instead of a string. Defaults to False. The options parameter is passed to Geometry.ExportToJson()

  FillUnsetWithDefault(Feature self, int bNotNullableOnly=FALSE, char ** options=None)

    void OGR_F_FillUnsetWithDefault(OGRFeatureH hFeat, int bNotNullableOnly, char **papszOptions)

    Fill unset fields with default values that might be defined.

    This function is the same as the C++ method OGRFeature::FillUnsetWithDefault().

    New in version 2.0.

    Parameters:

      - hFeat – handle to the feature.

      - bNotNullableOnly – if we should fill only unset fields with a not-null constraint.

      - papszOptions – unused currently. Must be set to NULL.

  GetDefnRef(Feature self) → FeatureDefn

    OGRFeatureDefnH OGR_F_GetDefnRef(OGRFeatureH hFeat)

    Fetch feature definition.

    This function is the same as the C++ method OGRFeature::GetDefnRef().

    Parameters:

      hFeat – handle to the feature to get the feature definition from.

    Returns:

      a handle to the feature definition object on which feature depends.

    Return type:

      OGRFeatureDefnH

  GetFID(Feature self) → GIntBig

    GIntBig OGR_F_GetFID(OGRFeatureH hFeat)

    Get feature identifier.

    This function is the same as the C++ method OGRFeature::GetFID(). Note: since GDAL 2.0, this method returns a GIntBig (previously a long)

    Parameters:

      - hFeat – handle to the feature from which to get the feature

      - identifier. –

    Returns:

      feature id or OGRNullFID if none has been assigned.

    Return type:

      int

  GetField(fld_index)
  GetFieldAsBinary(Feature self, int id) → OGRErr
  GetFieldAsBinary(Feature self, char const * field_name) → OGRErr

    GByte* OGR_F_GetFieldAsBinary(OGRFeatureH hFeat, int iField, int *pnBytes)

    Fetch field value as binary.

    This method only works for OFTBinary and OFTString fields.

    This function is the same as the C++ method OGRFeature::GetFieldAsBinary().

    Parameters:

      - hFeat – handle to the feature that owned the field.

      - iField – the field to fetch, from 0 to GetFieldCount()-1.

      - pnBytes – location to place count of bytes returned.

    Returns:

      the field value. This list is internal, and should not be modified, or freed. Its lifetime may be very brief.

    Return type:

      list

  GetFieldAsDateTime(Feature self, int id)
  GetFieldAsDateTime(Feature self, char const * field_name) → None

    int OGR_F_GetFieldAsDateTime(OGRFeatureH hFeat, int iField, int *pnYear, int *pnMonth, int *pnDay, int *pnHour, int *pnMinute, int *pnSecond, int *pnTZFlag)

    Fetch field value as date and time.

    Currently this method only works for OFTDate, OFTTime and OFTDateTime fields.

    This function is the same as the C++ method OGRFeature::GetFieldAsDateTime().

    Note

    Use OGR_F_GetFieldAsDateTimeEx() for second with millisecond accuracy.

    Parameters:

      - hFeat – handle to the feature that owned the field.

      - iField – the field to fetch, from 0 to GetFieldCount()-1.

      - pnYear – (including century)

      - pnMonth – (1-12)

      - pnDay – (1-31)

      - pnHour – (0-23)

      - pnMinute – (0-59)

      - pnSecond – (0-59)

      - pnTZFlag – (0=unknown, 1=localtime, 100=GMT, see data model for

      - details) –

    Returns:

      TRUE on success or FALSE on failure.

    Return type:

      int

  GetFieldAsDouble(Feature self, int id) → double
  GetFieldAsDouble(Feature self, char const * field_name) → double

    double OGR_F_GetFieldAsDouble(OGRFeatureH hFeat, int iField)

    Fetch field value as a double.

    OFTString features will be translated using CPLAtof(). OFTInteger fields will be cast to double. Other field types, or errors will result in a return value of zero.

    This function is the same as the C++ method OGRFeature::GetFieldAsDouble().

    Parameters:

      - hFeat – handle to the feature that owned the field.

      - iField – the field to fetch, from 0 to GetFieldCount()-1.

    Returns:

      the field value.

    Return type:

      float

  GetFieldAsDoubleList(Feature self, int id)
  GetFieldAsDoubleList(Feature self, char const * field_name) → None

    const double* OGR_F_GetFieldAsDoubleList(OGRFeatureH hFeat, int iField, int *pnCount)

    Fetch field value as a list of doubles.

    Currently this function only works for OFTRealList fields.

    This function is the same as the C++ method OGRFeature::GetFieldAsDoubleList().

    Parameters:

      - hFeat – handle to the feature that owned the field.

      - iField – the field to fetch, from 0 to GetFieldCount()-1.

      - pnCount – an integer to put the list count (number of doubles) into.

    Returns:

      the field value. This list is internal, and should not be modified, or freed. Its lifetime may be very brief. If *pnCount is zero on return the returned pointer may be NULL or non-NULL.

    Return type:

      list[float]

  GetFieldAsISO8601DateTime(Feature self, int id, char ** options=None) → char const
  GetFieldAsISO8601DateTime(Feature self, char const * field_name, char ** options=None) → char const *
  GetFieldAsInteger(Feature self, int id) → int
  GetFieldAsInteger(Feature self, char const * field_name) → int

    int OGR_F_GetFieldAsInteger(OGRFeatureH hFeat, int iField)

    Fetch field value as integer.

    OFTString features will be translated using atoi(). OFTReal fields will be cast to integer. Other field types, or errors will result in a return value of zero.

    This function is the same as the C++ method OGRFeature::GetFieldAsInteger().

    Parameters:

      - hFeat – handle to the feature that owned the field.

      - iField – the field to fetch, from 0 to GetFieldCount()-1.

    Returns:

      the field value.

    Return type:

      int

  GetFieldAsInteger64(Feature self, int id) → GIntBig
  GetFieldAsInteger64(Feature self, char const * field_name) → GIntBig

    GIntBig OGR_F_GetFieldAsInteger64(OGRFeatureH hFeat, int iField)

    Fetch field value as integer 64 bit.

    OFTInteger are promoted to 64 bit. OFTString features will be translated using CPLAtoGIntBig(). OFTReal fields will be cast to integer. Other field types, or errors will result in a return value of zero.

    This function is the same as the C++ method OGRFeature::GetFieldAsInteger64().

    New in version 2.0.

    Parameters:

      - hFeat – handle to the feature that owned the field.

      - iField – the field to fetch, from 0 to GetFieldCount()-1.

    Returns:

      the field value.

    Return type:

      int

  GetFieldAsInteger64List(Feature self, int id)

    const GIntBig* OGR_F_GetFieldAsInteger64List(OGRFeatureH hFeat, int iField, int *pnCount)

    Fetch field value as a list of 64 bit integers.

    Currently this function only works for OFTInteger64List fields.

    This function is the same as the C++ method OGRFeature::GetFieldAsInteger64List().

    New in version 2.0.

    Parameters:

      - hFeat – handle to the feature that owned the field.

      - iField – the field to fetch, from 0 to GetFieldCount()-1.

      - pnCount – an integer to put the list count (number of integers) into.

    Returns:

      the field value. This list is internal, and should not be modified, or freed. Its lifetime may be very brief. If *pnCount is zero on return the returned pointer may be NULL or non-NULL.

    Return type:

      list[int]

  GetFieldAsIntegerList(Feature self, int id)
  GetFieldAsIntegerList(Feature self, char const * field_name) → None

    const int* OGR_F_GetFieldAsIntegerList(OGRFeatureH hFeat, int iField, int *pnCount)

    Fetch field value as a list of integers.

    Currently this function only works for OFTIntegerList fields.

    This function is the same as the C++ method OGRFeature::GetFieldAsIntegerList().

    Parameters:

      - hFeat – handle to the feature that owned the field.

      - iField – the field to fetch, from 0 to GetFieldCount()-1.

      - pnCount – an integer to put the list count (number of integers) into.

    Returns:

      the field value. This list is internal, and should not be modified, or freed. Its lifetime may be very brief. If *pnCount is zero on return the returned pointer may be NULL or non-NULL.

    Return type:

      list[int]

  GetFieldAsString(Feature self, int id) → char const
  GetFieldAsString(Feature self, char const * field_name) → char const *

    const char* OGR_F_GetFieldAsString(OGRFeatureH hFeat, int iField)

    Fetch field value as a string.

    OFTReal and OFTInteger fields will be translated to string using sprintf(), but not necessarily using the established formatting rules. Other field types, or errors will result in a return value of zero.

    This function is the same as the C++ method OGRFeature::GetFieldAsString().

    Parameters:

      - hFeat – handle to the feature that owned the field.

      - iField – the field to fetch, from 0 to GetFieldCount()-1.

    Returns:

      the field value. This string is internal, and should not be modified, or freed. Its lifetime may be very brief.

    Return type:

      str

  GetFieldAsStringList(Feature self, int id) → char **

    char** OGR_F_GetFieldAsStringList(OGRFeatureH hFeat, int iField)

    Fetch field value as a list of strings.

    Currently this method only works for OFTStringList fields.

    The returned list is terminated by a NULL pointer. The number of elements can also be calculated using CSLCount().

    This function is the same as the C++ method OGRFeature::GetFieldAsStringList().

    Parameters:

      - hFeat – handle to the feature that owned the field.

      - iField – the field to fetch, from 0 to GetFieldCount()-1.

    Returns:

      the field value. This list is internal, and should not be modified, or freed. Its lifetime may be very brief.

    Return type:

      list[str]

  GetFieldCount(Feature self) → int

    int OGR_F_GetFieldCount(OGRFeatureH hFeat)

    Fetch number of fields on this feature This will always be the same as the field count for the OGRFeatureDefn.

    This function is the same as the C++ method OGRFeature::GetFieldCount().

    Parameters:

      hFeat – handle to the feature to get the fields count from.

    Returns:

      count of fields.

    Return type:

      int

  GetFieldDefnRef(Feature self, int id) → FieldDefn
  GetFieldDefnRef(Feature self, char const * field_name) → FieldDefn

    OGRFieldDefnH OGR_F_GetFieldDefnRef(OGRFeatureH hFeat, int i)

    Fetch definition for this field.

    This function is the same as the C++ method OGRFeature::GetFieldDefnRef().

    Parameters:

      - hFeat – handle to the feature on which the field is found.

      - i – the field to fetch, from 0 to GetFieldCount()-1.

    Returns:

      a handle to the field definition (from the OGRFeatureDefn). This is an internal reference, and should not be deleted or modified.

    Return type:

      OGRFieldDefnH

  GetFieldIndex(Feature self, char const * field_name) → int

    int OGR_F_GetFieldIndex(OGRFeatureH hFeat, const char *pszName)

    Fetch the field index given field name.

    This is a cover for the OGRFeatureDefn::GetFieldIndex() method.

    This function is the same as the C++ method OGRFeature::GetFieldIndex().

    Parameters:

      - hFeat – handle to the feature on which the field is found.

      - pszName – the name of the field to search for.

    Returns:

      the field index, or -1 if no matching field is found.

    Return type:

      int

  GetFieldType(Feature self, int id) → OGRFieldType
  GetFieldType(Feature self, char const * field_name) → OGRFieldType
  GetGeomFieldCount(Feature self) → int

    int OGR_F_GetGeomFieldCount(OGRFeatureH hFeat)

    Fetch number of geometry fields on this feature This will always be the same as the geometry field count for the OGRFeatureDefn.

    This function is the same as the C++ method OGRFeature::GetGeomFieldCount().

    New in version 1.11.

    Parameters:

      hFeat – handle to the feature to get the geometry fields count from.

    Returns:

      count of geometry fields.

    Return type:

      int

  GetGeomFieldDefnRef(Feature self, int id) → GeomFieldDefn
  GetGeomFieldDefnRef(Feature self, char const * field_name) → GeomFieldDefn

    OGRGeomFieldDefnH OGR_F_GetGeomFieldDefnRef(OGRFeatureH hFeat, int i)

    Fetch definition for this geometry field.

    This function is the same as the C++ method OGRFeature::GetGeomFieldDefnRef().

    New in version 1.11.

    Parameters:

      - hFeat – handle to the feature on which the field is found.

      - i – the field to fetch, from 0 to GetGeomFieldCount()-1.

    Returns:

      a handle to the field definition (from the OGRFeatureDefn). This is an internal reference, and should not be deleted or modified.

    Return type:

      OGRGeomFieldDefnH

  GetGeomFieldIndex(Feature self, char const * field_name) → int

    int OGR_F_GetGeomFieldIndex(OGRFeatureH hFeat, const char *pszName)

    Fetch the geometry field index given geometry field name.

    This is a cover for the OGRFeatureDefn::GetGeomFieldIndex() method.

    This function is the same as the C++ method OGRFeature::GetGeomFieldIndex().

    New in version 1.11.

    Parameters:

      - hFeat – handle to the feature on which the geometry field is found.

      - pszName – the name of the geometry field to search for.

    Returns:

      the geometry field index, or -1 if no matching geometry field is found.

    Return type:

      int

  GetGeomFieldRef(Feature self, int iField) → Geometry
  GetGeomFieldRef(Feature self, char const * field_name) → Geometry

    OGRGeometryH OGR_F_GetGeomFieldRef(OGRFeatureH hFeat, int iField)

    Fetch a handle to feature geometry.

    This function is the same as the C++ method OGRFeature::GetGeomFieldRef().

    Parameters:

      - hFeat – handle to the feature to get geometry from.

      - iField – geometry field to get.

      - be (a handle to internal feature geometry. This object should not) –

      - modified. –

      - 1.11 (GDAL) –

  GetGeometryRef(Feature self) → Geometry

    Return the feature geometry

    The lifetime of the returned geometry is bound to the one of its belonging feature.

    For more details: `OGR_F_GetGeometryRef()`

    The geometry() method is also available as an alias of GetGeometryRef()

    Returns:

      the geometry, or None.

    Return type:

      Geometry

  GetNativeData(Feature self) → char const *

    const char* OGR_F_GetNativeData(OGRFeatureH hFeat)

    Returns the native data for the feature.

    The native data is the representation in a “natural” form that comes from the driver that created this feature, or that is aimed at an output driver. The native data may be in different format, which is indicated by OGR_F_GetNativeMediaType().

    Note that most drivers do not support storing the native data in the feature object, and if they do, generally the NATIVE_DATA open option must be passed at dataset opening.

    The “native data” does not imply it is something more performant or powerful than what can be obtained with the rest of the API, but it may be useful in round-tripping scenarios where some characteristics of the underlying format are not captured otherwise by the OGR abstraction.

    This function is the same as the C++ method OGRFeature::GetNativeData().

    Note

    See https://trac.osgeo.org/gdal/wiki/rfc60_improved_roundtripping_in_ogr

    New in version 2.1.

    Parameters:

      hFeat – handle to the feature.

    Returns:

      a string with the native data, or NULL if there is none.

    Return type:

      str

  GetNativeMediaType(Feature self) → char const *

    const char* OGR_F_GetNativeMediaType(OGRFeatureH hFeat)

    Returns the native media type for the feature.

    The native media type is the identifier for the format of the native data. It follows the IANA RFC 2045 (seehttps://en.wikipedia.org/wiki/Media_type), e.g. “application/vnd.geo+json” for JSon.

    This function is the same as the C function OGR_F_GetNativeMediaType().

    Note

    See https://trac.osgeo.org/gdal/wiki/rfc60_improved_roundtripping_in_ogr

    New in version 2.1.

    Parameters:

      hFeat – handle to the feature.

    Returns:

      a string with the native media type, or NULL if there is none.

    Return type:

      str

  GetStyleString(Feature self) → char const *

    const char* OGR_F_GetStyleString(OGRFeatureH hFeat)

    Fetch style string for this feature.

    Set the OGR Feature Style Specification for details on the format of this string, and ogr_featurestyle.h for services available to parse it.

    This function is the same as the C++ method OGRFeature::GetStyleString().

    Parameters:

      hFeat – handle to the feature to get the style from.

    Returns:

      a reference to a representation in string format, or NULL if there isn’t one.

    Return type:

      str

  IsFieldNull(Feature self, int id) → bool
  IsFieldNull(Feature self, char const * field_name) → bool

    int OGR_F_IsFieldNull(OGRFeatureH hFeat, int iField)

    Test if a field is null.

    This function is the same as the C++ method OGRFeature::IsFieldNull().

    New in version 2.2.

    Parameters:

      - hFeat – handle to the feature on which the field is.

      - iField – the field to test.

    Returns:

      TRUE if the field is null, otherwise false.

    Return type:

      int

  IsFieldSet(Feature self, int id) → bool
  IsFieldSet(Feature self, char const * field_name) → bool

    int OGR_F_IsFieldSet(OGRFeatureH hFeat, int iField)

    Test if a field has ever been assigned a value or not.

    This function is the same as the C++ method OGRFeature::IsFieldSet().

    Parameters:

      - hFeat – handle to the feature on which the field is.

      - iField – the field to test.

    Returns:

      TRUE if the field has been set, otherwise false.

    Return type:

      int

  IsFieldSetAndNotNull(Feature self, int id) → bool
  IsFieldSetAndNotNull(Feature self, char const * field_name) → bool

    int OGR_F_IsFieldSetAndNotNull(OGRFeatureH hFeat, int iField)

    Test if a field is set and not null.

    This function is the same as the C++ method OGRFeature::IsFieldSetAndNotNull().

    New in version 2.2.

    Parameters:

      - hFeat – handle to the feature on which the field is.

      - iField – the field to test.

    Returns:

      TRUE if the field is set and not null, otherwise false.

    Return type:

      int

  Reference()
  SetFID(Feature self, GIntBig fid) → OGRErr

    OGRErr OGR_F_SetFID(OGRFeatureH hFeat, GIntBig nFID)

    Set the feature identifier.

    For specific types of features this operation may fail on illegal features ids. Generally it always succeeds. Feature ids should be greater than or equal to zero, with the exception of OGRNullFID (-1) indicating that the feature id is unknown.

    This function is the same as the C++ method OGRFeature::SetFID().

    Parameters:

      - hFeat – handle to the feature to set the feature id to.

      - nFID – the new feature identifier value to assign.

    Returns:

      On success OGRERR_NONE, or on failure some other value.

    Return type:

      OGRErr

  SetField(self, int id, char value)
  SetField(self, char name, char value) → None
  SetField(self, int id, int value) → None
  SetField(self, char name, int value) → None
  SetField(self, int id, double value) → None
  SetField(self, char name, double value) → None
    SetField(self, int id, int year, int month, int day, int hour, int minute,

      int second, int tzflag)

    SetField(self, char name, int year, int month, int day, int hour,

      int minute, int second, int tzflag)

  SetFieldBinaryFromHexString(Feature self, int id, char const * pszValue)
  SetFieldBinaryFromHexString(Feature self, char const * field_name, char const * pszValue) → None
  SetFieldDoubleList(Feature self, int id, int nList)

    void OGR_F_SetFieldDoubleList(OGRFeatureH hFeat, int iField, int nCount, const double *padfValues)

    Set field to list of doubles value.

    This function currently on has an effect of OFTIntegerList, OFTInteger64List, OFTRealList fields.

    This function is the same as the C++ method OGRFeature::SetField().

    This method has only an effect on the in-memory feature object. If this object comes from a layer and the modifications must be serialized back to the datasource, OGR_L_SetFeature() must be used afterwards. Or if this is a new feature, OGR_L_CreateFeature() must be used afterwards.

    Parameters:

      - hFeat – handle to the feature that owned the field.

      - iField – the field to set, from 0 to GetFieldCount()-1.

      - nCount – the number of values in the list being assigned.

      - padfValues – the values to assign.

  SetFieldInteger64(Feature self, int id, GIntBig value)

    void OGR_F_SetFieldInteger64(OGRFeatureH hFeat, int iField, GIntBig nValue)

    Set field to 64 bit integer value.

    OFTInteger, OFTInteger64 and OFTReal fields will be set directly. OFTString fields will be assigned a string representation of the value, but not necessarily taking into account formatting constraints on this field. Other field types may be unaffected.

    This function is the same as the C++ method OGRFeature::SetField().

    This method has only an effect on the in-memory feature object. If this object comes from a layer and the modifications must be serialized back to the datasource, OGR_L_SetFeature() must be used afterwards. Or if this is a new feature, OGR_L_CreateFeature() must be used afterwards.

    New in version 2.0.

    Parameters:

      - hFeat – handle to the feature that owned the field.

      - iField – the field to fetch, from 0 to GetFieldCount()-1.

      - nValue – the value to assign.

  SetFieldInteger64List(Feature self, int id, int nList)

    void OGR_F_SetFieldInteger64List(OGRFeatureH hFeat, int iField, int nCount, const GIntBig *panValues)

    Set field to list of 64 bit integers value.

    This function currently on has an effect of OFTIntegerList, OFTInteger64List and OFTRealList fields.

    This function is the same as the C++ method OGRFeature::SetField().

    This method has only an effect on the in-memory feature object. If this object comes from a layer and the modifications must be serialized back to the datasource, OGR_L_SetFeature() must be used afterwards. Or if this is a new feature, OGR_L_CreateFeature() must be used afterwards.

    New in version 2.0.

    Parameters:

      - hFeat – handle to the feature that owned the field.

      - iField – the field to set, from 0 to GetFieldCount()-1.

      - nCount – the number of values in the list being assigned.

      - panValues – the values to assign.

  SetFieldIntegerList(Feature self, int id, int nList)

    void OGR_F_SetFieldIntegerList(OGRFeatureH hFeat, int iField, int nCount, const int *panValues)

    Set field to list of integers value.

    This function currently on has an effect of OFTIntegerList, OFTInteger64List and OFTRealList fields.

    This function is the same as the C++ method OGRFeature::SetField().

    This method has only an effect on the in-memory feature object. If this object comes from a layer and the modifications must be serialized back to the datasource, OGR_L_SetFeature() must be used afterwards. Or if this is a new feature, OGR_L_CreateFeature() must be used afterwards.

    Parameters:

      - hFeat – handle to the feature that owned the field.

      - iField – the field to set, from 0 to GetFieldCount()-1.

      - nCount – the number of values in the list being assigned.

      - panValues – the values to assign.

  SetFieldNull(Feature self, int id)
  SetFieldNull(Feature self, char const * field_name) → None

    void OGR_F_SetFieldNull(OGRFeatureH hFeat, int iField)

    Clear a field, marking it as null.

    This function is the same as the C++ method OGRFeature::SetFieldNull().

    New in version 2.2.

    Parameters:

      - hFeat – handle to the feature on which the field is.

      - iField – the field to set to null.

  SetFieldString(Feature self, int id, char const * value)

    void OGR_F_SetFieldString(OGRFeatureH hFeat, int iField, const char *pszValue)

    Set field to string value.

    OFTInteger fields will be set based on an atoi() conversion of the string. OFTInteger64 fields will be set based on an CPLAtoGIntBig() conversion of the string. OFTReal fields will be set based on an CPLAtof() conversion of the string. Other field types may be unaffected.

    This function is the same as the C++ method OGRFeature::SetField().

    This method has only an effect on the in-memory feature object. If this object comes from a layer and the modifications must be serialized back to the datasource, OGR_L_SetFeature() must be used afterwards. Or if this is a new feature, OGR_L_CreateFeature() must be used afterwards.

    Parameters:

      - hFeat – handle to the feature that owned the field.

      - iField – the field to fetch, from 0 to GetFieldCount()-1.

      - pszValue – the value to assign.

  SetFieldStringList(Feature self, int id, char ** pList)

    void OGR_F_SetFieldStringList(OGRFeatureH hFeat, int iField, CSLConstList papszValues)

    Set field to list of strings value.

    This function currently on has an effect of OFTStringList fields.

    This function is the same as the C++ method OGRFeature::SetField().

    This method has only an effect on the in-memory feature object. If this object comes from a layer and the modifications must be serialized back to the datasource, OGR_L_SetFeature() must be used afterwards. Or if this is a new feature, OGR_L_CreateFeature() must be used afterwards.

    Parameters:

      - hFeat – handle to the feature that owned the field.

      - iField – the field to set, from 0 to GetFieldCount()-1.

      - papszValues – the values to assign. List of NUL-terminated string,

      - pointer. (ending with a NULL) –

  SetFrom(Feature self, Feature other, int forgiving=1) → OGRErr

    OGRErr OGR_F_SetFrom(OGRFeatureH hFeat, OGRFeatureH hOtherFeat, int bForgiving)

    Set one feature from another.

    Overwrite the contents of this feature from the geometry and attributes of another. The hOtherFeature does not need to have the same OGRFeatureDefn. Field values are copied by corresponding field names. Field types do not have to exactly match. OGR_F_SetField*() function conversion rules will be applied as needed.

    This function is the same as the C++ method OGRFeature::SetFrom().

    Parameters:

      - hFeat – handle to the feature to set to.

      - hOtherFeat – handle to the feature from which geometry, and field values will be copied.

      - bForgiving – TRUE if the operation should continue despite lacking output fields matching some of the source fields.

    Returns:

      OGRERR_NONE if the operation succeeds, even if some values are not transferred, otherwise an error code.

    Return type:

      OGRErr

  SetFromWithMap(Feature self, Feature other, int forgiving, int nList) → OGRErr

    OGRErr OGR_F_SetFromWithMap(OGRFeatureH hFeat, OGRFeatureH hOtherFeat, int bForgiving, const int *panMap)

    Set one feature from another.

    Overwrite the contents of this feature from the geometry and attributes of another. The hOtherFeature does not need to have the same OGRFeatureDefn. Field values are copied according to the provided indices map. Field types do not have to exactly match. OGR_F_SetField*() function conversion rules will be applied as needed. This is more efficient than OGR_F_SetFrom() in that this doesn’t lookup the fields by their names. Particularly useful when the field names don’t match.

    This function is the same as the C++ method OGRFeature::SetFrom().

    Parameters:

      - hFeat – handle to the feature to set to.

      - hOtherFeat – handle to the feature from which geometry, and field values will be copied.

      - panMap – Array of the indices of the destination feature’s fields stored at the corresponding index of the source feature’s fields. A value of -1 should be used to ignore the source’s field. The array should not be NULL and be as long as the number of fields in the source feature.

      - bForgiving – TRUE if the operation should continue despite lacking output fields matching some of the source fields.

    Returns:

      OGRERR_NONE if the operation succeeds, even if some values are not transferred, otherwise an error code.

    Return type:

      OGRErr

  SetGeomField(Feature self, int iField, Geometry geom) → OGRErr
  SetGeomField(Feature self, char const * field_name, Geometry geom) → OGRErr

    OGRErr OGR_F_SetGeomField(OGRFeatureH hFeat, int iField, OGRGeometryH hGeom)

    Set feature geometry of a specified geometry field.

    This function updates the features geometry, and operate exactly as SetGeometryDirectly(), except that this function does not assume ownership of the passed geometry, but instead makes a copy of it.

    This function is the same as the C++ OGRFeature::SetGeomField().

    Parameters:

      - hFeat – handle to the feature on which new geometry is applied to.

      - iField – geometry field to set.

      - hGeom – handle to the new geometry to apply to feature.

    Returns:

      OGRERR_NONE if successful, or OGR_UNSUPPORTED_GEOMETRY_TYPE if the geometry type is illegal for the OGRFeatureDefn (checking not yet implemented).

    Return type:

      OGRErr

  SetGeomFieldDirectly(Feature self, int iField, Geometry geom) → OGRErr
  SetGeomFieldDirectly(Feature self, char const * field_name, Geometry geom) → OGRErr

    OGRErr OGR_F_SetGeomFieldDirectly(OGRFeatureH hFeat, int iField, OGRGeometryH hGeom)

    Set feature geometry of a specified geometry field.

    This function updates the features geometry, and operate exactly as SetGeomField(), except that this function assumes ownership of the passed geometry (even in case of failure of that function).

    This function is the same as the C++ method OGRFeature::SetGeomFieldDirectly.

    New in version 1.11.

    Parameters:

      - hFeat – handle to the feature on which to apply the geometry.

      - iField – geometry field to set.

      - hGeom – handle to the new geometry to apply to feature.

    Returns:

      OGRERR_NONE if successful, or OGRERR_FAILURE if the index is invalid, or OGR_UNSUPPORTED_GEOMETRY_TYPE if the geometry type is illegal for the OGRFeatureDefn (checking not yet implemented).

    Return type:

      OGRErr

  SetGeometry(Feature self, Geometry geom) → OGRErr

    OGRErr OGR_F_SetGeometry(OGRFeatureH hFeat, OGRGeometryH hGeom)

    Set feature geometry.

    This function updates the features geometry, and operate exactly as SetGeometryDirectly(), except that this function does not assume ownership of the passed geometry, but instead makes a copy of it.

    This function is the same as the C++ OGRFeature::SetGeometry().

    This method has only an effect on the in-memory feature object. If this object comes from a layer and the modifications must be serialized back to the datasource, OGR_L_SetFeature() must be used afterwards. Or if this is a new feature, OGR_L_CreateFeature() must be used afterwards.

    Parameters:

      - hFeat – handle to the feature on which new geometry is applied to.

      - hGeom – handle to the new geometry to apply to feature.

    Returns:

      OGRERR_NONE if successful, or OGR_UNSUPPORTED_GEOMETRY_TYPE if the geometry type is illegal for the OGRFeatureDefn (checking not yet implemented).

    Return type:

      OGRErr

  SetGeometryDirectly(Feature self, Geometry geom) → OGRErr

    OGRErr OGR_F_SetGeometryDirectly(OGRFeatureH hFeat, OGRGeometryH hGeom)

    Set feature geometry.

    This function updates the features geometry, and operate exactly as SetGeometry(), except that this function assumes ownership of the passed geometry (even in case of failure of that function).

    This function is the same as the C++ method OGRFeature::SetGeometryDirectly.

    This method has only an effect on the in-memory feature object. If this object comes from a layer and the modifications must be serialized back to the datasource, OGR_L_SetFeature() must be used afterwards. Or if this is a new feature, OGR_L_CreateFeature() must be used afterwards.

    Parameters:

      - hFeat – handle to the feature on which to apply the geometry.

      - hGeom – handle to the new geometry to apply to feature.

    Returns:

      OGRERR_NONE if successful, or OGR_UNSUPPORTED_GEOMETRY_TYPE if the geometry type is illegal for the OGRFeatureDefn (checking not yet implemented).

    Return type:

      OGRErr

  SetNativeData(Feature self, char const * nativeData)

    void OGR_F_SetNativeData(OGRFeatureH hFeat, const char *pszNativeData)

    Sets the native data for the feature.

    The native data is the representation in a “natural” form that comes from the driver that created this feature, or that is aimed at an output driver. The native data may be in different format, which is indicated by OGR_F_GetNativeMediaType().

    This function is the same as the C++ method OGRFeature::SetNativeData().

    Note

    See https://trac.osgeo.org/gdal/wiki/rfc60_improved_roundtripping_in_ogr

    New in version 2.1.

    Parameters:

      - hFeat – handle to the feature.

      - pszNativeData – a string with the native data, or NULL if there is none.

  SetNativeMediaType(Feature self, char const * nativeMediaType)

    void OGR_F_SetNativeMediaType(OGRFeatureH hFeat, const char *pszNativeMediaType)

    Sets the native media type for the feature.

    The native media type is the identifier for the format of the native data. It follows the IANA RFC 2045 (seehttps://en.wikipedia.org/wiki/Media_type), e.g. “application/vnd.geo+json” for JSon.

    This function is the same as the C++ method OGRFeature::SetNativeMediaType().

    Note

    See https://trac.osgeo.org/gdal/wiki/rfc60_improved_roundtripping_in_ogr

    New in version 2.1.

    Parameters:

      - hFeat – handle to the feature.

      - pszNativeMediaType – a string with the native media type, or NULL if there is none.

  SetStyleString(Feature self, char const * the_string)

    void OGR_F_SetStyleString(OGRFeatureH hFeat, const char *pszStyle)

    Set feature style string.

    This method operate exactly as OGR_F_SetStyleStringDirectly() except that it does not assume ownership of the passed string, but instead makes a copy of it.

    This function is the same as the C++ method OGRFeature::SetStyleString().

    Parameters:

      - hFeat – handle to the feature to set style to.

      - pszStyle – the style string to apply to this feature, cannot be NULL.

  UnsetField(Feature self, int id)
  UnsetField(Feature self, char const * field_name) → None

    void OGR_F_UnsetField(OGRFeatureH hFeat, int iField)

    Clear a field, marking it as unset.

    This function is the same as the C++ method OGRFeature::UnsetField().

    Parameters:

      - hFeat – handle to the feature on which the field is.

      - iField – the field to unset.

  Validate(Feature self, int flags=OGR_F_VAL_ALL, int bEmitError=TRUE) → int

    int OGR_F_Validate(OGRFeatureH hFeat, int nValidateFlags, int bEmitError)

    Validate that a feature meets constraints of its schema.

    The scope of test is specified with the nValidateFlags parameter.

    Regarding OGR_F_VAL_WIDTH, the test is done assuming the string width must be interpreted as the number of UTF-8 characters. Some drivers might interpret the width as the number of bytes instead. So this test is rather conservative (if it fails, then it will fail for all interpretations).

    This function is the same as the C++ method OGRFeature::Validate().

    New in version 2.0.

    Parameters:

      - hFeat – handle to the feature to validate.

      - nValidateFlags – OGR_F_VAL_ALL or combination of OGR_F_VAL_NULL, OGR_F_VAL_GEOM_TYPE, OGR_F_VAL_WIDTH and OGR_F_VAL_ALLOW_NULL_WHEN_DEFAULT with ‘|’ operator

      - bEmitError – TRUE if a CPLError() must be emitted when a check fails

    Returns:

      TRUE if all enabled validation tests pass.

    Return type:

      int

  geometry()

    Return the feature geometry

    The lifetime of the returned geometry is bound to the one of its belonging feature.

    For more details: `OGR_F_GetGeometryRef()`

    The GetGeometryRef() method is also available as an alias of geometry()

    Returns:

      the geometry, or None.

    Return type:

      Geometry

  items()

    Return a dictionary with the field names as key, and their value in the feature

  keys()

    Return the list of field names (of the layer definition)

  property thisown

    The membership flag

class osgeo.ogr.FeatureDefn(*args, **kwargs)

  Bases: `object`

  Proxy of C++ OGRFeatureDefnShadow class.

  AddFieldDefn(FeatureDefn self, FieldDefn defn)

    void OGR_FD_AddFieldDefn(OGRFeatureDefnH hDefn, OGRFieldDefnH hNewField)

    Add a new field definition to the passed feature definition.

    To add a new field definition to a layer definition, do not use this function directly, but use OGR_L_CreateField() instead.

    This function should only be called while there are no OGRFeature objects in existence based on this OGRFeatureDefn. The OGRFieldDefn passed in is copied, and remains the responsibility of the caller.

    This function is the same as the C++ method OGRFeatureDefn::AddFieldDefn().

    Parameters:

      - hDefn – handle to the feature definition to add the field definition to.

      - hNewField – handle to the new field definition.

  AddGeomFieldDefn(FeatureDefn self, GeomFieldDefn defn)

    void OGR_FD_AddGeomFieldDefn(OGRFeatureDefnH hDefn, OGRGeomFieldDefnH hNewGeomField)

    Add a new field definition to the passed feature definition.

    To add a new field definition to a layer definition, do not use this function directly, but use OGR_L_CreateGeomField() instead.

    This function should only be called while there are no OGRFeature objects in existence based on this OGRFeatureDefn. The OGRGeomFieldDefn passed in is copied, and remains the responsibility of the caller.

    This function is the same as the C++ method OGRFeatureDefn::AddGeomFieldDefn().

    New in version 1.11.

    Parameters:

      - hDefn – handle to the feature definition to add the geometry field definition to.

      - hNewGeomField – handle to the new field definition.

  DeleteGeomFieldDefn(FeatureDefn self, int idx) → OGRErr

    OGRErr OGR_FD_DeleteGeomFieldDefn(OGRFeatureDefnH hDefn, int iGeomField)

    Delete an existing geometry field definition.

    To delete an existing geometry field definition from a layer definition, do not use this function directly, but use OGR_L_DeleteGeomField() instead ( not implemented yet).

    This method should only be called while there are no OGRFeature objects in existence based on this OGRFeatureDefn.

    This method is the same as the C++ method OGRFeatureDefn::DeleteGeomFieldDefn().

    New in version 1.11.

    Parameters:

      - hDefn – handle to the feature definition.

      - iGeomField – the index of the geometry field definition.

    Returns:

      OGRERR_NONE in case of success.

    Return type:

      OGRErr

  Destroy()

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

  GetFieldCount(FeatureDefn self) → int

    int OGR_FD_GetFieldCount(OGRFeatureDefnH hDefn)

    Fetch number of fields on the passed feature definition.

    This function is the same as the C++ OGRFeatureDefn::GetFieldCount().

    Parameters:

      hDefn – handle to the feature definition to get the fields count from.

    Returns:

      count of fields.

    Return type:

      int

  GetFieldDefn(FeatureDefn self, int i) → FieldDefn

    OGRFieldDefnH OGR_FD_GetFieldDefn(OGRFeatureDefnH hDefn, int iField)

    Fetch field definition of the passed feature definition.

    This function is the same as the C++ method OGRFeatureDefn::GetFieldDefn().

    Parameters:

      - hDefn – handle to the feature definition to get the field definition from.

      - iField – the field to fetch, between 0 and GetFieldCount()-1.

    Returns:

      a handle to an internal field definition object or NULL if invalid index. This object should not be modified or freed by the application.

    Return type:

      OGRFieldDefnH

  GetFieldIndex(FeatureDefn self, char const * field_name) → int

    int OGR_FD_GetFieldIndex(OGRFeatureDefnH hDefn, const char *pszFieldName)

    Find field by name.

    The field index of the first field matching the passed field name (case insensitively) is returned.

    This function is the same as the C++ method OGRFeatureDefn::GetFieldIndex.

    Parameters:

      - hDefn – handle to the feature definition to get field index from.

      - pszFieldName – the field name to search for.

    Returns:

      the field index, or -1 if no match found.

    Return type:

      int

  GetGeomFieldCount(FeatureDefn self) → int

    int OGR_FD_GetGeomFieldCount(OGRFeatureDefnH hDefn)

    Fetch number of geometry fields on the passed feature definition.

    This function is the same as the C++ OGRFeatureDefn::GetGeomFieldCount().

    New in version 1.11.

    Parameters:

      hDefn – handle to the feature definition to get the fields count from.

    Returns:

      count of geometry fields.

    Return type:

      int

  GetGeomFieldDefn(FeatureDefn self, int i) → GeomFieldDefn

    OGRGeomFieldDefnH OGR_FD_GetGeomFieldDefn(OGRFeatureDefnH hDefn, int iGeomField)

    Fetch geometry field definition of the passed feature definition.

    This function is the same as the C++ method OGRFeatureDefn::GetGeomFieldDefn().

    New in version 1.11.

    Parameters:

      - hDefn – handle to the feature definition to get the field definition from.

      - iGeomField – the geometry field to fetch, between 0 and GetGeomFieldCount() - 1.

    Returns:

      a handle to an internal field definition object or NULL if invalid index. This object should not be modified or freed by the application.

    Return type:

      OGRGeomFieldDefnH

  GetGeomFieldIndex(FeatureDefn self, char const * field_name) → int

    int OGR_FD_GetGeomFieldIndex(OGRFeatureDefnH hDefn, const char *pszGeomFieldName)

    Find geometry field by name.

    The geometry field index of the first geometry field matching the passed field name (case insensitively) is returned.

    This function is the same as the C++ method OGRFeatureDefn::GetGeomFieldIndex.

    Parameters:

      - hDefn – handle to the feature definition to get field index from.

      - pszGeomFieldName – the geometry field name to search for.

    Returns:

      the geometry field index, or -1 if no match found.

    Return type:

      int

  GetGeomType(FeatureDefn self) → OGRwkbGeometryType

    OGRwkbGeometryType OGR_FD_GetGeomType(OGRFeatureDefnH hDefn)

    Fetch the geometry base type of the passed feature definition.

    This function is the same as the C++ method OGRFeatureDefn::GetGeomType().

    Starting with GDAL 1.11, this method returns GetGeomFieldDefn(0)->GetType().

    Parameters:

      hDefn – handle to the feature definition to get the geometry type from.

    Returns:

      the base type for all geometry related to this definition.

    Return type:

      OGRwkbGeometryType

  GetName(FeatureDefn self) → char const *

    const char* OGR_FD_GetName(OGRFeatureDefnH hDefn)

    Get name of the OGRFeatureDefn passed as an argument.

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

    Parameters:

      hDefn – handle to the feature definition to get the name from.

    Returns:

      the name. This name is internal and should not be modified, or freed.

    Return type:

      str

  GetReferenceCount(FeatureDefn self) → int

    int OGR_FD_GetReferenceCount(OGRFeatureDefnH hDefn)

    Fetch current reference count.

    This function is the same as the C++ method OGRFeatureDefn::GetReferenceCount().

    Parameters:

      hDefn – handle to the feature definition on witch OGRFeature are based on.

    Returns:

      the current reference count.

    Return type:

      int

  IsGeometryIgnored(FeatureDefn self) → int

    int OGR_FD_IsGeometryIgnored(OGRFeatureDefnH hDefn)

    Determine whether the geometry can be omitted when fetching features.

    This function is the same as the C++ method OGRFeatureDefn::IsGeometryIgnored().

    Starting with GDAL 1.11, this method returns GetGeomFieldDefn(0)->IsIgnored().

    Parameters:

      hDefn – handle to the feature definition on witch OGRFeature are based on.

    Returns:

      ignore state

    Return type:

      int

  IsSame(FeatureDefn self, FeatureDefn other_defn) → int

    int OGR_FD_IsSame(OGRFeatureDefnH hFDefn, OGRFeatureDefnH hOtherFDefn)

    Test if the feature definition is identical to the other one.

    New in version 1.11.

    Parameters:

      - hFDefn – handle to the feature definition on witch OGRFeature are based on.

      - hOtherFDefn – handle to the other feature definition to compare to.

    Returns:

      TRUE if the feature definition is identical to the other one.

    Return type:

      int

  IsStyleIgnored(FeatureDefn self) → int

    int OGR_FD_IsStyleIgnored(OGRFeatureDefnH hDefn)

    Determine whether the style can be omitted when fetching features.

    This function is the same as the C++ method OGRFeatureDefn::IsStyleIgnored().

    Parameters:

      hDefn – handle to the feature definition on which OGRFeature are based on.

    Returns:

      ignore state

    Return type:

      int

  SetGeomType(FeatureDefn self, OGRwkbGeometryType geom_type)

    void OGR_FD_SetGeomType(OGRFeatureDefnH hDefn, OGRwkbGeometryType eType)

    Assign the base geometry type for the passed layer (the same as the feature definition).

    All geometry objects using this type must be of the defined type or a derived type. The default upon creation is wkbUnknown which allows for any geometry type. The geometry type should generally not be changed after any OGRFeatures have been created against this definition.

    This function is the same as the C++ method OGRFeatureDefn::SetGeomType().

    Starting with GDAL 1.11, this method calls GetGeomFieldDefn(0)->SetType().

    Parameters:

      - hDefn – handle to the layer or feature definition to set the geometry type to.

      - eType – the new type to assign.

  SetGeometryIgnored(FeatureDefn self, int bIgnored)

    void OGR_FD_SetGeometryIgnored(OGRFeatureDefnH hDefn, int bIgnore)

    Set whether the geometry can be omitted when fetching features.

    This function is the same as the C++ method OGRFeatureDefn::SetGeometryIgnored().

    Starting with GDAL 1.11, this method calls GetGeomFieldDefn(0)->SetIgnored().

    Parameters:

      - hDefn – handle to the feature definition on witch OGRFeature are based on.

      - bIgnore – ignore state

  SetStyleIgnored(FeatureDefn self, int bIgnored)

    void OGR_FD_SetStyleIgnored(OGRFeatureDefnH hDefn, int bIgnore)

    Set whether the style can be omitted when fetching features.

    This function is the same as the C++ method OGRFeatureDefn::SetStyleIgnored().

    Parameters:

      - hDefn – handle to the feature definition on witch OGRFeature are based on.

      - bIgnore – ignore state

  property thisown

    The membership flag

class osgeo.ogr.FieldDefn(*args, **kwargs)

  Bases: `object`

  Proxy of C++ OGRFieldDefnShadow class.

  Destroy()

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

  GetAlternativeName(FieldDefn self) → char const *
  GetAlternativeNameRef(FieldDefn self) → char const *

    const char* OGR_Fld_GetAlternativeNameRef(OGRFieldDefnH hDefn)

    Fetch the alternative name (or “alias”) for this field.

    The alternative name is an optional attribute for a field which can provide a more user-friendly, descriptive name of a field which is not subject to the usual naming constraints defined by the data provider.

    This is a metadata style attribute only: the alternative name cannot be used in place of the actual field name during SQL queries or other field name dependent API calls.

    This function is the same as the CPP method OGRFieldDefn::GetAlternativeNameRef().

    New in version 3.2.

    Parameters:

      hDefn – handle to the field definition.

    Returns:

      the alternative name of the field definition.

    Return type:

      str

  GetComment(FieldDefn self) → char const *
  GetDefault(FieldDefn self) → char const *

    const char* OGR_Fld_GetDefault(OGRFieldDefnH hDefn)

    Get default field value.

    This function is the same as the C++ method OGRFieldDefn::GetDefault().

    New in version 2.0.

    Parameters:

      hDefn – handle to the field definition.

    Returns:

      default field value or NULL.

    Return type:

      str

  GetDomainName(FieldDefn self) → char const *

    const char* OGR_Fld_GetDomainName(OGRFieldDefnH hDefn)

    Return the name of the field domain for this field.

    By default, none (empty string) is returned.

    Field domains ( OGRFieldDomain class) are attached at the GDALDataset level and should be retrieved with GDALDatasetGetFieldDomain().

    This method is the same as the C++ method OGRFieldDefn::GetDomainName().

    New in version 3.3.

    Parameters:

      hDefn – handle to the field definition

    Returns:

      the field domain name, or an empty string if there is none.

    Return type:

      str

  GetFieldTypeName(FieldDefn self, OGRFieldType type) → char const *
  GetJustify(FieldDefn self) → OGRJustification

    OGRJustification OGR_Fld_GetJustify(OGRFieldDefnH hDefn)

    Get the justification for this field.

    This function is the same as the CPP method OGRFieldDefn::GetJustify().

    Note: no driver is know to use the concept of field justification.

    Parameters:

      hDefn – handle to the field definition to get justification from.

    Returns:

      the justification.

    Return type:

      OGRJustification

  GetName(FieldDefn self) → char const *
  GetNameRef(FieldDefn self) → char const *

    const char* OGR_Fld_GetNameRef(OGRFieldDefnH hDefn)

    Fetch name of this field.

    This function is the same as the CPP method OGRFieldDefn::GetNameRef().

    Parameters:

      hDefn – handle to the field definition.

    Returns:

      the name of the field definition.

    Return type:

      str

  GetPrecision(FieldDefn self) → int

    int OGR_Fld_GetPrecision(OGRFieldDefnH hDefn)

    Get the formatting precision for this field.

    This should normally be zero for fields of types other than OFTReal.

    This function is the same as the CPP method OGRFieldDefn::GetPrecision().

    Parameters:

      hDefn – handle to the field definition to get precision from.

    Returns:

      the precision.

    Return type:

      int

  GetSubType(FieldDefn self) → OGRFieldSubType

    OGRFieldSubType OGR_Fld_GetSubType(OGRFieldDefnH hDefn)

    Fetch subtype of this field.

    This function is the same as the CPP method OGRFieldDefn::GetSubType().

    New in version 2.0.

    Parameters:

      hDefn – handle to the field definition to get subtype from.

    Returns:

      field subtype.

    Return type:

      OGRFieldSubType

  GetType(FieldDefn self) → OGRFieldType

    OGRFieldType OGR_Fld_GetType(OGRFieldDefnH hDefn)

    Fetch type of this field.

    This function is the same as the CPP method OGRFieldDefn::GetType().

    Parameters:

      hDefn – handle to the field definition to get type from.

    Returns:

      field type.

    Return type:

      OGRFieldType

  GetTypeName(FieldDefn self) → char const *
  GetWidth(FieldDefn self) → int

    int OGR_Fld_GetWidth(OGRFieldDefnH hDefn)

    Get the formatting width for this field.

    This function is the same as the CPP method OGRFieldDefn::GetWidth().

    Parameters:

      hDefn – handle to the field definition to get width from.

    Returns:

      the width, zero means no specified width.

    Return type:

      int

  IsDefaultDriverSpecific(FieldDefn self) → int

    int OGR_Fld_IsDefaultDriverSpecific(OGRFieldDefnH hDefn)

    Returns whether the default value is driver specific.

    Driver specific default values are those that are not NULL, a numeric value, a literal value enclosed between single quote characters, CURRENT_TIMESTAMP, CURRENT_TIME, CURRENT_DATE or datetime literal value.

    This function is the same as the C++ method OGRFieldDefn::IsDefaultDriverSpecific().

    New in version 2.0.

    Parameters:

      hDefn – handle to the field definition

    Returns:

      TRUE if the default value is driver specific.

    Return type:

      int

  IsIgnored(FieldDefn self) → int

    int OGR_Fld_IsIgnored(OGRFieldDefnH hDefn)

    Return whether this field should be omitted when fetching features.

    This method is the same as the C++ method OGRFieldDefn::IsIgnored().

    Parameters:

      hDefn – handle to the field definition

    Returns:

      ignore state

    Return type:

      int

  IsNullable(FieldDefn self) → int

    int OGR_Fld_IsNullable(OGRFieldDefnH hDefn)

    Return whether this field can receive null values.

    By default, fields are nullable.

    Even if this method returns FALSE (i.e not-nullable field), it doesn’t mean that OGRFeature::IsFieldSet() will necessary return TRUE, as fields can be temporary unset and null/not-null validation is usually done when OGRLayer::CreateFeature()/SetFeature() is called.

    This method is the same as the C++ method OGRFieldDefn::IsNullable().

    New in version 2.0.

    Parameters:

      hDefn – handle to the field definition

    Returns:

      TRUE if the field is authorized to be null.

    Return type:

      int

  IsUnique(FieldDefn self) → int

    int OGR_Fld_IsUnique(OGRFieldDefnH hDefn)

    Return whether this field has a unique constraint.

    By default, fields have no unique constraint.

    This method is the same as the C++ method OGRFieldDefn::IsUnique().

    New in version 3.2.

    Parameters:

      hDefn – handle to the field definition

    Returns:

      TRUE if the field has a unique constraint.

    Return type:

      int

  SetAlternativeName(FieldDefn self, char const * alternativeName)

    void OGR_Fld_SetAlternativeName(OGRFieldDefnH hDefn, const char *pszAlternativeName)

    Reset the alternative name (or “alias”) for this field.

    The alternative name is an optional attribute for a field which can provide a more user-friendly, descriptive name of a field which is not subject to the usual naming constraints defined by the data provider.

    This is a metadata style attribute only: the alternative name cannot be used in place of the actual field name during SQL queries or other field name dependent API calls.

    This function is the same as the CPP method OGRFieldDefn::SetAlternativeName().

    New in version 3.2.

    Parameters:

      - hDefn – handle to the field definition to apply the new alternative name to.

      - pszAlternativeName – the new alternative name to apply.

  SetComment(FieldDefn self, char const * comment)
  SetDefault(FieldDefn self, char const * pszValue)

    void OGR_Fld_SetDefault(OGRFieldDefnH hDefn, const char *pszDefault)

    Set default field value.

    The default field value is taken into account by drivers (generally those with a SQL interface) that support it at field creation time. OGR will generally not automatically set the default field value to null fields by itself when calling OGRFeature::CreateFeature() / OGRFeature::SetFeature(), but will let the low-level layers to do the job. So retrieving the feature from the layer is recommended.

    The accepted values are NULL, a numeric value, a literal value enclosed between single quote characters (and inner single quote characters escaped by repetition of the single quote character), CURRENT_TIMESTAMP, CURRENT_TIME, CURRENT_DATE or a driver specific expression (that might be ignored by other drivers). For a datetime literal value, format should be ‘YYYY/MM/DD HH:MM:SS[.sss]’ (considered as UTC time).

    Drivers that support writing DEFAULT clauses will advertise the GDAL_DCAP_DEFAULT_FIELDS driver metadata item.

    This function is the same as the C++ method OGRFieldDefn::SetDefault().

    New in version 2.0.

    Parameters:

      - hDefn – handle to the field definition.

      - pszDefault – new default field value or NULL pointer.

  SetDomainName(FieldDefn self, char const * name)

    void OGR_Fld_SetDomainName(OGRFieldDefnH hDefn, const char *pszFieldName)

    Set the name of the field domain for this field.

    Field domains ( OGRFieldDomain) are attached at the GDALDataset level.

    This method is the same as the C++ method OGRFieldDefn::SetDomainName().

    New in version 3.3.

    Parameters:

      - hDefn – handle to the field definition

      - pszFieldName – Field domain name.

  SetIgnored(FieldDefn self, int bIgnored)

    void OGR_Fld_SetIgnored(OGRFieldDefnH hDefn, int ignore)

    Set whether this field should be omitted when fetching features.

    This method is the same as the C++ method OGRFieldDefn::SetIgnored().

    Parameters:

      - hDefn – handle to the field definition

      - ignore – ignore state

  SetJustify(FieldDefn self, OGRJustification justify)

    void OGR_Fld_SetJustify(OGRFieldDefnH hDefn, OGRJustification eJustify)

    Set the justification for this field.

    Note: no driver is know to use the concept of field justification.

    This function is the same as the CPP method OGRFieldDefn::SetJustify().

    Parameters:

      - hDefn – handle to the field definition to set justification to.

      - eJustify – the new justification.

  SetName(FieldDefn self, char const * name)

    void OGR_Fld_SetName(OGRFieldDefnH hDefn, const char *pszName)

    Reset the name of this field.

    This function is the same as the CPP method OGRFieldDefn::SetName().

    Parameters:

      - hDefn – handle to the field definition to apply the new name to.

      - pszName – the new name to apply.

  SetNullable(FieldDefn self, int bNullable)

    void OGR_Fld_SetNullable(OGRFieldDefnH hDefn, int bNullableIn)

    Set whether this field can receive null values.

    By default, fields are nullable, so this method is generally called with FALSE to set a not-null constraint.

    Drivers that support writing not-null constraint will advertise the GDAL_DCAP_NOTNULL_FIELDS driver metadata item.

    This method is the same as the C++ method OGRFieldDefn::SetNullable().

    New in version 2.0.

    Parameters:

      - hDefn – handle to the field definition

      - bNullableIn – FALSE if the field must have a not-null constraint.

  SetPrecision(FieldDefn self, int precision)

    void OGR_Fld_SetPrecision(OGRFieldDefnH hDefn, int nPrecision)

    Set the formatting precision for this field in characters.

    This should normally be zero for fields of types other than OFTReal.

    This function is the same as the CPP method OGRFieldDefn::SetPrecision().

    Parameters:

      - hDefn – handle to the field definition to set precision to.

      - nPrecision – the new precision.

  SetSubType(FieldDefn self, OGRFieldSubType type)

    void OGR_Fld_SetSubType(OGRFieldDefnH hDefn, OGRFieldSubType eSubType)

    Set the subtype of this field.

    This should never be done to an OGRFieldDefn that is already part of an OGRFeatureDefn.

    This function is the same as the CPP method OGRFieldDefn::SetSubType().

    New in version 2.0.

    Parameters:

      - hDefn – handle to the field definition to set type to.

      - eSubType – the new field subtype.

  SetType(FieldDefn self, OGRFieldType type)

    void OGR_Fld_SetType(OGRFieldDefnH hDefn, OGRFieldType eType)

    Set the type of this field.

    This should never be done to an OGRFieldDefn that is already part of an OGRFeatureDefn.

    This function is the same as the CPP method OGRFieldDefn::SetType().

    Parameters:

      - hDefn – handle to the field definition to set type to.

      - eType – the new field type.

  SetUnique(FieldDefn self, int bUnique)

    void OGR_Fld_SetUnique(OGRFieldDefnH hDefn, int bUniqueIn)

    Set whether this field has a unique constraint.

    By default, fields have no unique constraint, so this method is generally called with TRUE to set a unique constraint.

    Drivers that support writing unique constraint will advertise the GDAL_DCAP_UNIQUE_FIELDS driver metadata item. field can receive null values.

    This method is the same as the C++ method OGRFieldDefn::SetUnique().

    New in version 3.2.

    Parameters:

      - hDefn – handle to the field definition

      - bUniqueIn – TRUE if the field must have a unique constraint.

  SetWidth(FieldDefn self, int width)

    void OGR_Fld_SetWidth(OGRFieldDefnH hDefn, int nNewWidth)

    Set the formatting width for this field in characters.

    This function is the same as the CPP method OGRFieldDefn::SetWidth().

    Parameters:

      - hDefn – handle to the field definition to set width to.

      - nNewWidth – the new width.

  property justify: OGRJustification

    GetJustify(FieldDefn self) -> OGRJustification OGRJustification OGR_Fld_GetJustify(OGRFieldDefnH hDefn)

    Get the justification for this field.

    This function is the same as the CPP method OGRFieldDefn::GetJustify().

    Note: no driver is know to use the concept of field justification.

    Parameters:

      hDefn – handle to the field definition to get justification from.

    Returns:

      the justification.

    Return type:

      OGRJustification

  property name: char const *

    GetName(FieldDefn self) -> char const *

  property precision: int

    GetPrecision(FieldDefn self) -> int int OGR_Fld_GetPrecision(OGRFieldDefnH hDefn)

    Get the formatting precision for this field.

    This should normally be zero for fields of types other than OFTReal.

    This function is the same as the CPP method OGRFieldDefn::GetPrecision().

    Parameters:

      hDefn – handle to the field definition to get precision from.

    Returns:

      the precision.

    Return type:

      int

  property thisown

    The membership flag

  property type: OGRFieldType

    GetType(FieldDefn self) -> OGRFieldType OGRFieldType OGR_Fld_GetType(OGRFieldDefnH hDefn)

    Fetch type of this field.

    This function is the same as the CPP method OGRFieldDefn::GetType().

    Parameters:

      hDefn – handle to the field definition to get type from.

    Returns:

      field type.

    Return type:

      OGRFieldType

  property width: int

    GetWidth(FieldDefn self) -> int int OGR_Fld_GetWidth(OGRFieldDefnH hDefn)

    Get the formatting width for this field.

    This function is the same as the CPP method OGRFieldDefn::GetWidth().

    Parameters:

      hDefn – handle to the field definition to get width from.

    Returns:

      the width, zero means no specified width.

    Return type:

      int

class osgeo.ogr.FieldDomain(*args, **kwargs)

  Bases: `object`

  Proxy of C++ OGRFieldDomainShadow class.

  GetDescription(FieldDomain self) → char const *
  GetDomainType(FieldDomain self) → OGRFieldDomainType
  GetEnumeration(FieldDomain self) → OGRCodedValue const *
  GetFieldSubType(FieldDomain self) → OGRFieldSubType
  GetFieldType(FieldDomain self) → OGRFieldType
  GetGlob(FieldDomain self) → char const *
  GetMaxAsDouble(FieldDomain self) → double
  GetMergePolicy(FieldDomain self) → OGRFieldDomainMergePolicy
  GetMinAsDouble(FieldDomain self) → double
  GetName(FieldDomain self) → char const *
  GetSplitPolicy(FieldDomain self) → OGRFieldDomainSplitPolicy
  IsMaxInclusive(FieldDomain self) → bool
  IsMinInclusive(FieldDomain self) → bool
  SetMergePolicy(FieldDomain self, OGRFieldDomainMergePolicy policy)
  SetSplitPolicy(FieldDomain self, OGRFieldDomainSplitPolicy policy)
  property thisown

    The membership flag

osgeo.ogr.ForceTo(Geometry geom_in, OGRwkbGeometryType eTargetType, char ** options=None) → Geometry

osgeo.ogr.ForceToLineString(Geometry geom_in) → Geometry

osgeo.ogr.ForceToMultiLineString(Geometry geom_in) → Geometry

osgeo.ogr.ForceToMultiPoint(Geometry geom_in) → Geometry

osgeo.ogr.ForceToMultiPolygon(Geometry geom_in) → Geometry

osgeo.ogr.ForceToPolygon(Geometry geom_in) → Geometry

osgeo.ogr.GT_Flatten(OGRwkbGeometryType eType) → OGRwkbGeometryType

osgeo.ogr.GT_GetCollection(OGRwkbGeometryType eType) → OGRwkbGeometryType

osgeo.ogr.GT_GetCurve(OGRwkbGeometryType eType) → OGRwkbGeometryType

osgeo.ogr.GT_GetLinear(OGRwkbGeometryType eType) → OGRwkbGeometryType

osgeo.ogr.GT_HasM(OGRwkbGeometryType eType) → int

osgeo.ogr.GT_HasZ(OGRwkbGeometryType eType) → int

osgeo.ogr.GT_IsCurve(OGRwkbGeometryType arg1) → int

osgeo.ogr.GT_IsNonLinear(OGRwkbGeometryType arg1) → int

osgeo.ogr.GT_IsSubClassOf(OGRwkbGeometryType eType, OGRwkbGeometryType eSuperType) → int

osgeo.ogr.GT_IsSurface(OGRwkbGeometryType arg1) → int

osgeo.ogr.GT_SetM(OGRwkbGeometryType eType) → OGRwkbGeometryType

osgeo.ogr.GT_SetModifier(OGRwkbGeometryType eType, int bSetZ, int bSetM=FALSE) → OGRwkbGeometryType

osgeo.ogr.GT_SetZ(OGRwkbGeometryType eType) → OGRwkbGeometryType

osgeo.ogr.GeneralCmdLineProcessor(char ** papszArgv, int nOptions=0) → char **

class osgeo.ogr.GeomFieldDefn(*args, **kwargs)

  Bases: `object`

  Proxy of C++ OGRGeomFieldDefnShadow class.

  GetName(GeomFieldDefn self) → char const *
  GetNameRef(GeomFieldDefn self) → char const *
  GetSpatialRef(GeomFieldDefn self) → SpatialReference
  GetType(GeomFieldDefn self) → OGRwkbGeometryType
  IsIgnored(GeomFieldDefn self) → int
  IsNullable(GeomFieldDefn self) → int
  SetIgnored(GeomFieldDefn self, int bIgnored)
  SetName(GeomFieldDefn self, char const * name)
  SetNullable(GeomFieldDefn self, int bNullable)
  SetSpatialRef(GeomFieldDefn self, SpatialReference srs)
  SetType(GeomFieldDefn self, OGRwkbGeometryType type)
  property name: char const *

    GetName(GeomFieldDefn self) -> char const *

  property srs: OSRSpatialReferenceShadow *

    GetSpatialRef(GeomFieldDefn self) -> SpatialReference

  property thisown

    The membership flag

  property type: OGRwkbGeometryType

    GetType(GeomFieldDefn self) -> OGRwkbGeometryType

class osgeo.ogr.GeomTransformer(*args)

  Bases: `object`

  Proxy of C++ OGRGeomTransformerShadow class.

  Transform(GeomTransformer self, Geometry src_geom) → Geometry
  property thisown

    The membership flag

class osgeo.ogr.Geometry(*args, **kwargs)

  Bases: `object`

  Proxy of C++ OGRGeometryShadow class.

  AddGeometry(Geometry self, Geometry other) → OGRErr
  AddGeometryDirectly(Geometry self, Geometry other_disown) → OGRErr
  AddPoint(Geometry self, double x, double y, double z=0)
  AddPointM(Geometry self, double x, double y, double m)
  AddPointZM(Geometry self, double x, double y, double z, double m)
  AddPoint_2D(Geometry self, double x, double y)
  Area(Geometry self) → double
  AssignSpatialReference(Geometry self, SpatialReference reference)

    Assign spatial reference to this object.

    For more details: `OGR_G_AssignSpatialReference()`

    Parameters:

      reference (SpatialReference) – The new spatial reference system to apply.

  Boundary(Geometry self) → Geometry

    Compute boundary.

    For more details: `OGR_G_Boundary()`

    Returns:

      A new geometry or None on failure.

    Return type:

      Geometry

  Buffer(Geometry self, double distance, int quadsecs=30) → Geometry

    Compute buffer of geometry.

    For more details: `OGR_G_Buffer()`

    Parameters:

      - distance (float) – The buffer distance to be applied. Should be expressed into the same unit as the coordinates of the geometry.

      - quadsecs (int, default=30) – The number of segments used to approximate a 90 degree (quadrant) of curvature.

    Returns:

      The newly created geometry or None if an error occurs.

    Return type:

      Geometry

  Centroid(Geometry self) → Geometry

    Compute the geometry centroid.

    For more details: `OGR_G_Centroid()`

    Return type:

      Geometry

  Clone(Geometry self) → Geometry

    Make a copy of this object.

    For more details: `OGR_G_Clone()`

    Returns:

      The copy of the geometry with the same spatial reference system as the original.

    Return type:

      Geometry

  CloseRings(Geometry self)

    Force rings to be closed.

    For more details: `OGR_G_CloseRings()`

  ConcaveHull(Geometry self, double ratio, bool allowHoles) → Geometry
  Contains(Geometry self, Geometry other) → bool

    Test for containment.

    For more details: `OGR_G_Contains()`

    Parameters:

      other (Geometry) – the other geometry to compare.

    Returns:

      True if this contains the other geometry, otherwise False.

    Return type:

      int

  ConvexHull(Geometry self) → Geometry

    Compute convex hull.

    For more details: `OGR_G_ConvexHull()`

    Returns:

      a handle to A newly allocated geometry now owned by the caller, or None on failure.

    Return type:

      Geometry

  CoordinateDimension(Geometry self) → int

    Get the dimension of the coordinates in this geometry.

    For more details: `OGR_G_CoordinateDimension()`

    New in version 2.1.

    Returns:

      This will return 2 for XY, 3 for XYZ and XYM, and 4 for XYZM data.

    Return type:

      int

  CreatePreparedGeometry(Geometry self) → PreparedGeometry
  Crosses(Geometry self, Geometry other) → bool

    Test for crossing.

    For more details: `OGR_G_Crosses()`

    Parameters:

      other (Geometry) – the other geometry to compare.

    Returns:

      True if they are crossing, otherwise False.

    Return type:

      int

  DelaunayTriangulation(Geometry self, double dfTolerance=0.0, int bOnlyEdges=FALSE) → Geometry

    Return a Delaunay triangulation of the vertices of the geometry.

    For more details: `OGR_G_DelaunayTriangulation()`

    New in version 2.1.

    Parameters:

      - dfTolerance (float) – optional snapping tolerance to use for improved robustness

      - bOnlyEdges (bool) – If True, will return a MULTILINESTRING, otherwise it will return a GEOMETRYCOLLECTION containing triangular POLYGONs.

    Returns:

      The geometry resulting from the Delaunay triangulation or None if an error occurs.

    Return type:

      Geometry

  Destroy()
  Difference(Geometry self, Geometry other) → Geometry

    Compute difference.

    For more details: `OGR_G_Difference()`

    Parameters:

      other (Geometry) – The other geometry.

    Returns:

      A new geometry representing the difference or None if the difference is empty or an error occurs.

    Return type:

      Geometry

  Disjoint(Geometry self, Geometry other) → bool

    Test for disjointness.

    For more details: `OGR_G_Disjoint()`

    Parameters:

      other (Geometry) – The other geometry to compare.

    Returns:

      True if they are disjoint, otherwise False.

    Return type:

      int

  Distance(Geometry self, Geometry other) → double

    Compute distance between two geometries.

    For more details: `OGR_G_Distance()`

    Parameters:

      other (Geometry) – The other geometry to compare against.

    Returns:

      The distance between the geometries or -1 if an error occurs.

    Return type:

      float

  Distance3D(Geometry self, Geometry other) → double

    Returns the 3D distance between two geometries.

    For more details: `OGR_G_Distance3D()`

    New in version 2.2.

    Parameters:

      other (Geometry) – The other geometry to compare against.

    Returns:

      The distance between the geometries or -1 if an error occurs.

    Return type:

      float

  Empty(Geometry self)

    Clear geometry information.

    For more details: `OGR_G_Empty()`

  Equal(Geometry self, Geometry other) → bool
  Equals(Geometry self, Geometry other) → bool

    Returns True if two geometries are equivalent.

    For more details: `OGR_G_Equals()`

    Parameters:

      other (Geometry) – The other geometry to test against.

    Returns:

      True if equivalent or False otherwise.

    Return type:

      int

  ExportToGML(Geometry self, char ** options=None) → retStringAndCPLFree *
  ExportToIsoWkb(Geometry self, OGRwkbByteOrder byte_order=wkbNDR) → OGRErr

    Convert a geometry into SFSQL 1.2 / ISO SQL/MM Part 3 well known binary format.

    For more details: `OGR_G_ExportToIsoWkb()`

    New in version 2.0.

    Parameters:

      byte_order (osgeo.ogr.wkbXDR | osgeo.ogr.wkbNDR, default=osgeo.ogr.wkbNDR) – One of wkbXDR or wkbNDR indicating MSB or LSB byte order respectively.

    Return type:

      bytes

  ExportToIsoWkt(Geometry self) → OGRErr

    Convert a geometry into SFSQL 1.2 / ISO SQL/MM Part 3 well known text format.

    For more details: `OGR_G_ExportToIsoWkt()`

    New in version 2.0.

    Return type:

      str

  ExportToJson(Geometry self, char ** options=None) → retStringAndCPLFree *
  ExportToKML(Geometry self, char const * altitude_mode=None) → retStringAndCPLFree *
  ExportToWkb(Geometry self, OGRwkbByteOrder byte_order=wkbNDR) → OGRErr

    Convert a geometry well known binary format.

    For more details: `OGR_G_ExportToWkb()`

    Parameters:

      byte_order (osgeo.ogr.wkbXDR | osgeo.ogr.wkbNDR, default=osgeo.ogr.wkbNDR) – One of wkbXDR or wkbNDR indicating MSB or LSB byte order respectively.

    Return type:

      bytes

  ExportToWkt(Geometry self) → OGRErr

    Convert a geometry into well known text format.

    For more details: `OGR_G_ExportToWkt()`

    Return type:

      str

  FlattenTo2D(Geometry self)

    Convert geometry to strictly 2D.

    For more details: `OGR_G_FlattenTo2D()`

  GetArea(Geometry self) → double
  GetBoundary(Geometry self) → Geometry

    Compute boundary (deprecated)

    For more details: `OGR_G_GetBoundary()`

    ..warning:: Deprecated

    See: `OGR_G_Boundary()`

  GetCoordinateDimension(Geometry self) → int

    Get the dimension of the coordinates in this geometry.

    For more details: `OGR_G_GetCoordinateDimension()`

    Warning

    Deprecated. Use `CoordinateDimension()`, `Is3D()`, or `IsMeasured()`.

    Returns:

      This will return 2 or 3.

    Return type:

      int

  GetCurveGeometry(Geometry self, char ** options=None) → Geometry
  GetDimension(Geometry self) → int

    Get the dimension of this geometry.

    For more details: `OGR_G_GetDimension()`

    Returns:

      0 for points, 1 for lines, and 2 for surfaces.

    Return type:

      int

  GetEnvelope(Geometry self)

    Computes and returns the bounding envelope for this geometry in the passed psEnvelope structure.

    For more details: `OGR_G_GetEnvelope()`

    Warning

    Check the return order of the bounds.

    Returns:

      - minx (float)

      - maxx (float)

      - miny (float)

      - maxy (float)

  GetEnvelope3D(Geometry self)

    Computes and returns the bounding envelope (3D) for this geometry in the passed psEnvelope structure.

    For more details: `OGR_G_GetEnvelope3D()`

    Warning

    Check the return order of the bounds.

    Returns:

      - minx (float)

      - maxx (float)

      - miny (float)

      - maxy (float)

      - minz (float)

      - maxz (float)

  GetGeometryCount(Geometry self) → int
  GetGeometryName(Geometry self) → char const *

    Fetch WKT name for geometry type.

    For more details: `OGR_G_GetGeometryName()`

    geometry to get name from.

    Return type:

      str

  GetGeometryRef(Geometry self, int geom) → Geometry
  GetGeometryType(Geometry self) → OGRwkbGeometryType

    Fetch geometry type.

    For more details: `OGR_G_GetGeometryType()`

    Returns:

      The geometry type code. The types can be found with ‘osgeo.ogr.wkb’ prefix. For example `osgeo.ogr.wkbPolygon`.

    Return type:

      int

  GetLinearGeometry(Geometry self, double dfMaxAngleStepSizeDegrees=0.0, char ** options=None) → Geometry
  GetM(Geometry self, int point=0) → double
  GetPoint(Geometry self, int iPoint=0)
  GetPointCount(Geometry self) → int
  GetPointZM(Geometry self, int iPoint=0)
  GetPoint_2D(Geometry self, int iPoint=0)
  GetPoints(Geometry self, int nCoordDimension=0)
  GetSpatialReference(Geometry self) → SpatialReference

    For more details: `OGR_G_GetSpatialReference()`

    Returns spatial reference system for geometry.

    Return type:

      SpatialReference

  GetX(Geometry self, int point=0) → double
  GetY(Geometry self, int point=0) → double
  GetZ(Geometry self, int point=0) → double
  HasCurveGeometry(Geometry self, int bLookForCircular=FALSE) → int
  Intersect(Geometry self, Geometry other) → bool
  Intersection(Geometry self, Geometry other) → Geometry

    Compute intersection.

    For more details: `OGR_G_Intersection()`

    Parameters:

      other (Geometry) – The other geometry.

    Returns:

      A new geometry representing the intersection or None if there is no intersection or an error occurs.

    Return type:

      Geometry

  Intersects(Geometry self, Geometry other) → bool

    Determines whether two geometries intersect.

    For more details: `OGR_G_Intersects()`

    Parameters:

      other (Geometry) – The other geometry to test against.

    Returns:

      True if the geometries intersect, otherwise False.

    Return type:

      int

  Is3D(Geometry self) → int

    See whether this geometry has Z coordinates.

    For more details: `OGR_G_Is3D()`

    New in version 2.1.

    Returns:

      True if the geometry has Z coordinates.

    Return type:

      int

  IsEmpty(Geometry self) → bool

    Test if the geometry is empty.

    For more details: `OGR_G_IsEmpty()`

    Returns:

      True if the geometry has no points, otherwise False.

    Return type:

      int

  IsMeasured(Geometry self) → int

    See whether this geometry is measured.

    For more details: `OGR_G_IsMeasured()`

    New in version 2.1.

    Returns:

      True if the geometry has M coordinates.

    Return type:

      int

  IsRing(Geometry self) → bool

    Test if the geometry is a ring.

    For more details: `OGR_G_IsRing()`

    Returns:

      True if the geometry has no points, otherwise False.

    Return type:

      int

  IsSimple(Geometry self) → bool

    Returns True if the geometry is simple.

    For more details: `OGR_G_IsSimple()`

    Returns:

      True if object is simple, otherwise False.

    Return type:

      int

  IsValid(Geometry self) → bool

    Test if the geometry is valid.

    For more details: `OGR_G_IsValid()`

    Returns:

      True if the geometry has no points, otherwise False.

    Return type:

      int

  Length(Geometry self) → double
  MakeValid(Geometry self, char ** options=None) → Geometry

    Attempts to make an invalid geometry valid without losing vertices.

    For more details: `OGR_G_MakeValidEx()`

    New in version 3.0.

    New in version 3.4: options

    Parameters:

      options (list[str], optional) – papszOptions to be passed in. For example: [“METHOD=STRUCTURE”].

    Returns:

      A newly allocated geometry now owned by the caller, or None on failure.

    Return type:

      Geometry

  Normalize(Geometry self) → Geometry

    Attempts to bring geometry into normalized/canonical form.

    For more details: `OGR_G_Normalize()`

    New in version 3.3.

    Returns:

      A newly allocated geometry now owned by the caller, or None on failure.

    Return type:

      Geometry

  Overlaps(Geometry self, Geometry other) → bool

    Test for overlap.

    For more details: `OGR_G_Overlaps()`

    Parameters:

      other (Geometry) – the other geometry to compare.

    Returns:

      True if they are overlapping, otherwise False.

    Return type:

      int

  PointOnSurface(Geometry self) → Geometry

    Returns a point guaranteed to lie on the surface.

    For more details: `OGR_G_PointOnSurface()`

    Returns:

      A point guaranteed to lie on the surface or None if an error occurred.

    Return type:

      Geometry

  Polygonize(Geometry self) → Geometry

    Polygonizes a set of sparse edges.

    For more details: `OGR_G_Polygonize()`

    Returns:

      A new geometry or None on failure.

    Return type:

      Geometry

  RemoveGeometry(Geometry self, int iSubGeom) → OGRErr
  RemoveLowerDimensionSubGeoms(Geometry self) → Geometry
  Segmentize(Geometry self, double dfMaxLength)

    Modify the geometry such it has no segment longer then the given distance.

    For more details: `OGR_G_Segmentize()`

    Parameters:

      dfMaxLength (float) – the maximum distance between 2 points after segmentization

  Set3D(Geometry self, int b3D)

    Add or remove the Z coordinate dimension.

    For more details: `OGR_G_Set3D()`

    New in version 2.1.

    Parameters:

      bIs3D (bool) – Should the geometry have a Z dimension, either True or False.

  SetCoordinateDimension(Geometry self, int dimension)

    Set the coordinate dimension.

    For more details: `OGR_G_SetCoordinateDimension()`

    Warning

    Deprecated. Use `Set3D()` or `SetMeasured()`.

    Parameters:

      dimension (int) – New coordinate dimension value, either 2 or 3.

  SetMeasured(Geometry self, int bMeasured)

    Add or remove the M coordinate dimension.

    For more details: `OGR_G_SetMeasured()`

    New in version 2.1.

    Parameters:

      bIsMeasured (bool) – Should the geometry have a M dimension, either True or False.

  SetPoint(Geometry self, int point, double x, double y, double z=0)
  SetPointM(Geometry self, int point, double x, double y, double m)
  SetPointZM(Geometry self, int point, double x, double y, double z, double m)
  SetPoint_2D(Geometry self, int point, double x, double y)
  Simplify(Geometry self, double tolerance) → Geometry

    Compute a simplified geometry.

    For more details: `OGR_G_Simplify()`

    Parameters:

      tolerance (float) – The distance tolerance for the simplification.

    Returns:

      The simplified geometry or None if an error occurs.

    Return type:

      Geometry

  SimplifyPreserveTopology(Geometry self, double tolerance) → Geometry

    Simplify the geometry while preserving topology.

    For more details: `OGR_G_SimplifyPreserveTopology()`

    Parameters:

      tolerance (float) – The distance tolerance for the simplification.

    Returns:

      The simplified geometry or None if an error occurs.

    Return type:

      Geometry

  SwapXY(Geometry self)

    Swap x and y coordinates.

    For more details: `OGR_G_SwapXY()`

    New in version 2.3.0.

  SymDifference(Geometry self, Geometry other) → Geometry

    Compute symmetric difference.

    For more details: `OGR_G_SymDifference()`

    Parameters:

      other – the other geometry.

    Returns:

      A new geometry representing the symmetric difference or None if the difference is empty or an error occurs.

    Return type:

      Geometry

  SymmetricDifference(Geometry self, Geometry other) → Geometry

    Compute symmetric difference (deprecated)

    For more details: `OGR_G_SymmetricDifference()`

    Warning

    Deprecated

  Touches(Geometry self, Geometry other) → bool

    Test for touching.

    For more details: `OGR_G_Touches()`

    Parameters:

      other – the other geometry to compare.

    Returns:

      True if they are touching, otherwise False.

    Return type:

      int

  Transform(Geometry self, CoordinateTransformation trans) → OGRErr
  Transform(Geometry self, GeomTransformer transformer) → Geometry

    Apply arbitrary coordinate transformation to geometry.

    For more details: `OGR_G_Transform()`

    Parameters:

      trans (CoordinateTransform) – The transformation to apply.

    Returns:

      The transformed geometry.

    Return type:

      Geometry

  TransformTo(Geometry self, SpatialReference reference) → OGRErr

    Transform geometry to new spatial reference system.

    For more details: `OGR_G_TransformTo()`

    Parameters:

      reference (SpatialReference) – The spatial reference system to apply.

    Returns:

      `osgeo.ogr.OGRERR_NONE` on success, or an error code.

    Return type:

      int

  Union(Geometry self, Geometry other) → Geometry

    Compute union.

    For more details: `OGR_G_Union()`

    Parameters:

      other (Geometry) – The other geometry.

    Returns:

      A new geometry representing the union or None if an error occurs.

    Return type:

      Geometry

  UnionCascaded(Geometry self) → Geometry

    Compute union using cascading.

    For more deails: `OGR_G_UnionCascaded()`

    Returns:

      A new geometry representing the union or None if an error occurs.

    Return type:

      Geometry

  Value(Geometry self, double dfDistance) → Geometry
  Within(Geometry self, Geometry other) → bool

    Test for containment.

    For more details: `OGR_G_Within()`

    Parameters:

      other (Geometry) – the other geometry to compare.

    Returns:

      True if this is within other, otherwise False.

    Return type:

      int

  WkbSize(Geometry self) → size_t

    Returns size of related binary representation.

    For more details: `OGR_G_WkbSize()`

    Return type:

      int

  property thisown

    The membership flag

osgeo.ogr.GeometryTypeToName(OGRwkbGeometryType eType) → char const *

osgeo.ogr.GetDriver(int driver_number) → Driver

osgeo.ogr.GetDriverByName(char const * name) → Driver

osgeo.ogr.GetDriverCount() → int

osgeo.ogr.GetFieldSubTypeName(OGRFieldSubType type) → char const *

osgeo.ogr.GetFieldTypeName(OGRFieldType type) → char const *

osgeo.ogr.GetGEOSVersionMajor() → int

osgeo.ogr.GetGEOSVersionMicro() → int

osgeo.ogr.GetGEOSVersionMinor() → int

osgeo.ogr.GetNonLinearGeometriesEnabledFlag() → int

osgeo.ogr.GetOpenDS(int ds_number) → DataSource

osgeo.ogr.GetOpenDSCount() → int

osgeo.ogr.GetUseExceptions() → int

class osgeo.ogr.Layer(*args, **kwargs)

  Bases: `MajorObject`

  Proxy of C++ OGRLayerShadow class.

  AlterFieldDefn(Layer self, int iField, FieldDefn field_def, int nFlags) → OGRErr

    Alter the definition of an existing field on a layer.

    For more details: `OGR_L_AlterFieldDefn()`

    Parameters:

      - iField (int) – index of the field whose definition must be altered.

      - field_def (FieldDefn) – new field definition

      - nFlags (int) – Combination of `osgeo.ogr.ALTER_NAME_FLAG`, `osgeo.ogr.ALTER_TYPE_FLAG`, `osgeo.ogr.ALTER_WIDTH_PRECISION_FLAG`, `osgeo.ogr.ALTER_NULLABLE_FLAG` and `osgeo.ogr.ALTER_DEFAULT_FLAG` to indicate which of the name and/or type and/or width and precision fields and/or nullability from the new field definition must be taken into account.

    Returns:

      `osgeo.ogr.OGRERR_NONE` on success.

    Return type:

      int

  AlterGeomFieldDefn(Layer self, int iGeomField, GeomFieldDefn field_def, int nFlags) → OGRErr
  Clip(Layer self, Layer method_layer, Layer result_layer, char ** options=None, GDALProgressFunc callback=0, void * callback_data=None) → OGRErr

    Clip off areas that are not covered by the method layer.

    For more details: `OGR_L_Clip()`

    Parameters:

      - method_layer (Layer) – the method layer. Should not be None.

      - result_layer (Layer) – the layer where the features resulting from the operation are inserted. Should not be None.

      - options (list[str], optional) – List of options (empty list is allowed). For example [“PROMOTE_TO_MULTI=YES”].

      - callback (Callable, optional) – a GDALProgressFunc() compatible callback function for reporting progress or None.

      - callback_data – Argument to be passed to ‘callback’. May be None.

    Returns:

      An error code if there was an error or the execution was interrupted, `osgeo.ogr.OGRERR_NONE` otherwise.

    Return type:

      int

  CommitTransaction(Layer self) → OGRErr

    For datasources which support transactions, this commits a transaction.

    For more details: `OGR_L_CommitTransaction()`

    Returns:

      `osgeo.ogr.OGRERR_NONE` on success.

    Return type:

      int

  CreateFeature(Layer self, Feature feature) → OGRErr

    Create and write a new feature within a layer.

    For more details: `OGR_L_CreateFeature()`

    To create a feature, but set it if it exists see `Layer.UpsertFeature()`.

    Parameters:

      feature (Feature) – The feature to write to disk.

    Returns:

      `osgeo.ogr.OGRERR_NONE` on success.

    Return type:

      int

  CreateField(Layer self, FieldDefn field_def, int approx_ok=1) → OGRErr

    Create a new field on a layer.

    For more details: `OGR_L_CreateField()`

    Parameters:

      - field_def (FieldDefn) – The field definition to write to disk.

      - approx_ok (bool, default=True) – If True, the field may be created in a slightly different form depending on the limitations of the format driver.

    Returns:

      `osgeo.ogr.OGRERR_NONE` on success.

    Return type:

      int

  CreateFields(fields)

    Create a list of fields on the Layer

  CreateGeomField(Layer self, GeomFieldDefn field_def, int approx_ok=1) → OGRErr

    Create a new geometry field on a layer.

    For more details: `OGR_L_CreateGeomField()`

    Parameters:

      - field_def (GeomFieldDefn) – The geometry field definition to write to disk.

      - approx_ok (bool, default=True) – If True, the field may be created in a slightly different form depending on the limitations of the format driver.

    Returns:

      `osgeo.ogr.OGRERR_NONE` on success.

    Return type:

      int

  DeleteFeature(Layer self, GIntBig fid) → OGRErr

    Delete feature from layer.

    For more details: `OGR_L_DeleteFeature()`

    Parameters:

      fid (int) – The feature id to be deleted from the layer

    Returns:

      `osgeo.ogr.OGRERR_NONE` if the operation works, otherwise an appropriate error code (e.g `osgeo.ogr.OGRERR_NON_EXISTING_FEATURE`) if the feature does not exist.

    Return type:

      int

  DeleteField(Layer self, int iField) → OGRErr

    Delete an existing field on a layer.

    For more details: `OGR_L_DeleteField()`

    Parameters:

      iField (int) – index of the field to delete.

    Returns:

      `osgeo.ogr.OGRERR_NONE` on success.

    Return type:

      int

  Dereference()

    For backwards compatibility only.

  Erase(Layer self, Layer method_layer, Layer result_layer, char ** options=None, GDALProgressFunc callback=0, void * callback_data=None) → OGRErr

    Remove areas that are covered by the method layer.

    For more details: `OGR_L_Erase()`

    Parameters:

      - method_layer (Layer) – the method layer. Should not be None.

      - result_layer (Layer) – the layer where the features resulting from the operation are inserted. Should not be None.

      - options (list[str], optional) – List of options (empty list is allowed). For example [“PROMOTE_TO_MULTI=YES”].

      - callback (Callable, optional) – a GDALProgressFunc() compatible callback function for reporting progress or None.

      - callback_data – Argument to be passed to ‘callback’. May be None.

    Returns:

      An error code if there was an error or the execution was interrupted, `osgeo.ogr.OGRERR_NONE` otherwise.

    Return type:

      int

  FindFieldIndex(Layer self, char const * pszFieldName, int bExactMatch) → int

    Find the index of field in a layer.

    For more details: `OGR_L_FindFieldIndex()`

    Returns:

      field index, or -1 if the field doesn’t exist

    Return type:

      int

  GetArrowStream(Layer self, char ** options=None) → ArrowArrayStream
  GetArrowStreamAsNumPy(options=[])

    Return an ArrowStream as NumPy Array objects. A specific option to this method is USE_MASKED_ARRAYS=YES/NO (default is YES).

  GetArrowStreamAsPyArrow(options=[])

    Return an ArrowStream as PyArrow Schema and Array objects

  GetExtent(Layer self, int force=1, int can_return_null=0, int geom_field=0)

    Fetch the extent of this layer.

    For more details:

    - `OGR_L_GetExtent()`

    - `OGR_L_GetExtentEx()`

    Warning

    Check the return order of the bounds.

    Parameters:

      - force (int, default=False) – Flag indicating whether the extent should be computed even if it is expensive.

      - can_return_null (int, default=False) – Whether None can be returned in the response.

      - geom_field (int, default=0) – Ithe index of the geometry field on which to compute the extent. Can be iterated over using `range()` and `GetGeomFieldCount()`.

    Returns:

      - minx (float)

      - maxx (float)

      - miny (float)

      - maxy (float)

  GetFIDColumn(Layer self) → char const *

    This method returns the name of the underlying database column being used as the FID column, or ‘’ if not supported.

    For more details: `OGR_L_GetFIDColumn()`

    Returns:

      fid column name.

    Return type:

      str

  GetFeature(Layer self, GIntBig fid) → Feature

    Fetch a feature by its identifier.

    For more details: `OGR_L_GetFeature()`

    Use `TestCapability()` with (`osgeo.ogr.OLCRandomRead`) to establish if this layer supports efficient random access reading via `GetFeature()`; However, the call should always work if the feature exists.

    Sequential reads (with `GetNextFeature()`) are generally considered interrupted by a `GetFeature()` call.

    Parameters:

      fid (int) – The feature id of the feature to read.

    Returns:

      A new feature now owned by the caller, or None on failure. The returned feature should be deleted with `Destroy()`.

    Return type:

      Feature

  GetFeatureCount(Layer self, int force=1) → GIntBig

    Fetch the feature count in this layer.

    For more details: `OGR_L_GetFeatureCount()`

    Parameters:

      force (int) – Flag indicating whether the count should be computed even if it is expensive.

    Returns:

      Feature count, -1 if count not known.

    Return type:

      int

  GetFeaturesRead(Layer self) → GIntBig

    For more details: `OGR_L_GetFeaturesRead()`

  GetGeomType(Layer self) → OGRwkbGeometryType

    Return the layer geometry type.

    For more details: `OGR_L_GetGeomType()`

    Returns:

      The geometry type code. The types can be found with ‘osgeo.ogr.wkb’ prefix. For example `osgeo.ogr.wkbPolygon`.

    Return type:

      int

  GetGeometryColumn(Layer self) → char const *

    This method returns the name of the underlying database column being used as the geometry column, or ‘’ if not supported.

    For more details: `OGR_L_GetGeometryColumn()`

    Returns:

      geometry column name.

    Return type:

      str

  GetGeometryTypes(Layer self, int geom_field=0, int flags=0, GDALProgressFunc callback=0, void * callback_data=None)

    Get actual geometry types found in features.

    For more details: `OGR_L_GetGeometryTypes()`

    Parameters:

      - geom_field (int, optional) – index of the geometry field

      - flags (int, optional) – 0, or a combination of `osgeo.ogr.GGT_COUNT_NOT_NEEDED`, `osgeo.ogr.GGT_STOP_IF_MIXED` and `osgeo.ogr.GGT_GEOMCOLLECTIONZ_TINZ`

      - callback (Callable, optional) – a GDALProgressFunc() compatible callback function for cancellation or None.

      - callback_data – Argument to be passed to ‘callback’. May be None.

    Returns:

      A dictionary whose keys are `osgeo.ogr.wkbXXXX` constants and values the corresponding number of geometries of that type in the layer.

    Return type:

      dict

  GetLayerDefn(Layer self) → FeatureDefn

    Fetch the schema information for this layer.

    For more details: `OGR_L_GetLayerDefn()`

    Returns:

      The feature definition.

    Return type:

      FeatureDefn

  GetName(Layer self) → char const *

    Return the layer name.

    For more details: `OGR_L_GetName()`

    Returns:

      The layer name

    Return type:

      str

  GetNextFeature(Layer self) → Feature

    Fetch the next available feature from this layer.

    For more details: `OGR_L_GetNextFeature()`

    Returns:

      A feature or None if no more features are available.

    Return type:

      Feature

  GetRefCount(Layer self) → int

    For more details: `OGR_L_GetRefCount()`

  GetSpatialFilter(Layer self) → Geometry

    This function returns the current spatial filter for this layer.

    For more details: `OGR_L_GetSpatialFilter()`

    Returns:

      The spatial filter geometry.

    Return type:

      Geometry

  GetSpatialRef(Layer self) → SpatialReference

    Fetch the spatial reference system for this layer.

    For more details: `OGR_L_GetSpatialRef()`

    Returns:

      spatial reference, or None if there isn’t one.

    Return type:

      SpatialReference

  GetStyleTable(Layer self) → StyleTable

    Get style table.

    For more details: `OGR_L_GetStyleTable()`

  GetSupportedSRSList(Layer self, int geom_field=0)
  Identity(Layer self, Layer method_layer, Layer result_layer, char ** options=None, GDALProgressFunc callback=0, void * callback_data=None) → OGRErr

    Identify the features of this layer with the ones from the identity layer.

    For more details: `OGR_L_Identity()`

    Parameters:

      - method_layer (Layer) – the method layer. Should not be None.

      - result_layer (Layer) – the layer where the features resulting from the operation are inserted. Should not be None.

      - options (list[str], optional) – List of options (empty list is allowed). For example [“PROMOTE_TO_MULTI=YES”].

      - callback (Callable, optional) – a GDALProgressFunc() compatible callback function for reporting progress or None.

      - callback_data – Argument to be passed to ‘callback’. May be None.

    Returns:

      An error code if there was an error or the execution was interrupted, `osgeo.ogr.OGRERR_NONE` otherwise.

    Return type:

      int

  Intersection(Layer self, Layer method_layer, Layer result_layer, char ** options=None, GDALProgressFunc callback=0, void * callback_data=None) → OGRErr

    Intersection of two layers.

    For more details: `OGR_L_Intersection()`

    Parameters:

      - method_layer (Layer) – the method layer. Should not be None.

      - result_layer (Layer) – the layer where the features resulting from the operation are inserted. Should not be None.

      - options (list[str], optional) – List of options (empty list is allowed). For example [“PROMOTE_TO_MULTI=YES”].

      - callback (Callable, optional) – a GDALProgressFunc() compatible callback function for reporting progress or None.

      - callback_data – Argument to be passed to ‘callback’. May be None.

    Returns:

      An error code if there was an error or the execution was interrupted, `osgeo.ogr.OGRERR_NONE` otherwise.

    Return type:

      int

  Reference()

    For backwards compatibility only.

  Rename(Layer self, char const * new_name) → OGRErr
  ReorderField(Layer self, int iOldFieldPos, int iNewFieldPos) → OGRErr

    Reorder an existing field on a layer.

    For more details: `OGR_L_ReorderField()`

    Parameters:

      - iOldFieldPos (int) – previous position of the field to move. Must be in the range [0,GetFieldCount()-1].

      - iNewFieldPos (int) – new position of the field to move. Must be in the range [0,GetFieldCount()-1].

    Returns:

      `osgeo.ogr.OGRERR_NONE` on success.

    Return type:

      int

  ReorderFields(Layer self, int nList) → OGRErr

    Reorder all the fields of a layer.

    For more details: `OGR_L_ReorderFields()`

    Parameters:

      nList (list[int]) – A list of GetLayerDefn().GetFieldCount() elements which is a permutation of [0, GetLayerDefn().GetFieldCount()-1].

    Returns:

      `osgeo.ogr.OGRERR_NONE` on success.

    Return type:

      int

  ResetReading(Layer self)

    Reset feature reading to start on the first feature.

    For more details: `OGR_L_ResetReading()`

  RollbackTransaction(Layer self) → OGRErr

    Roll back a datasource to its state before the start of the current transaction.

    For more details: `OGR_L_RollbackTransaction()`

    Returns:

      `osgeo.ogr.OGRERR_NONE` on success.

    Return type:

      int

  SetActiveSRS(Layer self, int geom_field, SpatialReference srs) → OGRErr
  SetAttributeFilter(Layer self, char * filter_string) → OGRErr

    Set a new attribute query.

    For more details: `OGR_L_SetAttributeFilter()`

    Parameters:

      filter_string (str) – query in restricted SQL WHERE format, or None to clear the current query.

    Returns:

      `osgeo.ogr.OGRERR_NONE` if successfully installed, or an error code if the query expression is in error, or some other failure occurs.

    Return type:

      int

  SetFeature(Layer self, Feature feature) → OGRErr

    Rewrite an existing feature.

    For more details: `OGR_L_SetFeature()`

    To set a feature, but create it if it doesn’t exist see `Layer.UpsertFeature()`.

    Parameters:

      feature (Feature) – The feature to write.

    Returns:

      `osgeo.ogr.OGRERR_NONE` if the operation works, otherwise an appropriate error code (e.g `osgeo.ogr.OGRERR_NON_EXISTING_FEATURE` if the feature does not exist).

    Return type:

      int

  SetIgnoredFields(Layer self, char const ** options) → OGRErr

    Set which fields can be omitted when retrieving features from the layer.

    For more details: `OGR_L_SetIgnoredFields()`

    Parameters:

      options (list[str]) – A list of field names. If an empty list is passed, the ignored list is cleared.

    Returns:

      `osgeo.ogr.OGRERR_NONE` if all field names have been resolved (even if the driver does not support this method)

    Return type:

      int

  SetNextByIndex(Layer self, GIntBig new_index) → OGRErr

    Move read cursor to the nIndex’th feature in the current resultset.

    For more details: `OGR_L_SetNextByIndex()`

    Parameters:

      new_index (int) – The index indicating how many steps into the result set to seek.

    Returns:

      `osgeo.ogr.OGRERR_NONE` on success or an error code.

    Return type:

      int

  SetSpatialFilter(Layer self, Geometry filter)
  SetSpatialFilter(Layer self, int iGeomField, Geometry filter) → None

    Set a new spatial filter.

    For more details:

    - `OGR_L_SetSpatialFilter()`

    - `OGR_L_SetSpatialFilterEx()`

    Parameters:

      - iGeomField (int, optional) – index of the geometry field on which the spatial filter operates.

      - filter (Geometry) – The geometry to use as a filtering region. None may be passed indicating that the current spatial filter should be cleared, but no new one instituted.

  SetSpatialFilterRect(Layer self, double minx, double miny, double maxx, double maxy)
  SetSpatialFilterRect(Layer self, int iGeomField, double minx, double miny, double maxx, double maxy) → None

    Set a new rectangular spatial filter.

    For more details:

    - `OGR_L_SetSpatialFilterRect()`

    - `OGR_L_SetSpatialFilterRectEx()`

    Parameters:

      - iGeomField (int, optional) – index of the geometry field on which the spatial filter operates.

      - minx (float) – the minimum X coordinate for the rectangular region.

      - miny (float) – the minimum Y coordinate for the rectangular region.

      - maxx (float) – the maximum X coordinate for the rectangular region.

      - maxy (float) – the maximum Y coordinate for the rectangular region.

  SetStyleTable(Layer self, StyleTable table)

    Set style table.

    For more details: `OGR_L_SetStyleTable()`

  StartTransaction(Layer self) → OGRErr

    For datasources which support transactions, this creates a transaction.

    For more details: `OGR_L_StartTransaction()`

    Returns:

      `osgeo.ogr.OGRERR_NONE` on success.

    Return type:

      int

  SymDifference(Layer self, Layer method_layer, Layer result_layer, char ** options=None, GDALProgressFunc callback=0, void * callback_data=None) → OGRErr

    Symmetrical difference of two layers.

    For more details: `OGR_L_SymDifference()`

    Parameters:

      - method_layer (Layer) – the method layer. Should not be None.

      - result_layer (Layer) – the layer where the features resulting from the operation are inserted. Should not be None.

      - options (list[str], optional) – List of options (empty list is allowed). For example [“PROMOTE_TO_MULTI=YES”].

      - callback (Callable, optional) – a GDALProgressFunc() compatible callback function for reporting progress or None.

      - callback_data – Argument to be passed to ‘callback’. May be None.

    Returns:

      An error code if there was an error or the execution was interrupted, `osgeo.ogr.OGRERR_NONE` otherwise.

    Return type:

      int

  SyncToDisk(Layer self) → OGRErr

    Flush pending changes to disk.

    For more details: `OGR_L_SyncToDisk()`

    Returns:

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

    Return type:

      int

  TestCapability(Layer self, char const * cap) → bool

    Test if this layer supported the named capability.

    For more details: `OGR_L_TestCapability()`

    Parameters:

      cap (str) – The name of the capability to test. These can be found in the osgeo.ogr namespace. For example, `osgeo.ogr.OLCRandomRead`.

    Returns:

      True if the layer has the requested capability, or False otherwise. Will return False for any unrecognized capabilities.

    Return type:

      int

  Union(Layer self, Layer method_layer, Layer result_layer, char ** options=None, GDALProgressFunc callback=0, void * callback_data=None) → OGRErr

    Union of two layers.

    For more details: `OGR_L_Union()`

    The first geometry field is always used.

    Parameters:

      - method_layer (Layer) – the method layer. Should not be None.

      - result_layer (Layer) – the layer where the features resulting from the operation are inserted. Should not be None.

      - options (list[str], optional) – List of options (empty list is allowed). For example [“PROMOTE_TO_MULTI=YES”].

      - callback (Callable, optional) – a GDALProgressFunc() compatible callback function for reporting progress or None.

      - callback_data – Argument to be passed to ‘callback’. May be None.

    Returns:

      An error code if there was an error or the execution was interrupted, `osgeo.ogr.OGRERR_NONE` otherwise.

    Return type:

      int

  Update(Layer self, Layer method_layer, Layer result_layer, char ** options=None, GDALProgressFunc callback=0, void * callback_data=None) → OGRErr

    Update this layer with features from the update layer.

    For more details: `OGR_L_Update()`

    Parameters:

      - method_layer (Layer) – the method layer. Should not be None.

      - result_layer (Layer) – the layer where the features resulting from the operation are inserted. Should not be None.

      - options (list[str], optional) – List of options (empty list is allowed). For example [“PROMOTE_TO_MULTI=YES”].

      - callback (Callable, optional) – a GDALProgressFunc() compatible callback function for reporting progress or None.

      - callback_data – Argument to be passed to ‘callback’. May be None.

    Returns:

      An error code if there was an error or the execution was interrupted, `osgeo.ogr.OGRERR_NONE` otherwise.

    Return type:

      int

  UpdateFeature(Layer self, Feature feature, int nUpdatedFieldsCount, int nUpdatedGeomFieldsCount, bool bUpdateStyleString) → OGRErr
  UpsertFeature(Layer self, Feature feature) → OGRErr

    Rewrite an existing feature or create a new feature within a layer.

    For more details: `OGR_L_UpsertFeature()`

    Parameters:

      feature (Feature) – The feature to write to disk.

    Returns:

      `osgeo.ogr.OGRERR_NONE` on success.

    Return type:

      int

  property schema
  property thisown

    The membership flag

class osgeo.ogr.MajorObject(*args, **kwargs)

  Bases: `object`

  Proxy of C++ GDALMajorObjectShadow class.

  GetDescription(MajorObject self) → char const *
  GetMetadata(domain='')
  GetMetadataDomainList(MajorObject self) → char **
  GetMetadataItem(MajorObject self, char const * pszName, char const * pszDomain="") → char const *
  GetMetadata_Dict(MajorObject self, char const * pszDomain="") → char **
  GetMetadata_List(MajorObject self, char const * pszDomain="") → char **
  SetDescription(MajorObject self, char const * pszNewDesc)
  SetMetadata(MajorObject self, char ** papszMetadata, char const * pszDomain="") → CPLErr
  SetMetadata(MajorObject self, char * pszMetadataString, char const * pszDomain="") → CPLErr
  SetMetadataItem(MajorObject self, char const * pszName, char const * pszValue, char const * pszDomain="") → CPLErr
  property thisown

    The membership flag

osgeo.ogr.Open(char const * utf8_path, int update=0) → DataSource

osgeo.ogr.OpenShared(char const * utf8_path, int update=0) → DataSource

class osgeo.ogr.PreparedGeometry(*args, **kwargs)

  Bases: `object`

  Proxy of C++ OGRPreparedGeometryShadow class.

  Contains(PreparedGeometry self, Geometry otherGeom) → bool
  Intersects(PreparedGeometry self, Geometry otherGeom) → bool
  property thisown

    The membership flag

osgeo.ogr.RegisterAll()

osgeo.ogr.SetGenerate_DB2_V72_BYTE_ORDER(int bGenerate_DB2_V72_BYTE_ORDER) → OGRErr

osgeo.ogr.SetNonLinearGeometriesEnabledFlag(int bFlag)

class osgeo.ogr.StyleTable(*args)

  Bases: `object`

  Proxy of C++ OGRStyleTableShadow class.

  AddStyle(StyleTable self, char const * pszName, char const * pszStyleString) → int
  Find(StyleTable self, char const * pszName) → char const *
  GetLastStyleName(StyleTable self) → char const *
  GetNextStyle(StyleTable self) → char const *
  LoadStyleTable(StyleTable self, char const * utf8_path) → int
  ResetStyleStringReading(StyleTable self)
  SaveStyleTable(StyleTable self, char const * utf8_path) → int
  property thisown

    The membership flag

osgeo.ogr.TermProgress_nocb(double dfProgress, char const * pszMessage=None, void * pData=None) → int

osgeo.ogr.UseExceptions()

  Enable exceptions in all GDAL related modules (osgeo.gdal, osgeo.ogr, osgeo.osr, osgeo.gnm). Note: prior to GDAL 3.7, this only affected the calling module