# 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)

  Bases: `object`

  Proxy of C++ ArrowArray class.

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

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

  Bases: `object`

  Proxy of C++ ArrowArrayStream class.

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

class osgeo.ogr.ArrowSchema(*args)

  Bases: `object`

  Proxy of C++ ArrowSchema class.

  GetChild(ArrowSchema self, int iChild) → ArrowSchema
  GetChildrenCount(ArrowSchema self) → GIntBig
  GetName(ArrowSchema self) → char const *

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

osgeo.ogr.CreateGeomCoordinatePrecision() → GeomCoordinatePrecision

osgeo.ogr.CreateRangeFieldDomainDateTime(char const * name, char const * description, char const * min, bool minIsInclusive, char const * max, double maxIsInclusive) → FieldDomain

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

osgeo.ogr.GT_GetSingle(OGRwkbGeometryType eType) → OGRwkbGeometryType

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

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

  Bases: `object`

  Proxy of C++ OGRGeomCoordinatePrecisionShadow class.

  GetFormatSpecificOptions(GeomCoordinatePrecision self, char const * formatName) → char **
  GetFormats(GeomCoordinatePrecision self) → char **
  GetMResolution(GeomCoordinatePrecision self) → double
  GetXYResolution(GeomCoordinatePrecision self) → double
  GetZResolution(GeomCoordinatePrecision self) → double
  Set(GeomCoordinatePrecision self, double xyResolution, double zResolution, double mResolution)
  SetFormatSpecificOptions(GeomCoordinatePrecision self, char const * formatName, char ** formatSpecificOptions)
  SetFromMeter(GeomCoordinatePrecision self, SpatialReference srs, double xyMeterResolution, double zMeterResolution, double mResolution)

class osgeo.ogr.GeomTransformer(*args)

  Bases: `object`

  Proxy of C++ OGRGeomTransformerShadow class.

  Transform(GeomTransformer self, Geometry src_geom) → Geometry

osgeo.ogr.GetDriver(int driver_number) → OGRDriverShadow *

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

  Get a vector driver. Like `gdal.GetDriverByName()`, but only returns drivers that handle vector data.

  Parameters:

    name (str) -- name of the driver to fetch

  Return type:

    gdal.Driver

  Examples

      >>> ogr.GetDriverByName('ESRI Shapefile').GetDescription()
      'ESRI Shapefile'

      >>> ogr.GetDriverByName('GTiff')
      >>>

osgeo.ogr.GetDriverCount() → int

osgeo.ogr.GetGEOSVersionMajor() → int

osgeo.ogr.GetGEOSVersionMicro() → int

osgeo.ogr.GetGEOSVersionMinor() → int

osgeo.ogr.GetNonLinearGeometriesEnabledFlag() → int

osgeo.ogr.GetOpenDS(int ds_number) → OGRDataSourceShadow *

osgeo.ogr.GetOpenDSCount() → int

osgeo.ogr.GetUseExceptions() → int

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

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

  Open a vector file as a `gdal.Dataset`. Equivalent to calling `gdal.OpenEx()` with the `gdal.OF_VECTOR` flag.

  Parameters:

    utf8_path (str) -- name of the file to open

  Return type:

    gdal.Dataset, or `None` on failure

  Examples

      >>> from osgeo import ogr
      >>> ogr.GetDriverByName('ESRI Shapefile').GetDescription()
      'ESRI Shapefile'
      >>> ogr.GetDriverByName('GTiff')
      >>>

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

  Open a vector file as a `gdal.Dataset`. If the file has already been opened in the current thread, return a reference to the already-opened `gdal.Dataset`. Equivalent to calling `gdal.OpenEx()` with the `gdal.OF_VECTOR` and `gdal.OF_SHARED` flags.

  Parameters:

    utf8_path (str) -- name of the file to open

  Return type:

    gdal.Dataset, or `None` on failure

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

osgeo.ogr.RegisterAll()

osgeo.ogr.SetGenerate_DB2_V72_BYTE_ORDER(int bGenerate_DB2_V72_BYTE_ORDER) → OGRErr

osgeo.ogr.SetNonLinearGeometriesEnabledFlag(int bFlag)

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