osgeo.ogr module
- osgeo.ogr.ApproximateArcAngles(dfCenterX, dfCenterY, dfZ, dfPrimaryRadius, dfSecondaryAxis, dfRotation, dfStartAngle, dfEndAngle, dfMaxAngleStepSizeDegrees) Geometry
- class osgeo.ogr.ArrowArray(*args)
Bases:
objectProxy of C++ ArrowArray class.
- GetChildrenCount(self) GIntBig
- GetLength(self) GIntBig
- class osgeo.ogr.ArrowArrayStream(*args, **kwargs)
Bases:
objectProxy of C++ ArrowArrayStream class.
- GetNextRecordBatch(self, options=None) ArrowArray
- GetSchema(self) ArrowSchema
- class osgeo.ogr.ArrowSchema(*args)
Bases:
objectProxy of C++ ArrowSchema class.
- GetChild(self, iChild) ArrowSchema
- GetChildrenCount(self) GIntBig
- GetName(self) char const *
- osgeo.ogr.BuildPolygonFromEdges(hLineCollection, bBestEffort=0, bAutoClose=0, dfTolerance=0) Geometry
- osgeo.ogr.CreateGeomCoordinatePrecision() GeomCoordinatePrecision
- osgeo.ogr.CreateGeometryFromEnvelope(xmin, ymin, xmax, ymax, reference=None) Geometry
Creates a rectangular, axis-aligned Polygon geometry.
Added in version 3.12.
- Parameters:
xmin (float) -- minimum x coordinate value
ymin (float) -- minimum y coordinate value
xmax (float) -- maximum x coordinate value
ymax (float) -- maximum y coordinate value
srs (SpatialReference, optional) -- optional spatial reference to assign to the geometry
- Return type:
Examples
>>> g = ogr.CreateGeometryFromEnvelope(424788, 25211, 581555, 279799) >>> g.ExportToWkt() 'POLYGON ((424788 25211,424788 279799,581555 279799,581555 25211,424788 25211))'
- osgeo.ogr.CreateRangeFieldDomainDateTime(name, description, min, minIsInclusive, max, 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:
objectContext 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(eType) OGRwkbGeometryType
- osgeo.ogr.GeneralCmdLineProcessor(papszArgv, nOptions=0) char **
- class osgeo.ogr.GeomCoordinatePrecision(*args, **kwargs)
Bases:
objectProxy of C++ OGRGeomCoordinatePrecisionShadow class.
- GetFormatSpecificOptions(self, formatName) char **
- GetFormats(self) char **
- GetMResolution(self) double
- GetXYResolution(self) double
- GetZResolution(self) double
- Set(self, xyResolution, zResolution, mResolution)
- SetFormatSpecificOptions(self, formatName, formatSpecificOptions)
- SetFromMeter(self, srs, xyMeterResolution, zMeterResolution, mResolution)
- class osgeo.ogr.GeomTransformer(*args)
Bases:
objectProxy of C++ OGRGeomTransformerShadow class.
- osgeo.ogr.GetDriver(driver_number) OGRDriverShadow *
- osgeo.ogr.GetDriverByName(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:
Examples
>>> ogr.GetDriverByName('ESRI Shapefile').GetDescription() 'ESRI Shapefile'
>>> ogr.GetDriverByName('GTiff') >>>
- osgeo.ogr.GetDriverCount() int
- osgeo.ogr.GetFieldSubtypeByName(subTypeName) OGRFieldSubType
- osgeo.ogr.GetFieldTypeByName(typeName) OGRFieldType
- osgeo.ogr.GetGEOSVersionMajor() int
- osgeo.ogr.GetGEOSVersionMicro() int
- osgeo.ogr.GetGEOSVersionMinor() int
- osgeo.ogr.GetNonLinearGeometriesEnabledFlag() int
- osgeo.ogr.GetOpenDS(ds_number) OGRDataSourceShadow *
- osgeo.ogr.GetOpenDSCount() int
- osgeo.ogr.GetUseExceptions() int
- class osgeo.ogr.MajorObject(*args, **kwargs)
Bases:
objectProxy of C++ GDALMajorObjectShadow class.
- GetDescription(self) char const *
- GetMetadata(domain='')
- GetMetadataDomainList(self) char **
- GetMetadataItem(self, pszName, pszDomain='') char const *
- GetMetadata_Dict(self, pszDomain='') char **
- GetMetadata_List(self, pszDomain='') char **
- SetDescription(self, pszNewDesc)
- SetMetadata(self, papszMetadata, pszDomain='') CPLErr
- SetMetadata(self, pszMetadataString, pszDomain='') CPLErr
- SetMetadataItem(self, pszName, pszValue, pszDomain='') CPLErr
- osgeo.ogr.Open(utf8_string, update=0) OGRDataSourceShadow *
Open a vector file as a
gdal.Dataset. Equivalent to callinggdal.OpenEx()with thegdal.OF_VECTORflag.- Parameters:
path (str) -- name of the file to open
- Returns:
A dataset or
Noneon failure.- Return type:
Dataset or None
Examples
>>> from osgeo import ogr >>> ogr.GetDriverByName('ESRI Shapefile').GetDescription() 'ESRI Shapefile' >>> ogr.GetDriverByName('GTiff') >>>
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-openedgdal.Dataset. Equivalent to callinggdal.OpenEx()with thegdal.OF_VECTORandgdal.OF_SHAREDflags.- Parameters:
path (str) -- name of the file to open
- Returns:
A dataset or
Noneon failure.- Return type:
Dataset or None
- class osgeo.ogr.PreparedGeometry(*args, **kwargs)
Bases:
objectProxy of C++ OGRPreparedGeometryShadow class.
- Contains(self, otherGeom) bool
- Intersects(self, otherGeom) bool
- osgeo.ogr.RegisterAll()
- osgeo.ogr.SetGenerate_DB2_V72_BYTE_ORDER(bGenerate_DB2_V72_BYTE_ORDER) OGRErr
- osgeo.ogr.SetNonLinearGeometriesEnabledFlag(bFlag)
- osgeo.ogr.TermProgress_nocb(dfProgress, pszMessage=None, 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