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

Source Code for Module osgeo.ogr

   1  # This file was automatically generated by SWIG (http://www.swig.org). 
   2  # Version 3.0.12 
   3  # 
   4  # Do not make changes to this file unless you know what you are doing--modify 
   5  # the SWIG interface file instead. 
   6   
   7  from sys import version_info as _swig_python_version_info 
   8  if _swig_python_version_info >= (2, 7, 0): 
9 - def swig_import_helper():
10 import importlib 11 pkg = __name__.rpartition('.')[0] 12 mname = '.'.join((pkg, '_ogr')).lstrip('.') 13 try: 14 return importlib.import_module(mname) 15 except ImportError: 16 return importlib.import_module('_ogr')
17 _ogr = swig_import_helper() 18 del swig_import_helper 19 elif _swig_python_version_info >= (2, 6, 0):
20 - def swig_import_helper():
21 from os.path import dirname 22 import imp 23 fp = None 24 try: 25 fp, pathname, description = imp.find_module('_ogr', [dirname(__file__)]) 26 except ImportError: 27 import _ogr 28 return _ogr 29 try: 30 _mod = imp.load_module('_ogr', fp, pathname, description) 31 finally: 32 if fp is not None: 33 fp.close() 34 return _mod
35 _ogr = swig_import_helper() 36 del swig_import_helper 37 else: 38 import _ogr 39 del _swig_python_version_info 40 41 try: 42 _swig_property = property 43 except NameError: 44 pass # Python < 2.2 doesn't have 'property'. 45 46 try: 47 import builtins as __builtin__ 48 except ImportError: 49 import __builtin__ 50
51 -def _swig_setattr_nondynamic(self, class_type, name, value, static=1):
52 if (name == "thisown"): 53 return self.this.own(value) 54 if (name == "this"): 55 if type(value).__name__ == 'SwigPyObject': 56 self.__dict__[name] = value 57 return 58 method = class_type.__swig_setmethods__.get(name, None) 59 if method: 60 return method(self, value) 61 if (not static): 62 if _newclass: 63 object.__setattr__(self, name, value) 64 else: 65 self.__dict__[name] = value 66 else: 67 raise AttributeError("You cannot add attributes to %s" % self)
68 69
70 -def _swig_setattr(self, class_type, name, value):
71 return _swig_setattr_nondynamic(self, class_type, name, value, 0)
72 73
74 -def _swig_getattr(self, class_type, name):
75 if (name == "thisown"): 76 return self.this.own() 77 method = class_type.__swig_getmethods__.get(name, None) 78 if method: 79 return method(self) 80 raise AttributeError("'%s' object has no attribute '%s'" % (class_type.__name__, name))
81 82
83 -def _swig_repr(self):
84 try: 85 strthis = "proxy of " + self.this.__repr__() 86 except __builtin__.Exception: 87 strthis = "" 88 return "<%s.%s; %s >" % (self.__class__.__module__, self.__class__.__name__, strthis,)
89 90 try: 91 _object = object 92 _newclass = 1 93 except __builtin__.Exception:
94 - class _object:
95 pass
96 _newclass = 0 97 98 wkb25DBit = _ogr.wkb25DBit 99 wkb25Bit = _ogr.wkb25Bit 100 wkbUnknown = _ogr.wkbUnknown 101 wkbPoint = _ogr.wkbPoint 102 wkbLineString = _ogr.wkbLineString 103 wkbPolygon = _ogr.wkbPolygon 104 wkbMultiPoint = _ogr.wkbMultiPoint 105 wkbMultiLineString = _ogr.wkbMultiLineString 106 wkbMultiPolygon = _ogr.wkbMultiPolygon 107 wkbGeometryCollection = _ogr.wkbGeometryCollection 108 wkbCircularString = _ogr.wkbCircularString 109 wkbCompoundCurve = _ogr.wkbCompoundCurve 110 wkbCurvePolygon = _ogr.wkbCurvePolygon 111 wkbMultiCurve = _ogr.wkbMultiCurve 112 wkbMultiSurface = _ogr.wkbMultiSurface 113 wkbCurve = _ogr.wkbCurve 114 wkbSurface = _ogr.wkbSurface 115 wkbPolyhedralSurface = _ogr.wkbPolyhedralSurface 116 wkbTIN = _ogr.wkbTIN 117 wkbTriangle = _ogr.wkbTriangle 118 wkbNone = _ogr.wkbNone 119 wkbLinearRing = _ogr.wkbLinearRing 120 wkbCircularStringZ = _ogr.wkbCircularStringZ 121 wkbCompoundCurveZ = _ogr.wkbCompoundCurveZ 122 wkbCurvePolygonZ = _ogr.wkbCurvePolygonZ 123 wkbMultiCurveZ = _ogr.wkbMultiCurveZ 124 wkbMultiSurfaceZ = _ogr.wkbMultiSurfaceZ 125 wkbCurveZ = _ogr.wkbCurveZ 126 wkbSurfaceZ = _ogr.wkbSurfaceZ 127 wkbPolyhedralSurfaceZ = _ogr.wkbPolyhedralSurfaceZ 128 wkbTINZ = _ogr.wkbTINZ 129 wkbTriangleZ = _ogr.wkbTriangleZ 130 wkbPointM = _ogr.wkbPointM 131 wkbLineStringM = _ogr.wkbLineStringM 132 wkbPolygonM = _ogr.wkbPolygonM 133 wkbMultiPointM = _ogr.wkbMultiPointM 134 wkbMultiLineStringM = _ogr.wkbMultiLineStringM 135 wkbMultiPolygonM = _ogr.wkbMultiPolygonM 136 wkbGeometryCollectionM = _ogr.wkbGeometryCollectionM 137 wkbCircularStringM = _ogr.wkbCircularStringM 138 wkbCompoundCurveM = _ogr.wkbCompoundCurveM 139 wkbCurvePolygonM = _ogr.wkbCurvePolygonM 140 wkbMultiCurveM = _ogr.wkbMultiCurveM 141 wkbMultiSurfaceM = _ogr.wkbMultiSurfaceM 142 wkbCurveM = _ogr.wkbCurveM 143 wkbSurfaceM = _ogr.wkbSurfaceM 144 wkbPolyhedralSurfaceM = _ogr.wkbPolyhedralSurfaceM 145 wkbTINM = _ogr.wkbTINM 146 wkbTriangleM = _ogr.wkbTriangleM 147 wkbPointZM = _ogr.wkbPointZM 148 wkbLineStringZM = _ogr.wkbLineStringZM 149 wkbPolygonZM = _ogr.wkbPolygonZM 150 wkbMultiPointZM = _ogr.wkbMultiPointZM 151 wkbMultiLineStringZM = _ogr.wkbMultiLineStringZM 152 wkbMultiPolygonZM = _ogr.wkbMultiPolygonZM 153 wkbGeometryCollectionZM = _ogr.wkbGeometryCollectionZM 154 wkbCircularStringZM = _ogr.wkbCircularStringZM 155 wkbCompoundCurveZM = _ogr.wkbCompoundCurveZM 156 wkbCurvePolygonZM = _ogr.wkbCurvePolygonZM 157 wkbMultiCurveZM = _ogr.wkbMultiCurveZM 158 wkbMultiSurfaceZM = _ogr.wkbMultiSurfaceZM 159 wkbCurveZM = _ogr.wkbCurveZM 160 wkbSurfaceZM = _ogr.wkbSurfaceZM 161 wkbPolyhedralSurfaceZM = _ogr.wkbPolyhedralSurfaceZM 162 wkbTINZM = _ogr.wkbTINZM 163 wkbTriangleZM = _ogr.wkbTriangleZM 164 wkbPoint25D = _ogr.wkbPoint25D 165 wkbLineString25D = _ogr.wkbLineString25D 166 wkbPolygon25D = _ogr.wkbPolygon25D 167 wkbMultiPoint25D = _ogr.wkbMultiPoint25D 168 wkbMultiLineString25D = _ogr.wkbMultiLineString25D 169 wkbMultiPolygon25D = _ogr.wkbMultiPolygon25D 170 wkbGeometryCollection25D = _ogr.wkbGeometryCollection25D 171 OFTInteger = _ogr.OFTInteger 172 OFTIntegerList = _ogr.OFTIntegerList 173 OFTReal = _ogr.OFTReal 174 OFTRealList = _ogr.OFTRealList 175 OFTString = _ogr.OFTString 176 OFTStringList = _ogr.OFTStringList 177 OFTWideString = _ogr.OFTWideString 178 OFTWideStringList = _ogr.OFTWideStringList 179 OFTBinary = _ogr.OFTBinary 180 OFTDate = _ogr.OFTDate 181 OFTTime = _ogr.OFTTime 182 OFTDateTime = _ogr.OFTDateTime 183 OFTInteger64 = _ogr.OFTInteger64 184 OFTInteger64List = _ogr.OFTInteger64List 185 OFSTNone = _ogr.OFSTNone 186 OFSTBoolean = _ogr.OFSTBoolean 187 OFSTInt16 = _ogr.OFSTInt16 188 OFSTFloat32 = _ogr.OFSTFloat32 189 OFSTJSON = _ogr.OFSTJSON 190 OJUndefined = _ogr.OJUndefined 191 OJLeft = _ogr.OJLeft 192 OJRight = _ogr.OJRight 193 wkbXDR = _ogr.wkbXDR 194 wkbNDR = _ogr.wkbNDR 195 NullFID = _ogr.NullFID 196 ALTER_NAME_FLAG = _ogr.ALTER_NAME_FLAG 197 ALTER_TYPE_FLAG = _ogr.ALTER_TYPE_FLAG 198 ALTER_WIDTH_PRECISION_FLAG = _ogr.ALTER_WIDTH_PRECISION_FLAG 199 ALTER_NULLABLE_FLAG = _ogr.ALTER_NULLABLE_FLAG 200 ALTER_DEFAULT_FLAG = _ogr.ALTER_DEFAULT_FLAG 201 ALTER_ALL_FLAG = _ogr.ALTER_ALL_FLAG 202 F_VAL_NULL = _ogr.F_VAL_NULL 203 F_VAL_GEOM_TYPE = _ogr.F_VAL_GEOM_TYPE 204 F_VAL_WIDTH = _ogr.F_VAL_WIDTH 205 F_VAL_ALLOW_NULL_WHEN_DEFAULT = _ogr.F_VAL_ALLOW_NULL_WHEN_DEFAULT 206 F_VAL_ALL = _ogr.F_VAL_ALL 207 OLCRandomRead = _ogr.OLCRandomRead 208 OLCSequentialWrite = _ogr.OLCSequentialWrite 209 OLCRandomWrite = _ogr.OLCRandomWrite 210 OLCFastSpatialFilter = _ogr.OLCFastSpatialFilter 211 OLCFastFeatureCount = _ogr.OLCFastFeatureCount 212 OLCFastGetExtent = _ogr.OLCFastGetExtent 213 OLCCreateField = _ogr.OLCCreateField 214 OLCDeleteField = _ogr.OLCDeleteField 215 OLCReorderFields = _ogr.OLCReorderFields 216 OLCAlterFieldDefn = _ogr.OLCAlterFieldDefn 217 OLCTransactions = _ogr.OLCTransactions 218 OLCDeleteFeature = _ogr.OLCDeleteFeature 219 OLCFastSetNextByIndex = _ogr.OLCFastSetNextByIndex 220 OLCStringsAsUTF8 = _ogr.OLCStringsAsUTF8 221 OLCIgnoreFields = _ogr.OLCIgnoreFields 222 OLCCreateGeomField = _ogr.OLCCreateGeomField 223 OLCCurveGeometries = _ogr.OLCCurveGeometries 224 OLCMeasuredGeometries = _ogr.OLCMeasuredGeometries 225 ODsCCreateLayer = _ogr.ODsCCreateLayer 226 ODsCDeleteLayer = _ogr.ODsCDeleteLayer 227 ODsCCreateGeomFieldAfterCreateLayer = _ogr.ODsCCreateGeomFieldAfterCreateLayer 228 ODsCCurveGeometries = _ogr.ODsCCurveGeometries 229 ODsCTransactions = _ogr.ODsCTransactions 230 ODsCEmulatedTransactions = _ogr.ODsCEmulatedTransactions 231 ODsCMeasuredGeometries = _ogr.ODsCMeasuredGeometries 232 ODsCRandomLayerRead = _ogr.ODsCRandomLayerRead 233 ODsCRandomLayerWrite = _ogr.ODsCRandomLayerWrite 234 ODrCCreateDataSource = _ogr.ODrCCreateDataSource 235 ODrCDeleteDataSource = _ogr.ODrCDeleteDataSource 236 OLMD_FID64 = _ogr.OLMD_FID64 237 OGRERR_NONE = _ogr.OGRERR_NONE 238 OGRERR_NOT_ENOUGH_DATA = _ogr.OGRERR_NOT_ENOUGH_DATA 239 OGRERR_NOT_ENOUGH_MEMORY = _ogr.OGRERR_NOT_ENOUGH_MEMORY 240 OGRERR_UNSUPPORTED_GEOMETRY_TYPE = _ogr.OGRERR_UNSUPPORTED_GEOMETRY_TYPE 241 OGRERR_UNSUPPORTED_OPERATION = _ogr.OGRERR_UNSUPPORTED_OPERATION 242 OGRERR_CORRUPT_DATA = _ogr.OGRERR_CORRUPT_DATA 243 OGRERR_FAILURE = _ogr.OGRERR_FAILURE 244 OGRERR_UNSUPPORTED_SRS = _ogr.OGRERR_UNSUPPORTED_SRS 245 OGRERR_INVALID_HANDLE = _ogr.OGRERR_INVALID_HANDLE 246 OGRERR_NON_EXISTING_FEATURE = _ogr.OGRERR_NON_EXISTING_FEATURE 247
248 -def GetUseExceptions(*args):
249 """GetUseExceptions() -> int""" 250 return _ogr.GetUseExceptions(*args)
251
252 -def UseExceptions(*args):
253 """UseExceptions()""" 254 return _ogr.UseExceptions(*args)
255
256 -def DontUseExceptions(*args):
257 """DontUseExceptions()""" 258 return _ogr.DontUseExceptions(*args)
259 from . import osr
260 -class MajorObject(_object):
261 """Proxy of C++ GDALMajorObjectShadow class.""" 262 263 __swig_setmethods__ = {} 264 __setattr__ = lambda self, name, value: _swig_setattr(self, MajorObject, name, value) 265 __swig_getmethods__ = {} 266 __getattr__ = lambda self, name: _swig_getattr(self, MajorObject, name) 267
268 - def __init__(self, *args, **kwargs):
269 raise AttributeError("No constructor defined")
270 __repr__ = _swig_repr 271
272 - def GetDescription(self, *args):
273 """GetDescription(MajorObject self) -> char const *""" 274 return _ogr.MajorObject_GetDescription(self, *args)
275 276
277 - def SetDescription(self, *args):
278 """SetDescription(MajorObject self, char const * pszNewDesc)""" 279 return _ogr.MajorObject_SetDescription(self, *args)
280 281
282 - def GetMetadataDomainList(self, *args):
283 """GetMetadataDomainList(MajorObject self) -> char **""" 284 return _ogr.MajorObject_GetMetadataDomainList(self, *args)
285 286
287 - def GetMetadata_Dict(self, *args):
288 """GetMetadata_Dict(MajorObject self, char const * pszDomain) -> char **""" 289 return _ogr.MajorObject_GetMetadata_Dict(self, *args)
290 291
292 - def GetMetadata_List(self, *args):
293 """GetMetadata_List(MajorObject self, char const * pszDomain) -> char **""" 294 return _ogr.MajorObject_GetMetadata_List(self, *args)
295 296
297 - def SetMetadata(self, *args):
298 """ 299 SetMetadata(MajorObject self, char ** papszMetadata, char const * pszDomain) -> CPLErr 300 SetMetadata(MajorObject self, char * pszMetadataString, char const * pszDomain) -> CPLErr 301 """ 302 return _ogr.MajorObject_SetMetadata(self, *args)
303 304
305 - def GetMetadataItem(self, *args):
306 """GetMetadataItem(MajorObject self, char const * pszName, char const * pszDomain) -> char const *""" 307 return _ogr.MajorObject_GetMetadataItem(self, *args)
308 309
310 - def SetMetadataItem(self, *args):
311 """SetMetadataItem(MajorObject self, char const * pszName, char const * pszValue, char const * pszDomain) -> CPLErr""" 312 return _ogr.MajorObject_SetMetadataItem(self, *args)
313 314
315 - def GetMetadata(self, domain=''):
316 if domain[:4] == 'xml:': 317 return self.GetMetadata_List(domain) 318 return self.GetMetadata_Dict(domain)
319 320 MajorObject_swigregister = _ogr.MajorObject_swigregister 321 MajorObject_swigregister(MajorObject) 322
323 -class StyleTable(_object):
324 """Proxy of C++ OGRStyleTableShadow class.""" 325 326 __swig_setmethods__ = {} 327 __setattr__ = lambda self, name, value: _swig_setattr(self, StyleTable, name, value) 328 __swig_getmethods__ = {} 329 __getattr__ = lambda self, name: _swig_getattr(self, StyleTable, name) 330 __repr__ = _swig_repr 331
332 - def __init__(self, *args):
333 """__init__(OGRStyleTableShadow self) -> StyleTable""" 334 this = _ogr.new_StyleTable(*args) 335 try: 336 self.this.append(this) 337 except __builtin__.Exception: 338 self.this = this
339 __swig_destroy__ = _ogr.delete_StyleTable 340 __del__ = lambda self: None 341
342 - def AddStyle(self, *args):
343 """AddStyle(StyleTable self, char const * pszName, char const * pszStyleString) -> int""" 344 return _ogr.StyleTable_AddStyle(self, *args)
345 346
347 - def LoadStyleTable(self, *args):
348 """LoadStyleTable(StyleTable self, char const * utf8_path) -> int""" 349 return _ogr.StyleTable_LoadStyleTable(self, *args)
350 351
352 - def SaveStyleTable(self, *args):
353 """SaveStyleTable(StyleTable self, char const * utf8_path) -> int""" 354 return _ogr.StyleTable_SaveStyleTable(self, *args)
355 356
357 - def Find(self, *args):
358 """Find(StyleTable self, char const * pszName) -> char const *""" 359 return _ogr.StyleTable_Find(self, *args)
360 361
362 - def ResetStyleStringReading(self, *args):
363 """ResetStyleStringReading(StyleTable self)""" 364 return _ogr.StyleTable_ResetStyleStringReading(self, *args)
365 366
367 - def GetNextStyle(self, *args):
368 """GetNextStyle(StyleTable self) -> char const *""" 369 return _ogr.StyleTable_GetNextStyle(self, *args)
370 371
372 - def GetLastStyleName(self, *args):
373 """GetLastStyleName(StyleTable self) -> char const *""" 374 return _ogr.StyleTable_GetLastStyleName(self, *args)
375 376 StyleTable_swigregister = _ogr.StyleTable_swigregister 377 StyleTable_swigregister(StyleTable) 378
379 -class Driver(MajorObject):
380 """Proxy of C++ OGRDriverShadow class.""" 381 382 __swig_setmethods__ = {} 383 for _s in [MajorObject]: 384 __swig_setmethods__.update(getattr(_s, '__swig_setmethods__', {})) 385 __setattr__ = lambda self, name, value: _swig_setattr(self, Driver, name, value) 386 __swig_getmethods__ = {} 387 for _s in [MajorObject]: 388 __swig_getmethods__.update(getattr(_s, '__swig_getmethods__', {})) 389 __getattr__ = lambda self, name: _swig_getattr(self, Driver, name) 390
391 - def __init__(self, *args, **kwargs):
392 raise AttributeError("No constructor defined")
393 __repr__ = _swig_repr 394 __swig_getmethods__["name"] = _ogr.Driver_name_get 395 if _newclass: 396 name = _swig_property(_ogr.Driver_name_get) 397
398 - def CreateDataSource(self, *args, **kwargs):
399 """CreateDataSource(Driver self, char const * utf8_path, char ** options=None) -> DataSource""" 400 return _ogr.Driver_CreateDataSource(self, *args, **kwargs)
401 402
403 - def CopyDataSource(self, *args, **kwargs):
404 """CopyDataSource(Driver self, DataSource copy_ds, char const * utf8_path, char ** options=None) -> DataSource""" 405 return _ogr.Driver_CopyDataSource(self, *args, **kwargs)
406 407
408 - def Open(self, *args, **kwargs):
409 """Open(Driver self, char const * utf8_path, int update=0) -> DataSource""" 410 return _ogr.Driver_Open(self, *args, **kwargs)
411 412
413 - def DeleteDataSource(self, *args):
414 """DeleteDataSource(Driver self, char const * utf8_path) -> int""" 415 return _ogr.Driver_DeleteDataSource(self, *args)
416 417
418 - def TestCapability(self, *args):
419 """TestCapability(Driver self, char const * cap) -> bool""" 420 return _ogr.Driver_TestCapability(self, *args)
421 422
423 - def GetName(self, *args):
424 """GetName(Driver self) -> char const *""" 425 return _ogr.Driver_GetName(self, *args)
426 427
428 - def Register(self, *args):
429 """Register(Driver self)""" 430 return _ogr.Driver_Register(self, *args)
431 432
433 - def Deregister(self, *args):
434 """Deregister(Driver self)""" 435 return _ogr.Driver_Deregister(self, *args)
436 437 Driver_swigregister = _ogr.Driver_swigregister 438 Driver_swigregister(Driver) 439
440 -class DataSource(MajorObject):
441 """Proxy of C++ OGRDataSourceShadow class.""" 442 443 __swig_setmethods__ = {} 444 for _s in [MajorObject]: 445 __swig_setmethods__.update(getattr(_s, '__swig_setmethods__', {})) 446 __setattr__ = lambda self, name, value: _swig_setattr(self, DataSource, name, value) 447 __swig_getmethods__ = {} 448 for _s in [MajorObject]: 449 __swig_getmethods__.update(getattr(_s, '__swig_getmethods__', {})) 450 __getattr__ = lambda self, name: _swig_getattr(self, DataSource, name) 451
452 - def __init__(self, *args, **kwargs):
453 raise AttributeError("No constructor defined")
454 __repr__ = _swig_repr 455 __swig_getmethods__["name"] = _ogr.DataSource_name_get 456 if _newclass: 457 name = _swig_property(_ogr.DataSource_name_get) 458 __swig_destroy__ = _ogr.delete_DataSource 459 __del__ = lambda self: None 460
461 - def GetRefCount(self, *args):
462 """ 463 GetRefCount(DataSource self) -> int 464 465 int 466 OGR_DS_GetRefCount(OGRDataSourceH hDataSource) 467 """ 468 return _ogr.DataSource_GetRefCount(self, *args)
469 470
471 - def GetSummaryRefCount(self, *args):
472 """ 473 GetSummaryRefCount(DataSource self) -> int 474 475 int 476 OGR_DS_GetSummaryRefCount(OGRDataSourceH hDataSource) 477 """ 478 return _ogr.DataSource_GetSummaryRefCount(self, *args)
479 480
481 - def GetLayerCount(self, *args):
482 """ 483 GetLayerCount(DataSource self) -> int 484 485 int 486 OGR_DS_GetLayerCount(OGRDataSourceH hDS) 487 488 Get the number of layers in this data source. 489 490 Deprecated Use GDALDatasetGetLayerCount() in GDAL 2.0 491 492 Parameters: 493 ----------- 494 495 hDS: handle to the data source from which to get the number of 496 layers. 497 498 layer count. 499 """ 500 return _ogr.DataSource_GetLayerCount(self, *args)
501 502
503 - def GetDriver(self, *args):
504 """ 505 GetDriver(DataSource self) -> Driver 506 507 OGRSFDriverH 508 OGR_DS_GetDriver(OGRDataSourceH hDS) 509 510 Returns the driver that the dataset was opened with. 511 512 NOTE: Starting with GDAL 2.0, it is NOT safe to cast the returned 513 handle to OGRSFDriver*. If a C++ object is needed, the handle should 514 be cast to GDALDriver*. 515 516 Deprecated Use GDALGetDatasetDriver() in GDAL 2.0 517 518 Parameters: 519 ----------- 520 521 hDS: handle to the datasource 522 523 NULL if driver info is not available, or pointer to a driver owned by 524 the OGRSFDriverManager. 525 """ 526 return _ogr.DataSource_GetDriver(self, *args)
527 528
529 - def GetName(self, *args):
530 """ 531 GetName(DataSource self) -> char const * 532 533 const char* 534 OGR_DS_GetName(OGRDataSourceH hDS) 535 536 Returns the name of the data source. 537 538 This string should be sufficient to open the data source if passed to 539 the same OGRSFDriver that this data source was opened with, but it 540 need not be exactly the same string that was used to open the data 541 source. Normally this is a filename. 542 543 Deprecated Use GDALGetDescription() in GDAL 2.0 544 545 Parameters: 546 ----------- 547 548 hDS: handle to the data source to get the name from. 549 550 pointer to an internal name string which should not be modified or 551 freed by the caller. 552 """ 553 return _ogr.DataSource_GetName(self, *args)
554 555
556 - def DeleteLayer(self, *args):
557 """ 558 DeleteLayer(DataSource self, int index) -> OGRErr 559 560 OGRErr 561 OGR_DS_DeleteLayer(OGRDataSourceH hDS, int iLayer) 562 563 Delete the indicated layer from the datasource. 564 565 If this method is supported the ODsCDeleteLayer capability will test 566 TRUE on the OGRDataSource. 567 568 Deprecated Use GDALDatasetDeleteLayer() in GDAL 2.0 569 570 Parameters: 571 ----------- 572 573 hDS: handle to the datasource 574 575 iLayer: the index of the layer to delete. 576 577 OGRERR_NONE on success, or OGRERR_UNSUPPORTED_OPERATION if deleting 578 layers is not supported for this datasource. 579 """ 580 return _ogr.DataSource_DeleteLayer(self, *args)
581 582
583 - def SyncToDisk(self, *args):
584 """ 585 SyncToDisk(DataSource self) -> OGRErr 586 587 OGRErr 588 OGR_DS_SyncToDisk(OGRDataSourceH hDS) 589 590 Flush pending changes to disk. 591 592 See GDALDataset::FlushCache() 593 """ 594 return _ogr.DataSource_SyncToDisk(self, *args)
595 596
597 - def FlushCache(self, *args):
598 """FlushCache(DataSource self)""" 599 return _ogr.DataSource_FlushCache(self, *args)
600 601
602 - def CreateLayer(self, *args, **kwargs):
603 """ 604 CreateLayer(DataSource self, char const * name, SpatialReference srs=None, OGRwkbGeometryType geom_type, char ** options=None) -> Layer 605 606 OGRLayerH 607 OGR_DS_CreateLayer(OGRDataSourceH hDS, const char *pszName, 608 OGRSpatialReferenceH hSpatialRef, OGRwkbGeometryType eType, char 609 **papszOptions) 610 611 This function attempts to create a new layer on the data source with 612 the indicated name, coordinate system, geometry type. 613 614 The papszOptions argument can be used to control driver specific 615 creation options. These options are normally documented in the format 616 specific documentation. 617 618 Deprecated Use GDALDatasetCreateLayer() in GDAL 2.0 619 620 Parameters: 621 ----------- 622 623 hDS: The dataset handle. 624 625 pszName: the name for the new layer. This should ideally not match 626 any existing layer on the datasource. 627 628 hSpatialRef: handle to the coordinate system to use for the new 629 layer, or NULL if no coordinate system is available. The driver might 630 only increase the reference counter of the object to take ownership, 631 and not make a full copy, so do not use OSRDestroySpatialReference(), 632 but OSRRelease() instead when you are done with the object. 633 634 eType: the geometry type for the layer. Use wkbUnknown if there are 635 no constraints on the types geometry to be written. 636 637 papszOptions: a StringList of name=value options. Options are driver 638 specific, and driver information can be found at the following 639 url:http://www.gdal.org/ogr_formats.html 640 641 NULL is returned on failure, or a new OGRLayer handle on success. 642 Example: 643 """ 644 return _ogr.DataSource_CreateLayer(self, *args, **kwargs)
645 646
647 - def CopyLayer(self, *args, **kwargs):
648 """ 649 CopyLayer(DataSource self, Layer src_layer, char const * new_name, char ** options=None) -> Layer 650 651 OGRLayerH 652 OGR_DS_CopyLayer(OGRDataSourceH hDS, OGRLayerH hSrcLayer, const char 653 *pszNewName, char **papszOptions) 654 655 Duplicate an existing layer. 656 657 This function creates a new layer, duplicate the field definitions of 658 the source layer and then duplicate each features of the source layer. 659 The papszOptions argument can be used to control driver specific 660 creation options. These options are normally documented in the format 661 specific documentation. The source layer may come from another 662 dataset. 663 664 Deprecated Use GDALDatasetCopyLayer() in GDAL 2.0 665 666 Parameters: 667 ----------- 668 669 hDS: handle to the data source where to create the new layer 670 671 hSrcLayer: handle to the source layer. 672 673 pszNewName: the name of the layer to create. 674 675 papszOptions: a StringList of name=value options. Options are driver 676 specific. 677 678 an handle to the layer, or NULL if an error occurs. 679 """ 680 return _ogr.DataSource_CopyLayer(self, *args, **kwargs)
681 682
683 - def GetLayerByIndex(self, *args):
684 """GetLayerByIndex(DataSource self, int index=0) -> Layer""" 685 return _ogr.DataSource_GetLayerByIndex(self, *args)
686 687
688 - def GetLayerByName(self, *args):
689 """ 690 GetLayerByName(DataSource self, char const * layer_name) -> Layer 691 692 OGRLayerH 693 OGR_DS_GetLayerByName(OGRDataSourceH hDS, const char *pszName) 694 695 Fetch a layer by name. 696 697 The returned layer remains owned by the OGRDataSource and should not 698 be deleted by the application. 699 700 Deprecated Use GDALDatasetGetLayerByName() in GDAL 2.0 701 702 Parameters: 703 ----------- 704 705 hDS: handle to the data source from which to get the layer. 706 707 pszLayerName: Layer the layer name of the layer to fetch. 708 709 an handle to the layer, or NULL if the layer is not found or an error 710 occurs. 711 """ 712 return _ogr.DataSource_GetLayerByName(self, *args)
713 714
715 - def TestCapability(self, *args):
716 """ 717 TestCapability(DataSource self, char const * cap) -> bool 718 719 int 720 OGR_DS_TestCapability(OGRDataSourceH hDS, const char *pszCap) 721 722 Test if capability is available. 723 724 One of the following data source capability names can be passed into 725 this function, and a TRUE or FALSE value will be returned indicating 726 whether or not the capability is available for this object. 727 728 ODsCCreateLayer: True if this datasource can create new layers. 729 730 ODsCDeleteLayer: True if this datasource can delete existing layers. 731 732 ODsCCreateGeomFieldAfterCreateLayer: True if the layers of this 733 datasource support CreateGeomField() just after layer creation. 734 735 ODsCCurveGeometries: True if this datasource supports writing curve 736 geometries. (GDAL 2.0). In that case, OLCCurveGeometries must also be 737 declared in layers of that dataset. 738 739 The #define macro forms of the capability names should be used in 740 preference to the strings themselves to avoid misspelling. 741 742 Deprecated Use GDALDatasetTestCapability() in GDAL 2.0 743 744 Parameters: 745 ----------- 746 747 hDS: handle to the data source against which to test the capability. 748 749 pszCapability: the capability to test. 750 751 TRUE if capability available otherwise FALSE. 752 """ 753 return _ogr.DataSource_TestCapability(self, *args)
754 755
756 - def ExecuteSQL(self, *args, **kwargs):
757 """ 758 ExecuteSQL(DataSource self, char const * statement, Geometry spatialFilter=None, char const * dialect) -> Layer 759 760 OGRLayerH 761 OGR_DS_ExecuteSQL(OGRDataSourceH hDS, const char *pszStatement, 762 OGRGeometryH hSpatialFilter, const char *pszDialect) 763 764 Execute an SQL statement against the data store. 765 766 The result of an SQL query is either NULL for statements that are in 767 error, or that have no results set, or an OGRLayer handle representing 768 a results set from the query. Note that this OGRLayer is in addition 769 to the layers in the data store and must be destroyed with 770 OGR_DS_ReleaseResultSet() before the data source is closed 771 (destroyed). 772 773 For more information on the SQL dialect supported internally by OGR 774 review theOGR SQL document. Some drivers (i.e. Oracle and PostGIS) 775 pass the SQL directly through to the underlying RDBMS. 776 777 Starting with OGR 1.10, theSQLITE dialect can also be used. 778 779 Deprecated Use GDALDatasetExecuteSQL() in GDAL 2.0 780 781 Parameters: 782 ----------- 783 784 hDS: handle to the data source on which the SQL query is executed. 785 786 pszSQLCommand: the SQL statement to execute. 787 788 hSpatialFilter: handle to a geometry which represents a spatial 789 filter. Can be NULL. 790 791 pszDialect: allows control of the statement dialect. If set to NULL, 792 the OGR SQL engine will be used, except for RDBMS drivers that will 793 use their dedicated SQL engine, unless OGRSQL is explicitly passed as 794 the dialect. Starting with OGR 1.10, the SQLITE dialect can also be 795 used. 796 797 an handle to a OGRLayer containing the results of the query. 798 Deallocate with OGR_DS_ReleaseResultSet(). 799 """ 800 return _ogr.DataSource_ExecuteSQL(self, *args, **kwargs)
801 802
803 - def ReleaseResultSet(self, *args):
804 """ 805 ReleaseResultSet(DataSource self, Layer layer) 806 807 void 808 OGR_DS_ReleaseResultSet(OGRDataSourceH hDS, OGRLayerH hLayer) 809 810 Release results of OGR_DS_ExecuteSQL(). 811 812 This function should only be used to deallocate OGRLayers resulting 813 from an OGR_DS_ExecuteSQL() call on the same OGRDataSource. Failure to 814 deallocate a results set before destroying the OGRDataSource may cause 815 errors. 816 817 Deprecated Use GDALDatasetReleaseResultSet() in GDAL 2.0 818 819 Parameters: 820 ----------- 821 822 hDS: an handle to the data source on which was executed an SQL query. 823 824 hLayer: handle to the result of a previous OGR_DS_ExecuteSQL() call. 825 826 """ 827 return _ogr.DataSource_ReleaseResultSet(self, *args)
828 829
830 - def GetStyleTable(self, *args):
831 """ 832 GetStyleTable(DataSource self) -> StyleTable 833 834 OGRStyleTableH 835 OGR_DS_GetStyleTable(OGRDataSourceH hDS) 836 837 Get style table. 838 """ 839 return _ogr.DataSource_GetStyleTable(self, *args)
840 841
842 - def SetStyleTable(self, *args):
843 """ 844 SetStyleTable(DataSource self, StyleTable table) 845 846 void 847 OGR_DS_SetStyleTable(OGRDataSourceH hDS, OGRStyleTableH hStyleTable) 848 849 Set style table. 850 """ 851 return _ogr.DataSource_SetStyleTable(self, *args)
852 853
854 - def StartTransaction(self, *args, **kwargs):
855 """StartTransaction(DataSource self, int force=False) -> OGRErr""" 856 return _ogr.DataSource_StartTransaction(self, *args, **kwargs)
857 858
859 - def CommitTransaction(self, *args):
860 """CommitTransaction(DataSource self) -> OGRErr""" 861 return _ogr.DataSource_CommitTransaction(self, *args)
862 863
864 - def RollbackTransaction(self, *args):
865 """RollbackTransaction(DataSource self) -> OGRErr""" 866 return _ogr.DataSource_RollbackTransaction(self, *args)
867 868
869 - def Destroy(self):
870 "Once called, self has effectively been destroyed. Do not access. For backwards compatibility only" 871 _ogr.delete_DataSource(self) 872 self.thisown = 0
873
874 - def Release(self):
875 "Once called, self has effectively been destroyed. Do not access. For backwards compatibility only" 876 _ogr.delete_DataSource(self) 877 self.thisown = 0
878
879 - def Reference(self):
880 "For backwards compatibility only." 881 return self.Reference()
882
883 - def Dereference(self):
884 "For backwards compatibility only." 885 self.Dereference()
886
887 - def __len__(self):
888 """Returns the number of layers on the datasource""" 889 return self.GetLayerCount()
890
891 - def __getitem__(self, value):
892 """Support dictionary, list, and slice -like access to the datasource. 893 ds[0] would return the first layer on the datasource. 894 ds['aname'] would return the layer named "aname". 895 ds[0:4] would return a list of the first four layers.""" 896 if isinstance(value, slice): 897 output = [] 898 step = value.step if value.step else 1 899 for i in xrange(value.start, value.stop, step): 900 lyr = self.GetLayer(i) 901 if lyr is None: 902 return output 903 output.append(lyr) 904 return output 905 if isinstance(value, int): 906 if value > len(self) - 1: 907 raise IndexError 908 return self.GetLayer(value) 909 elif isinstance(value, str): 910 return self.GetLayer(value) 911 else: 912 raise TypeError('Input %s is not of String or Int type' % type(value))
913
914 - def GetLayer(self, iLayer=0):
915 """Return the layer given an index or a name""" 916 if isinstance(iLayer, str): 917 return self.GetLayerByName(str(iLayer)) 918 elif isinstance(iLayer, int): 919 return self.GetLayerByIndex(iLayer) 920 else: 921 raise TypeError("Input %s is not of String or Int type" % type(iLayer))
922
923 - def DeleteLayer(self, value):
924 """Deletes the layer given an index or layer name""" 925 if isinstance(value, str): 926 for i in range(self.GetLayerCount()): 927 name = self.GetLayer(i).GetName() 928 if name == value: 929 return _ogr.DataSource_DeleteLayer(self, i) 930 raise ValueError("Layer %s not found to delete" % value) 931 elif isinstance(value, int): 932 return _ogr.DataSource_DeleteLayer(self, value) 933 else: 934 raise TypeError("Input %s is not of String or Int type" % type(value))
935 936 DataSource_swigregister = _ogr.DataSource_swigregister 937 DataSource_swigregister(DataSource) 938
939 -class Layer(MajorObject):
940 """Proxy of C++ OGRLayerShadow class.""" 941 942 __swig_setmethods__ = {} 943 for _s in [MajorObject]: 944 __swig_setmethods__.update(getattr(_s, '__swig_setmethods__', {})) 945 __setattr__ = lambda self, name, value: _swig_setattr(self, Layer, name, value) 946 __swig_getmethods__ = {} 947 for _s in [MajorObject]: 948 __swig_getmethods__.update(getattr(_s, '__swig_getmethods__', {})) 949 __getattr__ = lambda self, name: _swig_getattr(self, Layer, name) 950
951 - def __init__(self, *args, **kwargs):
952 raise AttributeError("No constructor defined")
953 __repr__ = _swig_repr 954
955 - def GetRefCount(self, *args):
956 """ 957 GetRefCount(Layer self) -> int 958 959 int OGR_L_GetRefCount(OGRLayerH 960 hLayer) 961 """ 962 return _ogr.Layer_GetRefCount(self, *args)
963 964
965 - def SetSpatialFilter(self, *args):
966 """ 967 SetSpatialFilter(Layer self, Geometry filter) 968 SetSpatialFilter(Layer self, int iGeomField, Geometry filter) 969 970 void 971 OGR_L_SetSpatialFilter(OGRLayerH hLayer, OGRGeometryH hGeom) 972 973 Set a new spatial filter. 974 975 This function set the geometry to be used as a spatial filter when 976 fetching features via the OGR_L_GetNextFeature() function. Only 977 features that geometrically intersect the filter geometry will be 978 returned. 979 980 Currently this test is may be inaccurately implemented, but it is 981 guaranteed that all features whose envelope (as returned by 982 OGR_G_GetEnvelope()) overlaps the envelope of the spatial filter will 983 be returned. This can result in more shapes being returned that should 984 strictly be the case. 985 986 Starting with GDAL 2.3, features with null or empty geometries will 987 never be considered as matching a spatial filter. 988 989 This function makes an internal copy of the passed geometry. The 990 passed geometry remains the responsibility of the caller, and may be 991 safely destroyed. 992 993 For the time being the passed filter geometry should be in the same 994 SRS as the layer (as returned by OGR_L_GetSpatialRef()). In the future 995 this may be generalized. 996 997 This function is the same as the C++ method 998 OGRLayer::SetSpatialFilter. 999 1000 Parameters: 1001 ----------- 1002 1003 hLayer: handle to the layer on which to set the spatial filter. 1004 1005 hGeom: handle to the geometry to use as a filtering region. NULL may 1006 be passed indicating that the current spatial filter should be 1007 cleared, but no new one instituted. 1008 """ 1009 return _ogr.Layer_SetSpatialFilter(self, *args)
1010 1011
1012 - def SetSpatialFilterRect(self, *args):
1013 """ 1014 SetSpatialFilterRect(Layer self, double minx, double miny, double maxx, double maxy) 1015 SetSpatialFilterRect(Layer self, int iGeomField, double minx, double miny, double maxx, double maxy) 1016 1017 void 1018 OGR_L_SetSpatialFilterRect(OGRLayerH hLayer, double dfMinX, double 1019 dfMinY, double dfMaxX, double dfMaxY) 1020 1021 Set a new rectangular spatial filter. 1022 1023 This method set rectangle to be used as a spatial filter when fetching 1024 features via the OGR_L_GetNextFeature() method. Only features that 1025 geometrically intersect the given rectangle will be returned. 1026 1027 The x/y values should be in the same coordinate system as the layer as 1028 a whole (as returned by OGRLayer::GetSpatialRef()). Internally this 1029 method is normally implemented as creating a 5 vertex closed 1030 rectangular polygon and passing it to OGRLayer::SetSpatialFilter(). It 1031 exists as a convenience. 1032 1033 The only way to clear a spatial filter set with this method is to call 1034 OGRLayer::SetSpatialFilter(NULL). 1035 1036 This method is the same as the C++ method 1037 OGRLayer::SetSpatialFilterRect(). 1038 1039 Parameters: 1040 ----------- 1041 1042 hLayer: handle to the layer on which to set the spatial filter. 1043 1044 dfMinX: the minimum X coordinate for the rectangular region. 1045 1046 dfMinY: the minimum Y coordinate for the rectangular region. 1047 1048 dfMaxX: the maximum X coordinate for the rectangular region. 1049 1050 dfMaxY: the maximum Y coordinate for the rectangular region. 1051 """ 1052 return _ogr.Layer_SetSpatialFilterRect(self, *args)
1053 1054
1055 - def GetSpatialFilter(self, *args):
1056 """ 1057 GetSpatialFilter(Layer self) -> Geometry 1058 1059 OGRGeometryH 1060 OGR_L_GetSpatialFilter(OGRLayerH hLayer) 1061 1062 This function returns the current spatial filter for this layer. 1063 1064 The returned pointer is to an internally owned object, and should not 1065 be altered or deleted by the caller. 1066 1067 This function is the same as the C++ method 1068 OGRLayer::GetSpatialFilter(). 1069 1070 Parameters: 1071 ----------- 1072 1073 hLayer: handle to the layer to get the spatial filter from. 1074 1075 an handle to the spatial filter geometry. 1076 """ 1077 return _ogr.Layer_GetSpatialFilter(self, *args)
1078 1079
1080 - def SetAttributeFilter(self, *args):
1081 """ 1082 SetAttributeFilter(Layer self, char * filter_string) -> OGRErr 1083 1084 OGRErr 1085 OGR_L_SetAttributeFilter(OGRLayerH hLayer, const char *pszQuery) 1086 1087 Set a new attribute query. 1088 1089 This function sets the attribute query string to be used when fetching 1090 features via the OGR_L_GetNextFeature() function. Only features for 1091 which the query evaluates as true will be returned. 1092 1093 The query string should be in the format of an SQL WHERE clause. For 1094 instance "population > 1000000 and population < 5000000" where 1095 population is an attribute in the layer. The query format is a 1096 restricted form of SQL WHERE clause as defined 1097 "eq_format=restricted_where" about half way through this document: 1098 1099 http://ogdi.sourceforge.net/prop/6.2.CapabilitiesMetadata.html 1100 1101 Note that installing a query string will generally result in resetting 1102 the current reading position (ala OGR_L_ResetReading()). 1103 1104 This function is the same as the C++ method 1105 OGRLayer::SetAttributeFilter(). 1106 1107 Parameters: 1108 ----------- 1109 1110 hLayer: handle to the layer on which attribute query will be 1111 executed. 1112 1113 pszQuery: query in restricted SQL WHERE format, or NULL to clear the 1114 current query. 1115 1116 OGRERR_NONE if successfully installed, or an error code if the query 1117 expression is in error, or some other failure occurs. 1118 """ 1119 return _ogr.Layer_SetAttributeFilter(self, *args)
1120 1121
1122 - def ResetReading(self, *args):
1123 """ 1124 ResetReading(Layer self) 1125 1126 void 1127 OGR_L_ResetReading(OGRLayerH hLayer) 1128 1129 Reset feature reading to start on the first feature. 1130 1131 This affects GetNextFeature(). 1132 1133 This function is the same as the C++ method OGRLayer::ResetReading(). 1134 1135 Parameters: 1136 ----------- 1137 1138 hLayer: handle to the layer on which features are read. 1139 """ 1140 return _ogr.Layer_ResetReading(self, *args)
1141 1142
1143 - def GetName(self, *args):
1144 """ 1145 GetName(Layer self) -> char const * 1146 1147 const char* OGR_L_GetName(OGRLayerH 1148 hLayer) 1149 1150 Return the layer name. 1151 1152 This returns the same content as 1153 OGR_FD_GetName(OGR_L_GetLayerDefn(hLayer)), but for a few drivers, 1154 calling OGR_L_GetName() directly can avoid lengthy layer definition 1155 initialization. 1156 1157 This function is the same as the C++ method OGRLayer::GetName(). 1158 1159 Parameters: 1160 ----------- 1161 1162 hLayer: handle to the layer. 1163 1164 the layer name (must not been freed) 1165 1166 OGR 1.8.0 1167 """ 1168 return _ogr.Layer_GetName(self, *args)
1169 1170
1171 - def GetGeomType(self, *args):
1172 """ 1173 GetGeomType(Layer self) -> OGRwkbGeometryType 1174 1175 OGRwkbGeometryType 1176 OGR_L_GetGeomType(OGRLayerH hLayer) 1177 1178 Return the layer geometry type. 1179 1180 This returns the same result as 1181 OGR_FD_GetGeomType(OGR_L_GetLayerDefn(hLayer)), but for a few drivers, 1182 calling OGR_L_GetGeomType() directly can avoid lengthy layer 1183 definition initialization. 1184 1185 For layers with multiple geometry fields, this method only returns the 1186 geometry type of the first geometry column. For other columns, use 1187 OGR_GFld_GetType(OGR_FD_GetGeomFieldDefn(OGR_L_GetLayerDefn(hLayer), 1188 i)). For layers without any geometry field, this method returns 1189 wkbNone. 1190 1191 This function is the same as the C++ method OGRLayer::GetGeomType(). 1192 1193 Parameters: 1194 ----------- 1195 1196 hLayer: handle to the layer. 1197 1198 the geometry type 1199 1200 OGR 1.8.0 1201 """ 1202 return _ogr.Layer_GetGeomType(self, *args)
1203 1204
1205 - def GetGeometryColumn(self, *args):
1206 """ 1207 GetGeometryColumn(Layer self) -> char const * 1208 1209 const char* 1210 OGR_L_GetGeometryColumn(OGRLayerH hLayer) 1211 1212 This method returns the name of the underlying database column being 1213 used as the geometry column, or "" if not supported. 1214 1215 For layers with multiple geometry fields, this method only returns the 1216 geometry type of the first geometry column. For other columns, use OGR 1217 _GFld_GetNameRef(OGR_FD_GetGeomFieldDefn(OGR_L_GetLayerDefn(hLayer), 1218 i)). 1219 1220 This method is the same as the C++ method 1221 OGRLayer::GetGeometryColumn() 1222 1223 Parameters: 1224 ----------- 1225 1226 hLayer: handle to the layer 1227 1228 geometry column name. 1229 """ 1230 return _ogr.Layer_GetGeometryColumn(self, *args)
1231 1232
1233 - def GetFIDColumn(self, *args):
1234 """ 1235 GetFIDColumn(Layer self) -> char const * 1236 1237 const char* 1238 OGR_L_GetFIDColumn(OGRLayerH hLayer) 1239 1240 This method returns the name of the underlying database column being 1241 used as the FID column, or "" if not supported. 1242 1243 This method is the same as the C++ method OGRLayer::GetFIDColumn() 1244 1245 Parameters: 1246 ----------- 1247 1248 hLayer: handle to the layer 1249 1250 fid column name. 1251 """ 1252 return _ogr.Layer_GetFIDColumn(self, *args)
1253 1254
1255 - def GetFeature(self, *args):
1256 """ 1257 GetFeature(Layer self, GIntBig fid) -> Feature 1258 1259 OGRFeatureH 1260 OGR_L_GetFeature(OGRLayerH hLayer, GIntBig nFeatureId) 1261 1262 Fetch a feature by its identifier. 1263 1264 This function will attempt to read the identified feature. The nFID 1265 value cannot be OGRNullFID. Success or failure of this operation is 1266 unaffected by the spatial or attribute filters (and specialized 1267 implementations in drivers should make sure that they do not take into 1268 account spatial or attribute filters). 1269 1270 If this function returns a non-NULL feature, it is guaranteed that its 1271 feature id ( OGR_F_GetFID()) will be the same as nFID. 1272 1273 Use OGR_L_TestCapability(OLCRandomRead) to establish if this layer 1274 supports efficient random access reading via OGR_L_GetFeature(); 1275 however, the call should always work if the feature exists as a 1276 fallback implementation just scans all the features in the layer 1277 looking for the desired feature. 1278 1279 Sequential reads (with OGR_L_GetNextFeature()) are generally 1280 considered interrupted by a OGR_L_GetFeature() call. 1281 1282 The returned feature should be free with OGR_F_Destroy(). 1283 1284 This function is the same as the C++ method OGRLayer::GetFeature( ). 1285 1286 Parameters: 1287 ----------- 1288 1289 hLayer: handle to the layer that owned the feature. 1290 1291 nFeatureId: the feature id of the feature to read. 1292 1293 an handle to a feature now owned by the caller, or NULL on failure. 1294 """ 1295 return _ogr.Layer_GetFeature(self, *args)
1296 1297
1298 - def GetNextFeature(self, *args):
1299 """ 1300 GetNextFeature(Layer self) -> Feature 1301 1302 OGRFeatureH 1303 OGR_L_GetNextFeature(OGRLayerH hLayer) 1304 1305 Fetch the next available feature from this layer. 1306 1307 The returned feature becomes the responsibility of the caller to 1308 delete with OGR_F_Destroy(). It is critical that all features 1309 associated with an OGRLayer (more specifically an OGRFeatureDefn) be 1310 deleted before that layer/datasource is deleted. 1311 1312 Only features matching the current spatial filter (set with 1313 SetSpatialFilter()) will be returned. 1314 1315 This function implements sequential access to the features of a layer. 1316 The OGR_L_ResetReading() function can be used to start at the 1317 beginning again. 1318 1319 Features returned by OGR_GetNextFeature() may or may not be affected 1320 by concurrent modifications depending on drivers. A guaranteed way of 1321 seeing modifications in effect is to call OGR_L_ResetReading() on 1322 layers where OGR_GetNextFeature() has been called, before reading 1323 again. Structural changes in layers (field addition, deletion, ...) 1324 when a read is in progress may or may not be possible depending on 1325 drivers. If a transaction is committed/aborted, the current sequential 1326 reading may or may not be valid after that operation and a call to 1327 OGR_L_ResetReading() might be needed. 1328 1329 This function is the same as the C++ method 1330 OGRLayer::GetNextFeature(). 1331 1332 Parameters: 1333 ----------- 1334 1335 hLayer: handle to the layer from which feature are read. 1336 1337 an handle to a feature, or NULL if no more features are available. 1338 """ 1339 return _ogr.Layer_GetNextFeature(self, *args)
1340 1341
1342 - def SetNextByIndex(self, *args):
1343 """ 1344 SetNextByIndex(Layer self, GIntBig new_index) -> OGRErr 1345 1346 OGRErr 1347 OGR_L_SetNextByIndex(OGRLayerH hLayer, GIntBig nIndex) 1348 1349 Move read cursor to the nIndex'th feature in the current resultset. 1350 1351 This method allows positioning of a layer such that the 1352 GetNextFeature() call will read the requested feature, where nIndex is 1353 an absolute index into the current result set. So, setting it to 3 1354 would mean the next feature read with GetNextFeature() would have been 1355 the 4th feature to have been read if sequential reading took place 1356 from the beginning of the layer, including accounting for spatial and 1357 attribute filters. 1358 1359 Only in rare circumstances is SetNextByIndex() efficiently 1360 implemented. In all other cases the default implementation which calls 1361 ResetReading() and then calls GetNextFeature() nIndex times is used. 1362 To determine if fast seeking is available on the current layer use the 1363 TestCapability() method with a value of OLCFastSetNextByIndex. 1364 1365 This method is the same as the C++ method OGRLayer::SetNextByIndex() 1366 1367 Parameters: 1368 ----------- 1369 1370 hLayer: handle to the layer 1371 1372 nIndex: the index indicating how many steps into the result set to 1373 seek. 1374 1375 OGRERR_NONE on success or an error code. 1376 """ 1377 return _ogr.Layer_SetNextByIndex(self, *args)
1378 1379
1380 - def SetFeature(self, *args):
1381 """ 1382 SetFeature(Layer self, Feature feature) -> OGRErr 1383 1384 OGRErr OGR_L_SetFeature(OGRLayerH 1385 hLayer, OGRFeatureH hFeat) 1386 1387 Rewrite an existing feature. 1388 1389 This function will write a feature to the layer, based on the feature 1390 id within the OGRFeature. 1391 1392 Use OGR_L_TestCapability(OLCRandomWrite) to establish if this layer 1393 supports random access writing via OGR_L_SetFeature(). 1394 1395 This function is the same as the C++ method OGRLayer::SetFeature(). 1396 1397 Parameters: 1398 ----------- 1399 1400 hLayer: handle to the layer to write the feature. 1401 1402 hFeat: the feature to write. 1403 1404 OGRERR_NONE if the operation works, otherwise an appropriate error 1405 code (e.g OGRERR_NON_EXISTING_FEATURE if the feature does not exist). 1406 1407 """ 1408 return _ogr.Layer_SetFeature(self, *args)
1409 1410
1411 - def CreateFeature(self, *args):
1412 """ 1413 CreateFeature(Layer self, Feature feature) -> OGRErr 1414 1415 OGRErr 1416 OGR_L_CreateFeature(OGRLayerH hLayer, OGRFeatureH hFeat) 1417 1418 Create and write a new feature within a layer. 1419 1420 The passed feature is written to the layer as a new feature, rather 1421 than overwriting an existing one. If the feature has a feature id 1422 other than OGRNullFID, then the native implementation may use that as 1423 the feature id of the new feature, but not necessarily. Upon 1424 successful return the passed feature will have been updated with the 1425 new feature id. 1426 1427 This function is the same as the C++ method OGRLayer::CreateFeature(). 1428 1429 Parameters: 1430 ----------- 1431 1432 hLayer: handle to the layer to write the feature to. 1433 1434 hFeat: the handle of the feature to write to disk. 1435 1436 OGRERR_NONE on success. 1437 """ 1438 return _ogr.Layer_CreateFeature(self, *args)
1439 1440
1441 - def DeleteFeature(self, *args):
1442 """ 1443 DeleteFeature(Layer self, GIntBig fid) -> OGRErr 1444 1445 OGRErr 1446 OGR_L_DeleteFeature(OGRLayerH hLayer, GIntBig nFID) 1447 1448 Delete feature from layer. 1449 1450 The feature with the indicated feature id is deleted from the layer if 1451 supported by the driver. Most drivers do not support feature deletion, 1452 and will return OGRERR_UNSUPPORTED_OPERATION. The 1453 OGR_L_TestCapability() function may be called with OLCDeleteFeature to 1454 check if the driver supports feature deletion. 1455 1456 This method is the same as the C++ method OGRLayer::DeleteFeature(). 1457 1458 Parameters: 1459 ----------- 1460 1461 hLayer: handle to the layer 1462 1463 nFID: the feature id to be deleted from the layer 1464 1465 OGRERR_NONE if the operation works, otherwise an appropriate error 1466 code (e.g OGRERR_NON_EXISTING_FEATURE if the feature does not exist). 1467 1468 """ 1469 return _ogr.Layer_DeleteFeature(self, *args)
1470 1471
1472 - def SyncToDisk(self, *args):
1473 """ 1474 SyncToDisk(Layer self) -> OGRErr 1475 1476 OGRErr OGR_L_SyncToDisk(OGRLayerH 1477 hLayer) 1478 1479 Flush pending changes to disk. 1480 1481 This call is intended to force the layer to flush any pending writes 1482 to disk, and leave the disk file in a consistent state. It would not 1483 normally have any effect on read-only datasources. 1484 1485 Some layers do not implement this method, and will still return 1486 OGRERR_NONE. The default implementation just returns OGRERR_NONE. An 1487 error is only returned if an error occurs while attempting to flush to 1488 disk. 1489 1490 In any event, you should always close any opened datasource with 1491 OGR_DS_Destroy() that will ensure all data is correctly flushed. 1492 1493 This method is the same as the C++ method OGRLayer::SyncToDisk() 1494 1495 Parameters: 1496 ----------- 1497 1498 hLayer: handle to the layer 1499 1500 OGRERR_NONE if no error occurs (even if nothing is done) or an error 1501 code. 1502 """ 1503 return _ogr.Layer_SyncToDisk(self, *args)
1504 1505
1506 - def GetLayerDefn(self, *args):
1507 """ 1508 GetLayerDefn(Layer self) -> FeatureDefn 1509 1510 OGRFeatureDefnH 1511 OGR_L_GetLayerDefn(OGRLayerH hLayer) 1512 1513 Fetch the schema information for this layer. 1514 1515 The returned handle to the OGRFeatureDefn is owned by the OGRLayer, 1516 and should not be modified or freed by the application. It 1517 encapsulates the attribute schema of the features of the layer. 1518 1519 This function is the same as the C++ method OGRLayer::GetLayerDefn(). 1520 1521 Parameters: 1522 ----------- 1523 1524 hLayer: handle to the layer to get the schema information. 1525 1526 an handle to the feature definition. 1527 """ 1528 return _ogr.Layer_GetLayerDefn(self, *args)
1529 1530
1531 - def GetFeatureCount(self, *args, **kwargs):
1532 """ 1533 GetFeatureCount(Layer self, int force=1) -> GIntBig 1534 1535 GIntBig 1536 OGR_L_GetFeatureCount(OGRLayerH hLayer, int bForce) 1537 1538 Fetch the feature count in this layer. 1539 1540 Returns the number of features in the layer. For dynamic databases the 1541 count may not be exact. If bForce is FALSE, and it would be expensive 1542 to establish the feature count a value of -1 may be returned 1543 indicating that the count isn't know. If bForce is TRUE some 1544 implementations will actually scan the entire layer once to count 1545 objects. 1546 1547 The returned count takes the spatial filter into account. 1548 1549 Note that some implementations of this method may alter the read 1550 cursor of the layer. 1551 1552 This function is the same as the CPP OGRLayer::GetFeatureCount(). 1553 1554 Note: since GDAL 2.0, this method returns a GIntBig (previously a int) 1555 1556 Parameters: 1557 ----------- 1558 1559 hLayer: handle to the layer that owned the features. 1560 1561 bForce: Flag indicating whether the count should be computed even if 1562 it is expensive. 1563 1564 feature count, -1 if count not known. 1565 """ 1566 return _ogr.Layer_GetFeatureCount(self, *args, **kwargs)
1567 1568
1569 - def GetExtent(self, *args, **kwargs):
1570 """ 1571 GetExtent(Layer self, int force=1, int can_return_null=0, int geom_field=0) 1572 1573 OGRErr OGR_L_GetExtent(OGRLayerH 1574 hLayer, OGREnvelope *psExtent, int bForce) 1575 1576 Fetch the extent of this layer. 1577 1578 Returns the extent (MBR) of the data in the layer. If bForce is FALSE, 1579 and it would be expensive to establish the extent then OGRERR_FAILURE 1580 will be returned indicating that the extent isn't know. If bForce is 1581 TRUE then some implementations will actually scan the entire layer 1582 once to compute the MBR of all the features in the layer. 1583 1584 Depending on the drivers, the returned extent may or may not take the 1585 spatial filter into account. So it is safer to call OGR_L_GetExtent() 1586 without setting a spatial filter. 1587 1588 Layers without any geometry may return OGRERR_FAILURE just indicating 1589 that no meaningful extents could be collected. 1590 1591 Note that some implementations of this method may alter the read 1592 cursor of the layer. 1593 1594 This function is the same as the C++ method OGRLayer::GetExtent(). 1595 1596 Parameters: 1597 ----------- 1598 1599 hLayer: handle to the layer from which to get extent. 1600 1601 psExtent: the structure in which the extent value will be returned. 1602 1603 bForce: Flag indicating whether the extent should be computed even if 1604 it is expensive. 1605 1606 OGRERR_NONE on success, OGRERR_FAILURE if extent not known. 1607 """ 1608 return _ogr.Layer_GetExtent(self, *args, **kwargs)
1609 1610
1611 - def TestCapability(self, *args):
1612 """ 1613 TestCapability(Layer self, char const * cap) -> bool 1614 1615 int 1616 OGR_L_TestCapability(OGRLayerH hLayer, const char *pszCap) 1617 1618 Test if this layer supported the named capability. 1619 1620 The capability codes that can be tested are represented as strings, 1621 but #defined constants exists to ensure correct spelling. Specific 1622 layer types may implement class specific capabilities, but this can't 1623 generally be discovered by the caller. 1624 1625 OLCRandomRead / "RandomRead": TRUE if the GetFeature() method is 1626 implemented in an optimized way for this layer, as opposed to the 1627 default implementation using ResetReading() and GetNextFeature() to 1628 find the requested feature id. 1629 1630 OLCSequentialWrite / "SequentialWrite": TRUE if the CreateFeature() 1631 method works for this layer. Note this means that this particular 1632 layer is writable. The same OGRLayer class may returned FALSE for 1633 other layer instances that are effectively read-only. 1634 1635 OLCRandomWrite / "RandomWrite": TRUE if the SetFeature() method is 1636 operational on this layer. Note this means that this particular layer 1637 is writable. The same OGRLayer class may returned FALSE for other 1638 layer instances that are effectively read-only. 1639 1640 OLCFastSpatialFilter / "FastSpatialFilter": TRUE if this layer 1641 implements spatial filtering efficiently. Layers that effectively read 1642 all features, and test them with the OGRFeature intersection methods 1643 should return FALSE. This can be used as a clue by the application 1644 whether it should build and maintain its own spatial index for 1645 features in this layer. 1646 1647 OLCFastFeatureCount / "FastFeatureCount": TRUE if this layer can 1648 return a feature count (via OGR_L_GetFeatureCount()) efficiently, i.e. 1649 without counting the features. In some cases this will return TRUE 1650 until a spatial filter is installed after which it will return FALSE. 1651 1652 OLCFastGetExtent / "FastGetExtent": TRUE if this layer can return 1653 its data extent (via OGR_L_GetExtent()) efficiently, i.e. without 1654 scanning all the features. In some cases this will return TRUE until a 1655 spatial filter is installed after which it will return FALSE. 1656 1657 OLCFastSetNextByIndex / "FastSetNextByIndex": TRUE if this layer can 1658 perform the SetNextByIndex() call efficiently, otherwise FALSE. 1659 1660 OLCCreateField / "CreateField": TRUE if this layer can create new 1661 fields on the current layer using CreateField(), otherwise FALSE. 1662 1663 OLCCreateGeomField / "CreateGeomField": (GDAL >= 1.11) TRUE if this 1664 layer can create new geometry fields on the current layer using 1665 CreateGeomField(), otherwise FALSE. 1666 1667 OLCDeleteField / "DeleteField": TRUE if this layer can delete 1668 existing fields on the current layer using DeleteField(), otherwise 1669 FALSE. 1670 1671 OLCReorderFields / "ReorderFields": TRUE if this layer can reorder 1672 existing fields on the current layer using ReorderField() or 1673 ReorderFields(), otherwise FALSE. 1674 1675 OLCAlterFieldDefn / "AlterFieldDefn": TRUE if this layer can alter 1676 the definition of an existing field on the current layer using 1677 AlterFieldDefn(), otherwise FALSE. 1678 1679 OLCDeleteFeature / "DeleteFeature": TRUE if the DeleteFeature() 1680 method is supported on this layer, otherwise FALSE. 1681 1682 OLCStringsAsUTF8 / "StringsAsUTF8": TRUE if values of OFTString 1683 fields are assured to be in UTF-8 format. If FALSE the encoding of 1684 fields is uncertain, though it might still be UTF-8. 1685 1686 OLCTransactions / "Transactions": TRUE if the StartTransaction(), 1687 CommitTransaction() and RollbackTransaction() methods work in a 1688 meaningful way, otherwise FALSE. 1689 1690 OLCCurveGeometries / "CurveGeometries": TRUE if this layer supports 1691 writing curve geometries or may return such geometries. (GDAL 2.0). 1692 1693 This function is the same as the C++ method 1694 OGRLayer::TestCapability(). 1695 1696 Parameters: 1697 ----------- 1698 1699 hLayer: handle to the layer to get the capability from. 1700 1701 pszCap: the name of the capability to test. 1702 1703 TRUE if the layer has the requested capability, or FALSE otherwise. 1704 OGRLayers will return FALSE for any unrecognized capabilities. 1705 """ 1706 return _ogr.Layer_TestCapability(self, *args)
1707 1708
1709 - def CreateField(self, *args, **kwargs):
1710 """ 1711 CreateField(Layer self, FieldDefn field_def, int approx_ok=1) -> OGRErr 1712 1713 OGRErr 1714 OGR_L_CreateField(OGRLayerH hLayer, OGRFieldDefnH hField, int 1715 bApproxOK) 1716 1717 Create a new field on a layer. 1718 1719 You must use this to create new fields on a real layer. Internally the 1720 OGRFeatureDefn for the layer will be updated to reflect the new field. 1721 Applications should never modify the OGRFeatureDefn used by a layer 1722 directly. 1723 1724 This function should not be called while there are feature objects in 1725 existence that were obtained or created with the previous layer 1726 definition. 1727 1728 Not all drivers support this function. You can query a layer to check 1729 if it supports it with the OLCCreateField capability. Some drivers may 1730 only support this method while there are still no features in the 1731 layer. When it is supported, the existing features of the backing 1732 file/database should be updated accordingly. 1733 1734 Drivers may or may not support not-null constraints. If they support 1735 creating fields with not-null constraints, this is generally before 1736 creating any feature to the layer. 1737 1738 This function is the same as the C++ method OGRLayer::CreateField(). 1739 1740 Parameters: 1741 ----------- 1742 1743 hLayer: handle to the layer to write the field definition. 1744 1745 hField: handle of the field definition to write to disk. 1746 1747 bApproxOK: If TRUE, the field may be created in a slightly different 1748 form depending on the limitations of the format driver. 1749 1750 OGRERR_NONE on success. 1751 """ 1752 return _ogr.Layer_CreateField(self, *args, **kwargs)
1753 1754
1755 - def DeleteField(self, *args):
1756 """ 1757 DeleteField(Layer self, int iField) -> OGRErr 1758 1759 OGRErr 1760 OGR_L_DeleteField(OGRLayerH hLayer, int iField) 1761 1762 Delete an existing field on a layer. 1763 1764 You must use this to delete existing fields on a real layer. 1765 Internally the OGRFeatureDefn for the layer will be updated to reflect 1766 the deleted field. Applications should never modify the OGRFeatureDefn 1767 used by a layer directly. 1768 1769 This function should not be called while there are feature objects in 1770 existence that were obtained or created with the previous layer 1771 definition. 1772 1773 Not all drivers support this function. You can query a layer to check 1774 if it supports it with the OLCDeleteField capability. Some drivers may 1775 only support this method while there are still no features in the 1776 layer. When it is supported, the existing features of the backing 1777 file/database should be updated accordingly. 1778 1779 This function is the same as the C++ method OGRLayer::DeleteField(). 1780 1781 Parameters: 1782 ----------- 1783 1784 hLayer: handle to the layer. 1785 1786 iField: index of the field to delete. 1787 1788 OGRERR_NONE on success. 1789 1790 OGR 1.9.0 1791 """ 1792 return _ogr.Layer_DeleteField(self, *args)
1793 1794
1795 - def ReorderField(self, *args):
1796 """ 1797 ReorderField(Layer self, int iOldFieldPos, int iNewFieldPos) -> OGRErr 1798 1799 OGRErr 1800 OGR_L_ReorderField(OGRLayerH hLayer, int iOldFieldPos, int 1801 iNewFieldPos) 1802 1803 Reorder an existing field on a layer. 1804 1805 This function is a convenience wrapper of OGR_L_ReorderFields() 1806 dedicated to move a single field. 1807 1808 You must use this to reorder existing fields on a real layer. 1809 Internally the OGRFeatureDefn for the layer will be updated to reflect 1810 the reordering of the fields. Applications should never modify the 1811 OGRFeatureDefn used by a layer directly. 1812 1813 This function should not be called while there are feature objects in 1814 existence that were obtained or created with the previous layer 1815 definition. 1816 1817 The field definition that was at initial position iOldFieldPos will be 1818 moved at position iNewFieldPos, and elements between will be shuffled 1819 accordingly. 1820 1821 For example, let suppose the fields were "0","1","2","3","4" 1822 initially. ReorderField(1, 3) will reorder them as 1823 "0","2","3","1","4". 1824 1825 Not all drivers support this function. You can query a layer to check 1826 if it supports it with the OLCReorderFields capability. Some drivers 1827 may only support this method while there are still no features in the 1828 layer. When it is supported, the existing features of the backing 1829 file/database should be updated accordingly. 1830 1831 This function is the same as the C++ method OGRLayer::ReorderField(). 1832 1833 Parameters: 1834 ----------- 1835 1836 hLayer: handle to the layer. 1837 1838 iOldFieldPos: previous position of the field to move. Must be in the 1839 range [0,GetFieldCount()-1]. 1840 1841 iNewFieldPos: new position of the field to move. Must be in the range 1842 [0,GetFieldCount()-1]. 1843 1844 OGRERR_NONE on success. 1845 1846 OGR 1.9.0 1847 """ 1848 return _ogr.Layer_ReorderField(self, *args)
1849 1850
1851 - def ReorderFields(self, *args):
1852 """ 1853 ReorderFields(Layer self, int nList) -> OGRErr 1854 1855 OGRErr 1856 OGR_L_ReorderFields(OGRLayerH hLayer, int *panMap) 1857 1858 Reorder all the fields of a layer. 1859 1860 You must use this to reorder existing fields on a real layer. 1861 Internally the OGRFeatureDefn for the layer will be updated to reflect 1862 the reordering of the fields. Applications should never modify the 1863 OGRFeatureDefn used by a layer directly. 1864 1865 This function should not be called while there are feature objects in 1866 existence that were obtained or created with the previous layer 1867 definition. 1868 1869 panMap is such that,for each field definition at position i after 1870 reordering, its position before reordering was panMap[i]. 1871 1872 For example, let suppose the fields were "0","1","2","3","4" 1873 initially. ReorderFields([0,2,3,1,4]) will reorder them as 1874 "0","2","3","1","4". 1875 1876 Not all drivers support this function. You can query a layer to check 1877 if it supports it with the OLCReorderFields capability. Some drivers 1878 may only support this method while there are still no features in the 1879 layer. When it is supported, the existing features of the backing 1880 file/database should be updated accordingly. 1881 1882 This function is the same as the C++ method OGRLayer::ReorderFields(). 1883 1884 Parameters: 1885 ----------- 1886 1887 hLayer: handle to the layer. 1888 1889 panMap: an array of GetLayerDefn()-> OGRFeatureDefn::GetFieldCount() 1890 elements which is a permutation of [0, GetLayerDefn()-> 1891 OGRFeatureDefn::GetFieldCount()-1]. 1892 1893 OGRERR_NONE on success. 1894 1895 OGR 1.9.0 1896 """ 1897 return _ogr.Layer_ReorderFields(self, *args)
1898 1899
1900 - def AlterFieldDefn(self, *args):
1901 """ 1902 AlterFieldDefn(Layer self, int iField, FieldDefn field_def, int nFlags) -> OGRErr 1903 1904 OGRErr 1905 OGR_L_AlterFieldDefn(OGRLayerH hLayer, int iField, OGRFieldDefnH 1906 hNewFieldDefn, int nFlags) 1907 1908 Alter the definition of an existing field on a layer. 1909 1910 You must use this to alter the definition of an existing field of a 1911 real layer. Internally the OGRFeatureDefn for the layer will be 1912 updated to reflect the altered field. Applications should never modify 1913 the OGRFeatureDefn used by a layer directly. 1914 1915 This function should not be called while there are feature objects in 1916 existence that were obtained or created with the previous layer 1917 definition. 1918 1919 Not all drivers support this function. You can query a layer to check 1920 if it supports it with the OLCAlterFieldDefn capability. Some drivers 1921 may only support this method while there are still no features in the 1922 layer. When it is supported, the existing features of the backing 1923 file/database should be updated accordingly. Some drivers might also 1924 not support all update flags. 1925 1926 This function is the same as the C++ method 1927 OGRLayer::AlterFieldDefn(). 1928 1929 Parameters: 1930 ----------- 1931 1932 hLayer: handle to the layer. 1933 1934 iField: index of the field whose definition must be altered. 1935 1936 hNewFieldDefn: new field definition 1937 1938 nFlags: combination of ALTER_NAME_FLAG, ALTER_TYPE_FLAG, 1939 ALTER_WIDTH_PRECISION_FLAG, ALTER_NULLABLE_FLAG and ALTER_DEFAULT_FLAG 1940 to indicate which of the name and/or type and/or width and precision 1941 fields and/or nullability from the new field definition must be taken 1942 into account. 1943 1944 OGRERR_NONE on success. 1945 1946 OGR 1.9.0 1947 """ 1948 return _ogr.Layer_AlterFieldDefn(self, *args)
1949 1950
1951 - def CreateGeomField(self, *args, **kwargs):
1952 """ 1953 CreateGeomField(Layer self, GeomFieldDefn field_def, int approx_ok=1) -> OGRErr 1954 1955 OGRErr 1956 OGR_L_CreateGeomField(OGRLayerH hLayer, OGRGeomFieldDefnH hField, int 1957 bApproxOK) 1958 1959 Create a new geometry field on a layer. 1960 1961 You must use this to create new geometry fields on a real layer. 1962 Internally the OGRFeatureDefn for the layer will be updated to reflect 1963 the new field. Applications should never modify the OGRFeatureDefn 1964 used by a layer directly. 1965 1966 This function should not be called while there are feature objects in 1967 existence that were obtained or created with the previous layer 1968 definition. 1969 1970 Not all drivers support this function. You can query a layer to check 1971 if it supports it with the OLCCreateField capability. Some drivers may 1972 only support this method while there are still no features in the 1973 layer. When it is supported, the existing features of the backing 1974 file/database should be updated accordingly. 1975 1976 Drivers may or may not support not-null constraints. If they support 1977 creating fields with not-null constraints, this is generally before 1978 creating any feature to the layer. 1979 1980 This function is the same as the C++ method OGRLayer::CreateField(). 1981 1982 Parameters: 1983 ----------- 1984 1985 hLayer: handle to the layer to write the field definition. 1986 1987 hField: handle of the geometry field definition to write to disk. 1988 1989 bApproxOK: If TRUE, the field may be created in a slightly different 1990 form depending on the limitations of the format driver. 1991 1992 OGRERR_NONE on success. 1993 1994 OGR 1.11 1995 """ 1996 return _ogr.Layer_CreateGeomField(self, *args, **kwargs)
1997 1998
1999 - def StartTransaction(self, *args):
2000 """ 2001 StartTransaction(Layer self) -> OGRErr 2002 2003 OGRErr 2004 OGR_L_StartTransaction(OGRLayerH hLayer) 2005 2006 For datasources which support transactions, StartTransaction creates a 2007 transaction. 2008 2009 If starting the transaction fails, will return OGRERR_FAILURE. 2010 Datasources which do not support transactions will always return 2011 OGRERR_NONE. 2012 2013 Note: as of GDAL 2.0, use of this API is discouraged when the dataset 2014 offers dataset level transaction with GDALDataset::StartTransaction(). 2015 The reason is that most drivers can only offer transactions at dataset 2016 level, and not layer level. Very few drivers really support 2017 transactions at layer scope. 2018 2019 This function is the same as the C++ method 2020 OGRLayer::StartTransaction(). 2021 2022 Parameters: 2023 ----------- 2024 2025 hLayer: handle to the layer 2026 2027 OGRERR_NONE on success. 2028 """ 2029 return _ogr.Layer_StartTransaction(self, *args)
2030 2031
2032 - def CommitTransaction(self, *args):
2033 """ 2034 CommitTransaction(Layer self) -> OGRErr 2035 2036 OGRErr 2037 OGR_L_CommitTransaction(OGRLayerH hLayer) 2038 2039 For datasources which support transactions, CommitTransaction commits 2040 a transaction. 2041 2042 If no transaction is active, or the commit fails, will return 2043 OGRERR_FAILURE. Datasources which do not support transactions will 2044 always return OGRERR_NONE. 2045 2046 This function is the same as the C++ method 2047 OGRLayer::CommitTransaction(). 2048 2049 Parameters: 2050 ----------- 2051 2052 hLayer: handle to the layer 2053 2054 OGRERR_NONE on success. 2055 """ 2056 return _ogr.Layer_CommitTransaction(self, *args)
2057 2058
2059 - def RollbackTransaction(self, *args):
2060 """ 2061 RollbackTransaction(Layer self) -> OGRErr 2062 2063 OGRErr 2064 OGR_L_RollbackTransaction(OGRLayerH hLayer) 2065 2066 For datasources which support transactions, RollbackTransaction will 2067 roll back a datasource to its state before the start of the current 2068 transaction. 2069 2070 If no transaction is active, or the rollback fails, will return 2071 OGRERR_FAILURE. Datasources which do not support transactions will 2072 always return OGRERR_NONE. 2073 2074 This function is the same as the C++ method 2075 OGRLayer::RollbackTransaction(). 2076 2077 Parameters: 2078 ----------- 2079 2080 hLayer: handle to the layer 2081 2082 OGRERR_NONE on success. 2083 """ 2084 return _ogr.Layer_RollbackTransaction(self, *args)
2085 2086
2087 - def FindFieldIndex(self, *args):
2088 """ 2089 FindFieldIndex(Layer self, char const * pszFieldName, int bExactMatch) -> int 2090 2091 int 2092 OGR_L_FindFieldIndex(OGRLayerH hLayer, const char *pszFieldName, int 2093 bExactMatch) 2094 2095 Find the index of field in a layer. 2096 2097 The returned number is the index of the field in the layers, or -1 if 2098 the field doesn't exist. 2099 2100 If bExactMatch is set to FALSE and the field doesn't exists in the 2101 given form the driver might apply some changes to make it match, like 2102 those it might do if the layer was created (eg. like LAUNDER in the 2103 OCI driver). 2104 2105 This method is the same as the C++ method OGRLayer::FindFieldIndex(). 2106 2107 field index, or -1 if the field doesn't exist 2108 """ 2109 return _ogr.Layer_FindFieldIndex(self, *args)
2110 2111
2112 - def GetSpatialRef(self, *args):
2113 """ 2114 GetSpatialRef(Layer self) -> SpatialReference 2115 2116 OGRSpatialReferenceH 2117 OGR_L_GetSpatialRef(OGRLayerH hLayer) 2118 2119 Fetch the spatial reference system for this layer. 2120 2121 The returned object is owned by the OGRLayer and should not be 2122 modified or freed by the application. 2123 2124 This function is the same as the C++ method OGRLayer::GetSpatialRef(). 2125 2126 Parameters: 2127 ----------- 2128 2129 hLayer: handle to the layer to get the spatial reference from. 2130 2131 spatial reference, or NULL if there isn't one. 2132 """ 2133 return _ogr.Layer_GetSpatialRef(self, *args)
2134 2135
2136 - def GetFeaturesRead(self, *args):
2137 """ 2138 GetFeaturesRead(Layer self) -> GIntBig 2139 2140 GIntBig 2141 OGR_L_GetFeaturesRead(OGRLayerH hLayer) 2142 """ 2143 return _ogr.Layer_GetFeaturesRead(self, *args)
2144 2145
2146 - def SetIgnoredFields(self, *args):
2147 """ 2148 SetIgnoredFields(Layer self, char const ** options) -> OGRErr 2149 2150 OGRErr 2151 OGR_L_SetIgnoredFields(OGRLayerH hLayer, const char **papszFields) 2152 2153 Set which fields can be omitted when retrieving features from the 2154 layer. 2155 2156 If the driver supports this functionality (testable using 2157 OLCIgnoreFields capability), it will not fetch the specified fields in 2158 subsequent calls to GetFeature() / GetNextFeature() and thus save some 2159 processing time and/or bandwidth. 2160 2161 Besides field names of the layers, the following special fields can be 2162 passed: "OGR_GEOMETRY" to ignore geometry and "OGR_STYLE" to 2163 ignore layer style. 2164 2165 By default, no fields are ignored. 2166 2167 This method is the same as the C++ method OGRLayer::SetIgnoredFields() 2168 2169 Parameters: 2170 ----------- 2171 2172 papszFields: an array of field names terminated by NULL item. If NULL 2173 is passed, the ignored list is cleared. 2174 2175 OGRERR_NONE if all field names have been resolved (even if the driver 2176 does not support this method) 2177 """ 2178 return _ogr.Layer_SetIgnoredFields(self, *args)
2179 2180
2181 - def Intersection(self, *args, **kwargs):
2182 """ 2183 Intersection(Layer self, Layer method_layer, Layer result_layer, char ** options=None, GDALProgressFunc callback=0, void * callback_data=None) -> OGRErr 2184 2185 OGRErr 2186 OGR_L_Intersection(OGRLayerH pLayerInput, OGRLayerH pLayerMethod, 2187 OGRLayerH pLayerResult, char **papszOptions, GDALProgressFunc 2188 pfnProgress, void *pProgressArg) 2189 2190 Intersection of two layers. 2191 2192 The result layer contains features whose geometries represent areas 2193 that are common between features in the input layer and in the method 2194 layer. The features in the result layer have attributes from both 2195 input and method layers. The schema of the result layer can be set by 2196 the user or, if it is empty, is initialized to contain all fields in 2197 the input and method layers. 2198 2199 If the schema of the result is set by user and contains fields that 2200 have the same name as a field in input and in method layer, then the 2201 attribute in the result feature will get the value from the feature of 2202 the method layer. 2203 2204 For best performance use the minimum amount of features in the method 2205 layer and copy it into a memory layer. 2206 2207 This method relies on GEOS support. Do not use unless the GEOS support 2208 is compiled in. The recognized list of options is : 2209 SKIP_FAILURES=YES/NO. Set it to YES to go on, even when a feature 2210 could not be inserted or a GEOS call failed. 2211 2212 PROMOTE_TO_MULTI=YES/NO. Set it to YES to convert Polygons into 2213 MultiPolygons, or LineStrings to MultiLineStrings. 2214 2215 INPUT_PREFIX=string. Set a prefix for the field names that will be 2216 created from the fields of the input layer. 2217 2218 METHOD_PREFIX=string. Set a prefix for the field names that will be 2219 created from the fields of the method layer. 2220 2221 USE_PREPARED_GEOMETRIES=YES/NO. Set to NO to not use prepared 2222 geometries to pretest intersection of features of method layer with 2223 features of this layer. 2224 2225 PRETEST_CONTAINMENT=YES/NO. Set to YES to pretest the containment of 2226 features of method layer within the features of this layer. This will 2227 speed up the method significantly in some cases. Requires that the 2228 prepared geometries are in effect. 2229 2230 KEEP_LOWER_DIMENSION_GEOMETRIES=YES/NO. Set to NO to skip result 2231 features with lower dimension geometry that would otherwise be added 2232 to the result layer. The default is to add but only if the result 2233 layer has an unknown geometry type. 2234 2235 This function is the same as the C++ method OGRLayer::Intersection(). 2236 2237 Parameters: 2238 ----------- 2239 2240 pLayerInput: the input layer. Should not be NULL. 2241 2242 pLayerMethod: the method layer. Should not be NULL. 2243 2244 pLayerResult: the layer where the features resulting from the 2245 operation are inserted. Should not be NULL. See above the note about 2246 the schema. 2247 2248 papszOptions: NULL terminated list of options (may be NULL). 2249 2250 pfnProgress: a GDALProgressFunc() compatible callback function for 2251 reporting progress or NULL. 2252 2253 pProgressArg: argument to be passed to pfnProgress. May be NULL. 2254 2255 an error code if there was an error or the execution was interrupted, 2256 OGRERR_NONE otherwise. 2257 2258 The first geometry field is always used. 2259 2260 OGR 1.10 2261 """ 2262 return _ogr.Layer_Intersection(self, *args, **kwargs)
2263 2264
2265 - def Union(self, *args, **kwargs):
2266 """ 2267 Union(Layer self, Layer method_layer, Layer result_layer, char ** options=None, GDALProgressFunc callback=0, void * callback_data=None) -> OGRErr 2268 2269 OGRErr OGR_L_Union(OGRLayerH 2270 pLayerInput, OGRLayerH pLayerMethod, OGRLayerH pLayerResult, char 2271 **papszOptions, GDALProgressFunc pfnProgress, void *pProgressArg) 2272 2273 Union of two layers. 2274 2275 The result layer contains features whose geometries represent areas 2276 that are in either in the input layer, in the method layer, or in 2277 both. The features in the result layer have attributes from both input 2278 and method layers. For features which represent areas that are only in 2279 the input or in the method layer the respective attributes have 2280 undefined values. The schema of the result layer can be set by the 2281 user or, if it is empty, is initialized to contain all fields in the 2282 input and method layers. 2283 2284 If the schema of the result is set by user and contains fields that 2285 have the same name as a field in input and in method layer, then the 2286 attribute in the result feature will get the value from the feature of 2287 the method layer (even if it is undefined). 2288 2289 For best performance use the minimum amount of features in the method 2290 layer and copy it into a memory layer. 2291 2292 This method relies on GEOS support. Do not use unless the GEOS support 2293 is compiled in. The recognized list of options is : 2294 SKIP_FAILURES=YES/NO. Set it to YES to go on, even when a feature 2295 could not be inserted or a GEOS call failed. 2296 2297 PROMOTE_TO_MULTI=YES/NO. Set it to YES to convert Polygons into 2298 MultiPolygons, or LineStrings to MultiLineStrings. 2299 2300 INPUT_PREFIX=string. Set a prefix for the field names that will be 2301 created from the fields of the input layer. 2302 2303 METHOD_PREFIX=string. Set a prefix for the field names that will be 2304 created from the fields of the method layer. 2305 2306 USE_PREPARED_GEOMETRIES=YES/NO. Set to NO to not use prepared 2307 geometries to pretest intersection of features of method layer with 2308 features of this layer. 2309 2310 KEEP_LOWER_DIMENSION_GEOMETRIES=YES/NO. Set to NO to skip result 2311 features with lower dimension geometry that would otherwise be added 2312 to the result layer. The default is to add but only if the result 2313 layer has an unknown geometry type. 2314 2315 This function is the same as the C++ method OGRLayer::Union(). 2316 2317 Parameters: 2318 ----------- 2319 2320 pLayerInput: the input layer. Should not be NULL. 2321 2322 pLayerMethod: the method layer. Should not be NULL. 2323 2324 pLayerResult: the layer where the features resulting from the 2325 operation are inserted. Should not be NULL. See above the note about 2326 the schema. 2327 2328 papszOptions: NULL terminated list of options (may be NULL). 2329 2330 pfnProgress: a GDALProgressFunc() compatible callback function for 2331 reporting progress or NULL. 2332 2333 pProgressArg: argument to be passed to pfnProgress. May be NULL. 2334 2335 an error code if there was an error or the execution was interrupted, 2336 OGRERR_NONE otherwise. 2337 2338 The first geometry field is always used. 2339 2340 OGR 1.10 2341 """ 2342 return _ogr.Layer_Union(self, *args, **kwargs)
2343 2344
2345 - def SymDifference(self, *args, **kwargs):
2346 """ 2347 SymDifference(Layer self, Layer method_layer, Layer result_layer, char ** options=None, GDALProgressFunc callback=0, void * callback_data=None) -> OGRErr 2348 2349 OGRErr 2350 OGR_L_SymDifference(OGRLayerH pLayerInput, OGRLayerH pLayerMethod, 2351 OGRLayerH pLayerResult, char **papszOptions, GDALProgressFunc 2352 pfnProgress, void *pProgressArg) 2353 2354 Symmetrical difference of two layers. 2355 2356 The result layer contains features whose geometries represent areas 2357 that are in either in the input layer or in the method layer but not 2358 in both. The features in the result layer have attributes from both 2359 input and method layers. For features which represent areas that are 2360 only in the input or in the method layer the respective attributes 2361 have undefined values. The schema of the result layer can be set by 2362 the user or, if it is empty, is initialized to contain all fields in 2363 the input and method layers. 2364 2365 If the schema of the result is set by user and contains fields that 2366 have the same name as a field in input and in method layer, then the 2367 attribute in the result feature will get the value from the feature of 2368 the method layer (even if it is undefined). 2369 2370 For best performance use the minimum amount of features in the method 2371 layer and copy it into a memory layer. 2372 2373 This method relies on GEOS support. Do not use unless the GEOS support 2374 is compiled in. The recognized list of options is : 2375 SKIP_FAILURES=YES/NO. Set it to YES to go on, even when a feature 2376 could not be inserted or a GEOS call failed. 2377 2378 PROMOTE_TO_MULTI=YES/NO. Set it to YES to convert Polygons into 2379 MultiPolygons, or LineStrings to MultiLineStrings. 2380 2381 INPUT_PREFIX=string. Set a prefix for the field names that will be 2382 created from the fields of the input layer. 2383 2384 METHOD_PREFIX=string. Set a prefix for the field names that will be 2385 created from the fields of the method layer. 2386 2387 This function is the same as the C++ method OGRLayer::SymDifference(). 2388 2389 Parameters: 2390 ----------- 2391 2392 pLayerInput: the input layer. Should not be NULL. 2393 2394 pLayerMethod: the method layer. Should not be NULL. 2395 2396 pLayerResult: the layer where the features resulting from the 2397 operation are inserted. Should not be NULL. See above the note about 2398 the schema. 2399 2400 papszOptions: NULL terminated list of options (may be NULL). 2401 2402 pfnProgress: a GDALProgressFunc() compatible callback function for 2403 reporting progress or NULL. 2404 2405 pProgressArg: argument to be passed to pfnProgress. May be NULL. 2406 2407 an error code if there was an error or the execution was interrupted, 2408 OGRERR_NONE otherwise. 2409 2410 The first geometry field is always used. 2411 2412 OGR 1.10 2413 """ 2414 return _ogr.Layer_SymDifference(self, *args, **kwargs)
2415 2416
2417 - def Identity(self, *args, **kwargs):
2418 """ 2419 Identity(Layer self, Layer method_layer, Layer result_layer, char ** options=None, GDALProgressFunc callback=0, void * callback_data=None) -> OGRErr 2420 2421 OGRErr OGR_L_Identity(OGRLayerH 2422 pLayerInput, OGRLayerH pLayerMethod, OGRLayerH pLayerResult, char 2423 **papszOptions, GDALProgressFunc pfnProgress, void *pProgressArg) 2424 2425 Identify the features of this layer with the ones from the identity 2426 layer. 2427 2428 The result layer contains features whose geometries represent areas 2429 that are in the input layer. The features in the result layer have 2430 attributes from both input and method layers. The schema of the result 2431 layer can be set by the user or, if it is empty, is initialized to 2432 contain all fields in input and method layers. 2433 2434 If the schema of the result is set by user and contains fields that 2435 have the same name as a field in input and in method layer, then the 2436 attribute in the result feature will get the value from the feature of 2437 the method layer (even if it is undefined). 2438 2439 For best performance use the minimum amount of features in the method 2440 layer and copy it into a memory layer. 2441 2442 This method relies on GEOS support. Do not use unless the GEOS support 2443 is compiled in. The recognized list of options is : 2444 SKIP_FAILURES=YES/NO. Set it to YES to go on, even when a feature 2445 could not be inserted or a GEOS call failed. 2446 2447 PROMOTE_TO_MULTI=YES/NO. Set it to YES to convert Polygons into 2448 MultiPolygons, or LineStrings to MultiLineStrings. 2449 2450 INPUT_PREFIX=string. Set a prefix for the field names that will be 2451 created from the fields of the input layer. 2452 2453 METHOD_PREFIX=string. Set a prefix for the field names that will be 2454 created from the fields of the method layer. 2455 2456 USE_PREPARED_GEOMETRIES=YES/NO. Set to NO to not use prepared 2457 geometries to pretest intersection of features of method layer with 2458 features of this layer. 2459 2460 KEEP_LOWER_DIMENSION_GEOMETRIES=YES/NO. Set to NO to skip result 2461 features with lower dimension geometry that would otherwise be added 2462 to the result layer. The default is to add but only if the result 2463 layer has an unknown geometry type. 2464 2465 This function is the same as the C++ method OGRLayer::Identity(). 2466 2467 Parameters: 2468 ----------- 2469 2470 pLayerInput: the input layer. Should not be NULL. 2471 2472 pLayerMethod: the method layer. Should not be NULL. 2473 2474 pLayerResult: the layer where the features resulting from the 2475 operation are inserted. Should not be NULL. See above the note about 2476 the schema. 2477 2478 papszOptions: NULL terminated list of options (may be NULL). 2479 2480 pfnProgress: a GDALProgressFunc() compatible callback function for 2481 reporting progress or NULL. 2482 2483 pProgressArg: argument to be passed to pfnProgress. May be NULL. 2484 2485 an error code if there was an error or the execution was interrupted, 2486 OGRERR_NONE otherwise. 2487 2488 The first geometry field is always used. 2489 2490 OGR 1.10 2491 """ 2492 return _ogr.Layer_Identity(self, *args, **kwargs)
2493 2494
2495 - def Update(self, *args, **kwargs):
2496 """ 2497 Update(Layer self, Layer method_layer, Layer result_layer, char ** options=None, GDALProgressFunc callback=0, void * callback_data=None) -> OGRErr 2498 2499 OGRErr OGR_L_Update(OGRLayerH 2500 pLayerInput, OGRLayerH pLayerMethod, OGRLayerH pLayerResult, char 2501 **papszOptions, GDALProgressFunc pfnProgress, void *pProgressArg) 2502 2503 Update this layer with features from the update layer. 2504 2505 The result layer contains features whose geometries represent areas 2506 that are either in the input layer or in the method layer. The 2507 features in the result layer have areas of the features of the method 2508 layer or those ares of the features of the input layer that are not 2509 covered by the method layer. The features of the result layer get 2510 their attributes from the input layer. The schema of the result layer 2511 can be set by the user or, if it is empty, is initialized to contain 2512 all fields in the input layer. 2513 2514 If the schema of the result is set by user and contains fields that 2515 have the same name as a field in the method layer, then the attribute 2516 in the result feature the originates from the method layer will get 2517 the value from the feature of the method layer. 2518 2519 For best performance use the minimum amount of features in the method 2520 layer and copy it into a memory layer. 2521 2522 This method relies on GEOS support. Do not use unless the GEOS support 2523 is compiled in. The recognized list of options is : 2524 SKIP_FAILURES=YES/NO. Set it to YES to go on, even when a feature 2525 could not be inserted or a GEOS call failed. 2526 2527 PROMOTE_TO_MULTI=YES/NO. Set it to YES to convert Polygons into 2528 MultiPolygons, or LineStrings to MultiLineStrings. 2529 2530 INPUT_PREFIX=string. Set a prefix for the field names that will be 2531 created from the fields of the input layer. 2532 2533 METHOD_PREFIX=string. Set a prefix for the field names that will be 2534 created from the fields of the method layer. 2535 2536 This function is the same as the C++ method OGRLayer::Update(). 2537 2538 Parameters: 2539 ----------- 2540 2541 pLayerInput: the input layer. Should not be NULL. 2542 2543 pLayerMethod: the method layer. Should not be NULL. 2544 2545 pLayerResult: the layer where the features resulting from the 2546 operation are inserted. Should not be NULL. See above the note about 2547 the schema. 2548 2549 papszOptions: NULL terminated list of options (may be NULL). 2550 2551 pfnProgress: a GDALProgressFunc() compatible callback function for 2552 reporting progress or NULL. 2553 2554 pProgressArg: argument to be passed to pfnProgress. May be NULL. 2555 2556 an error code if there was an error or the execution was interrupted, 2557 OGRERR_NONE otherwise. 2558 2559 The first geometry field is always used. 2560 2561 OGR 1.10 2562 """ 2563 return _ogr.Layer_Update(self, *args, **kwargs)
2564 2565
2566 - def Clip(self, *args, **kwargs):
2567 """ 2568 Clip(Layer self, Layer method_layer, Layer result_layer, char ** options=None, GDALProgressFunc callback=0, void * callback_data=None) -> OGRErr 2569 2570 OGRErr OGR_L_Clip(OGRLayerH pLayerInput, 2571 OGRLayerH pLayerMethod, OGRLayerH pLayerResult, char **papszOptions, 2572 GDALProgressFunc pfnProgress, void *pProgressArg) 2573 2574 Clip off areas that are not covered by the method layer. 2575 2576 The result layer contains features whose geometries represent areas 2577 that are in the input layer and in the method layer. The features in 2578 the result layer have the (possibly clipped) areas of features in the 2579 input layer and the attributes from the same features. The schema of 2580 the result layer can be set by the user or, if it is empty, is 2581 initialized to contain all fields in the input layer. 2582 2583 For best performance use the minimum amount of features in the method 2584 layer and copy it into a memory layer. 2585 2586 This method relies on GEOS support. Do not use unless the GEOS support 2587 is compiled in. The recognized list of options is : 2588 SKIP_FAILURES=YES/NO. Set it to YES to go on, even when a feature 2589 could not be inserted or a GEOS call failed. 2590 2591 PROMOTE_TO_MULTI=YES/NO. Set it to YES to convert Polygons into 2592 MultiPolygons, or LineStrings to MultiLineStrings. 2593 2594 INPUT_PREFIX=string. Set a prefix for the field names that will be 2595 created from the fields of the input layer. 2596 2597 METHOD_PREFIX=string. Set a prefix for the field names that will be 2598 created from the fields of the method layer. 2599 2600 This function is the same as the C++ method OGRLayer::Clip(). 2601 2602 Parameters: 2603 ----------- 2604 2605 pLayerInput: the input layer. Should not be NULL. 2606 2607 pLayerMethod: the method layer. Should not be NULL. 2608 2609 pLayerResult: the layer where the features resulting from the 2610 operation are inserted. Should not be NULL. See above the note about 2611 the schema. 2612 2613 papszOptions: NULL terminated list of options (may be NULL). 2614 2615 pfnProgress: a GDALProgressFunc() compatible callback function for 2616 reporting progress or NULL. 2617 2618 pProgressArg: argument to be passed to pfnProgress. May be NULL. 2619 2620 an error code if there was an error or the execution was interrupted, 2621 OGRERR_NONE otherwise. 2622 2623 The first geometry field is always used. 2624 2625 OGR 1.10 2626 """ 2627 return _ogr.Layer_Clip(self, *args, **kwargs)
2628 2629
2630 - def Erase(self, *args, **kwargs):
2631 """ 2632 Erase(Layer self, Layer method_layer, Layer result_layer, char ** options=None, GDALProgressFunc callback=0, void * callback_data=None) -> OGRErr 2633 2634 OGRErr OGR_L_Erase(OGRLayerH 2635 pLayerInput, OGRLayerH pLayerMethod, OGRLayerH pLayerResult, char 2636 **papszOptions, GDALProgressFunc pfnProgress, void *pProgressArg) 2637 2638 Remove areas that are covered by the method layer. 2639 2640 The result layer contains features whose geometries represent areas 2641 that are in the input layer but not in the method layer. The features 2642 in the result layer have attributes from the input layer. The schema 2643 of the result layer can be set by the user or, if it is empty, is 2644 initialized to contain all fields in the input layer. 2645 2646 For best performance use the minimum amount of features in the method 2647 layer and copy it into a memory layer. 2648 2649 This method relies on GEOS support. Do not use unless the GEOS support 2650 is compiled in. The recognized list of options is : 2651 SKIP_FAILURES=YES/NO. Set it to YES to go on, even when a feature 2652 could not be inserted or a GEOS call failed. 2653 2654 PROMOTE_TO_MULTI=YES/NO. Set it to YES to convert Polygons into 2655 MultiPolygons, or LineStrings to MultiLineStrings. 2656 2657 INPUT_PREFIX=string. Set a prefix for the field names that will be 2658 created from the fields of the input layer. 2659 2660 METHOD_PREFIX=string. Set a prefix for the field names that will be 2661 created from the fields of the method layer. 2662 2663 This function is the same as the C++ method OGRLayer::Erase(). 2664 2665 Parameters: 2666 ----------- 2667 2668 pLayerInput: the input layer. Should not be NULL. 2669 2670 pLayerMethod: the method layer. Should not be NULL. 2671 2672 pLayerResult: the layer where the features resulting from the 2673 operation are inserted. Should not be NULL. See above the note about 2674 the schema. 2675 2676 papszOptions: NULL terminated list of options (may be NULL). 2677 2678 pfnProgress: a GDALProgressFunc() compatible callback function for 2679 reporting progress or NULL. 2680 2681 pProgressArg: argument to be passed to pfnProgress. May be NULL. 2682 2683 an error code if there was an error or the execution was interrupted, 2684 OGRERR_NONE otherwise. 2685 2686 The first geometry field is always used. 2687 2688 OGR 1.10 2689 """ 2690 return _ogr.Layer_Erase(self, *args, **kwargs)
2691 2692
2693 - def GetStyleTable(self, *args):
2694 """ 2695 GetStyleTable(Layer self) -> StyleTable 2696 2697 OGRStyleTableH 2698 OGR_L_GetStyleTable(OGRLayerH hLayer) 2699 2700 Get style table. 2701 """ 2702 return _ogr.Layer_GetStyleTable(self, *args)
2703 2704
2705 - def SetStyleTable(self, *args):
2706 """ 2707 SetStyleTable(Layer self, StyleTable table) 2708 2709 void 2710 OGR_L_SetStyleTable(OGRLayerH hLayer, OGRStyleTableH hStyleTable) 2711 2712 Set style table. 2713 """ 2714 return _ogr.Layer_SetStyleTable(self, *args)
2715 2716
2717 - def Reference(self):
2718 "For backwards compatibility only." 2719 pass
2720
2721 - def Dereference(self):
2722 "For backwards compatibility only." 2723 pass
2724
2725 - def __len__(self):
2726 """Returns the number of features in the layer""" 2727 return self.GetFeatureCount()
2728 2729 # To avoid __len__ being called when testing boolean value 2730 # which can have side effects (#4758)
2731 - def __nonzero__(self):
2732 return True
2733 2734 # For Python 3 compat 2735 __bool__ = __nonzero__ 2736
2737 - def __getitem__(self, value):
2738 """Support list and slice -like access to the layer. 2739 layer[0] would return the first feature on the layer. 2740 layer[0:4] would return a list of the first four features.""" 2741 if isinstance(value, slice): 2742 import sys 2743 output = [] 2744 if value.stop == sys.maxint: 2745 #for an unending slice, sys.maxint is used 2746 #We need to stop before that or GDAL will write an 2747 ##error to stdout 2748 stop = len(self) - 1 2749 else: 2750 stop = value.stop 2751 for i in xrange(value.start, stop, value.step): 2752 feature = self.GetFeature(i) 2753 if feature: 2754 output.append(feature) 2755 else: 2756 return output 2757 return output 2758 if isinstance(value, int): 2759 if value > len(self) - 1: 2760 raise IndexError 2761 return self.GetFeature(value) 2762 else: 2763 raise TypeError("Input %s is not of IntType or SliceType" % type(value))
2764
2765 - def CreateFields(self, fields):
2766 """Create a list of fields on the Layer""" 2767 for i in fields: 2768 self.CreateField(i)
2769
2770 - def __iter__(self):
2771 self.ResetReading() 2772 while True: 2773 feature = self.GetNextFeature() 2774 if not feature: 2775 break 2776 yield feature
2777
2778 - def schema(self):
2779 output = [] 2780 defn = self.GetLayerDefn() 2781 for n in range(defn.GetFieldCount()): 2782 output.append(defn.GetFieldDefn(n)) 2783 return output
2784 schema = property(schema)
2785 2786 2787 Layer_swigregister = _ogr.Layer_swigregister 2788 Layer_swigregister(Layer) 2789
2790 -class Feature(_object):
2791 """Proxy of C++ OGRFeatureShadow class.""" 2792 2793 __swig_setmethods__ = {} 2794 __setattr__ = lambda self, name, value: _swig_setattr(self, Feature, name, value) 2795 __swig_getmethods__ = {} 2796 __getattr__ = lambda self, name: _swig_getattr(self, Feature, name) 2797 __repr__ = _swig_repr 2798 __swig_destroy__ = _ogr.delete_Feature 2799 __del__ = lambda self: None 2800
2801 - def __init__(self, *args, **kwargs):
2802 """__init__(OGRFeatureShadow self, FeatureDefn feature_def) -> Feature""" 2803 this = _ogr.new_Feature(*args, **kwargs) 2804 try: 2805 self.this.append(this) 2806 except __builtin__.Exception: 2807 self.this = this
2808
2809 - def GetDefnRef(self, *args):
2810 """ 2811 GetDefnRef(Feature self) -> FeatureDefn 2812 2813 OGRFeatureDefnH 2814 OGR_F_GetDefnRef(OGRFeatureH hFeat) 2815 2816 Fetch feature definition. 2817 2818 This function is the same as the C++ method OGRFeature::GetDefnRef(). 2819 2820 Parameters: 2821 ----------- 2822 2823 hFeat: handle to the feature to get the feature definition from. 2824 2825 an handle to the feature definition object on which feature depends. 2826 2827 """ 2828 return _ogr.Feature_GetDefnRef(self, *args)
2829 2830
2831 - def SetGeometry(self, *args):
2832 """ 2833 SetGeometry(Feature self, Geometry geom) -> OGRErr 2834 2835 OGRErr 2836 OGR_F_SetGeometry(OGRFeatureH hFeat, OGRGeometryH hGeom) 2837 2838 Set feature geometry. 2839 2840 This function updates the features geometry, and operate exactly as 2841 SetGeometryDirectly(), except that this function does not assume 2842 ownership of the passed geometry, but instead makes a copy of it. 2843 2844 This function is the same as the C++ OGRFeature::SetGeometry(). 2845 2846 This method has only an effect on the in-memory feature object. If 2847 this object comes from a layer and the modifications must be 2848 serialized back to the datasource, OGR_L_SetFeature() must be used 2849 afterwards. Or if this is a new feature, OGR_L_CreateFeature() must be 2850 used afterwards. 2851 2852 Parameters: 2853 ----------- 2854 2855 hFeat: handle to the feature on which new geometry is applied to. 2856 2857 hGeom: handle to the new geometry to apply to feature. 2858 2859 OGRERR_NONE if successful, or OGR_UNSUPPORTED_GEOMETRY_TYPE if the 2860 geometry type is illegal for the OGRFeatureDefn (checking not yet 2861 implemented). 2862 """ 2863 return _ogr.Feature_SetGeometry(self, *args)
2864 2865
2866 - def SetGeometryDirectly(self, *args):
2867 """ 2868 SetGeometryDirectly(Feature self, Geometry geom) -> OGRErr 2869 2870 OGRErr 2871 OGR_F_SetGeometryDirectly(OGRFeatureH hFeat, OGRGeometryH hGeom) 2872 2873 Set feature geometry. 2874 2875 This function updates the features geometry, and operate exactly as 2876 SetGeometry(), except that this function assumes ownership of the 2877 passed geometry (even in case of failure of that function). 2878 2879 This function is the same as the C++ method 2880 OGRFeature::SetGeometryDirectly. 2881 2882 This method has only an effect on the in-memory feature object. If 2883 this object comes from a layer and the modifications must be 2884 serialized back to the datasource, OGR_L_SetFeature() must be used 2885 afterwards. Or if this is a new feature, OGR_L_CreateFeature() must be 2886 used afterwards. 2887 2888 Parameters: 2889 ----------- 2890 2891 hFeat: handle to the feature on which to apply the geometry. 2892 2893 hGeom: handle to the new geometry to apply to feature. 2894 2895 OGRERR_NONE if successful, or OGR_UNSUPPORTED_GEOMETRY_TYPE if the 2896 geometry type is illegal for the OGRFeatureDefn (checking not yet 2897 implemented). 2898 """ 2899 return _ogr.Feature_SetGeometryDirectly(self, *args)
2900 2901
2902 - def GetGeometryRef(self, *args):
2903 """ 2904 GetGeometryRef(Feature self) -> Geometry 2905 2906 OGRGeometryH 2907 OGR_F_GetGeometryRef(OGRFeatureH hFeat) 2908 2909 Fetch an handle to feature geometry. 2910 2911 This function is essentially the same as the C++ method 2912 OGRFeature::GetGeometryRef() (the only difference is that this C 2913 function honours OGRGetNonLinearGeometriesEnabledFlag()) 2914 2915 Parameters: 2916 ----------- 2917 2918 hFeat: handle to the feature to get geometry from. 2919 2920 an handle to internal feature geometry. This object should not be 2921 modified. 2922 """ 2923 return _ogr.Feature_GetGeometryRef(self, *args)
2924 2925
2926 - def SetGeomField(self, *args):
2927 """ 2928 SetGeomField(Feature self, int iField, Geometry geom) -> OGRErr 2929 SetGeomField(Feature self, char const * field_name, Geometry geom) -> OGRErr 2930 2931 OGRErr 2932 OGR_F_SetGeomField(OGRFeatureH hFeat, int iField, OGRGeometryH hGeom) 2933 2934 Set feature geometry of a specified geometry field. 2935 2936 This function updates the features geometry, and operate exactly as 2937 SetGeometryDirectly(), except that this function does not assume 2938 ownership of the passed geometry, but instead makes a copy of it. 2939 2940 This function is the same as the C++ OGRFeature::SetGeomField(). 2941 2942 Parameters: 2943 ----------- 2944 2945 hFeat: handle to the feature on which new geometry is applied to. 2946 2947 iField: geometry field to set. 2948 2949 hGeom: handle to the new geometry to apply to feature. 2950 2951 OGRERR_NONE if successful, or OGR_UNSUPPORTED_GEOMETRY_TYPE if the 2952 geometry type is illegal for the OGRFeatureDefn (checking not yet 2953 implemented). 2954 """ 2955 return _ogr.Feature_SetGeomField(self, *args)
2956 2957
2958 - def SetGeomFieldDirectly(self, *args):
2959 """ 2960 SetGeomFieldDirectly(Feature self, int iField, Geometry geom) -> OGRErr 2961 SetGeomFieldDirectly(Feature self, char const * field_name, Geometry geom) -> OGRErr 2962 2963 OGRErr 2964 OGR_F_SetGeomFieldDirectly(OGRFeatureH hFeat, int iField, OGRGeometryH 2965 hGeom) 2966 2967 Set feature geometry of a specified geometry field. 2968 2969 This function updates the features geometry, and operate exactly as 2970 SetGeomField(), except that this function assumes ownership of the 2971 passed geometry (even in case of failure of that function). 2972 2973 This function is the same as the C++ method 2974 OGRFeature::SetGeomFieldDirectly. 2975 2976 Parameters: 2977 ----------- 2978 2979 hFeat: handle to the feature on which to apply the geometry. 2980 2981 iField: geometry field to set. 2982 2983 hGeom: handle to the new geometry to apply to feature. 2984 2985 OGRERR_NONE if successful, or OGRERR_FAILURE if the index is invalid, 2986 or OGR_UNSUPPORTED_GEOMETRY_TYPE if the geometry type is illegal for 2987 the OGRFeatureDefn (checking not yet implemented). 2988 2989 GDAL 1.11 2990 """ 2991 return _ogr.Feature_SetGeomFieldDirectly(self, *args)
2992 2993
2994 - def GetGeomFieldRef(self, *args):
2995 """ 2996 GetGeomFieldRef(Feature self, int iField) -> Geometry 2997 GetGeomFieldRef(Feature self, char const * field_name) -> Geometry 2998 2999 OGRGeometryH 3000 OGR_F_GetGeomFieldRef(OGRFeatureH hFeat, int iField) 3001 3002 Fetch an handle to feature geometry. 3003 3004 This function is the same as the C++ method 3005 OGRFeature::GetGeomFieldRef(). 3006 3007 Parameters: 3008 ----------- 3009 3010 hFeat: handle to the feature to get geometry from. 3011 3012 iField: geometry field to get. 3013 3014 an handle to internal feature geometry. This object should not be 3015 modified. 3016 3017 GDAL 1.11 3018 """ 3019 return _ogr.Feature_GetGeomFieldRef(self, *args)
3020 3021
3022 - def Clone(self, *args):
3023 """ 3024 Clone(Feature self) -> Feature 3025 3026 OGRFeatureH OGR_F_Clone(OGRFeatureH 3027 hFeat) 3028 3029 Duplicate feature. 3030 3031 The newly created feature is owned by the caller, and will have its 3032 own reference to the OGRFeatureDefn. 3033 3034 This function is the same as the C++ method OGRFeature::Clone(). 3035 3036 Parameters: 3037 ----------- 3038 3039 hFeat: handle to the feature to clone. 3040 3041 an handle to the new feature, exactly matching this feature. 3042 """ 3043 return _ogr.Feature_Clone(self, *args)
3044 3045
3046 - def Equal(self, *args):
3047 """ 3048 Equal(Feature self, Feature feature) -> bool 3049 3050 int OGR_F_Equal(OGRFeatureH hFeat, 3051 OGRFeatureH hOtherFeat) 3052 3053 Test if two features are the same. 3054 3055 Two features are considered equal if the share them (handle equality) 3056 same OGRFeatureDefn, have the same field values, and the same geometry 3057 (as tested by OGR_G_Equal()) as well as the same feature id. 3058 3059 This function is the same as the C++ method OGRFeature::Equal(). 3060 3061 Parameters: 3062 ----------- 3063 3064 hFeat: handle to one of the feature. 3065 3066 hOtherFeat: handle to the other feature to test this one against. 3067 3068 TRUE if they are equal, otherwise FALSE. 3069 """ 3070 return _ogr.Feature_Equal(self, *args)
3071 3072
3073 - def GetFieldCount(self, *args):
3074 """ 3075 GetFieldCount(Feature self) -> int 3076 3077 int 3078 OGR_F_GetFieldCount(OGRFeatureH hFeat) 3079 3080 Fetch number of fields on this feature This will always be the same as 3081 the field count for the OGRFeatureDefn. 3082 3083 This function is the same as the C++ method 3084 OGRFeature::GetFieldCount(). 3085 3086 Parameters: 3087 ----------- 3088 3089 hFeat: handle to the feature to get the fields count from. 3090 3091 count of fields. 3092 """ 3093 return _ogr.Feature_GetFieldCount(self, *args)
3094 3095
3096 - def GetFieldDefnRef(self, *args):
3097 """ 3098 GetFieldDefnRef(Feature self, int id) -> FieldDefn 3099 GetFieldDefnRef(Feature self, char const * field_name) -> FieldDefn 3100 3101 OGRFieldDefnH 3102 OGR_F_GetFieldDefnRef(OGRFeatureH hFeat, int i) 3103 3104 Fetch definition for this field. 3105 3106 This function is the same as the C++ method 3107 OGRFeature::GetFieldDefnRef(). 3108 3109 Parameters: 3110 ----------- 3111 3112 hFeat: handle to the feature on which the field is found. 3113 3114 i: the field to fetch, from 0 to GetFieldCount()-1. 3115 3116 an handle to the field definition (from the OGRFeatureDefn). This is 3117 an internal reference, and should not be deleted or modified. 3118 """ 3119 return _ogr.Feature_GetFieldDefnRef(self, *args)
3120 3121
3122 - def GetGeomFieldCount(self, *args):
3123 """ 3124 GetGeomFieldCount(Feature self) -> int 3125 3126 int 3127 OGR_F_GetGeomFieldCount(OGRFeatureH hFeat) 3128 3129 Fetch number of geometry fields on this feature This will always be 3130 the same as the geometry field count for the OGRFeatureDefn. 3131 3132 This function is the same as the C++ method 3133 OGRFeature::GetGeomFieldCount(). 3134 3135 Parameters: 3136 ----------- 3137 3138 hFeat: handle to the feature to get the geometry fields count from. 3139 3140 count of geometry fields. 3141 3142 GDAL 1.11 3143 """ 3144 return _ogr.Feature_GetGeomFieldCount(self, *args)
3145 3146
3147 - def GetGeomFieldDefnRef(self, *args):
3148 """ 3149 GetGeomFieldDefnRef(Feature self, int id) -> GeomFieldDefn 3150 GetGeomFieldDefnRef(Feature self, char const * field_name) -> GeomFieldDefn 3151 3152 OGRGeomFieldDefnH 3153 OGR_F_GetGeomFieldDefnRef(OGRFeatureH hFeat, int i) 3154 3155 Fetch definition for this geometry field. 3156 3157 This function is the same as the C++ method 3158 OGRFeature::GetGeomFieldDefnRef(). 3159 3160 Parameters: 3161 ----------- 3162 3163 hFeat: handle to the feature on which the field is found. 3164 3165 i: the field to fetch, from 0 to GetGeomFieldCount()-1. 3166 3167 an handle to the field definition (from the OGRFeatureDefn). This is 3168 an internal reference, and should not be deleted or modified. 3169 3170 GDAL 1.11 3171 """ 3172 return _ogr.Feature_GetGeomFieldDefnRef(self, *args)
3173 3174
3175 - def GetFieldAsString(self, *args):
3176 """ 3177 GetFieldAsString(Feature self, int id) -> char const 3178 GetFieldAsString(Feature self, char const * field_name) -> char const * 3179 3180 const char* 3181 OGR_F_GetFieldAsString(OGRFeatureH hFeat, int iField) 3182 3183 Fetch field value as a string. 3184 3185 OFTReal and OFTInteger fields will be translated to string using 3186 sprintf(), but not necessarily using the established formatting rules. 3187 Other field types, or errors will result in a return value of zero. 3188 3189 This function is the same as the C++ method 3190 OGRFeature::GetFieldAsString(). 3191 3192 Parameters: 3193 ----------- 3194 3195 hFeat: handle to the feature that owned the field. 3196 3197 iField: the field to fetch, from 0 to GetFieldCount()-1. 3198 3199 the field value. This string is internal, and should not be modified, 3200 or freed. Its lifetime may be very brief. 3201 """ 3202 return _ogr.Feature_GetFieldAsString(self, *args)
3203 3204
3205 - def GetFieldAsInteger(self, *args):
3206 """ 3207 GetFieldAsInteger(Feature self, int id) -> int 3208 GetFieldAsInteger(Feature self, char const * field_name) -> int 3209 3210 int 3211 OGR_F_GetFieldAsInteger(OGRFeatureH hFeat, int iField) 3212 3213 Fetch field value as integer. 3214 3215 OFTString features will be translated using atoi(). OFTReal fields 3216 will be cast to integer. Other field types, or errors will result in a 3217 return value of zero. 3218 3219 This function is the same as the C++ method 3220 OGRFeature::GetFieldAsInteger(). 3221 3222 Parameters: 3223 ----------- 3224 3225 hFeat: handle to the feature that owned the field. 3226 3227 iField: the field to fetch, from 0 to GetFieldCount()-1. 3228 3229 the field value. 3230 """ 3231 return _ogr.Feature_GetFieldAsInteger(self, *args)
3232 3233
3234 - def GetFieldAsInteger64(self, *args):
3235 """ 3236 GetFieldAsInteger64(Feature self, int id) -> GIntBig 3237 GetFieldAsInteger64(Feature self, char const * field_name) -> GIntBig 3238 3239 GIntBig 3240 OGR_F_GetFieldAsInteger64(OGRFeatureH hFeat, int iField) 3241 3242 Fetch field value as integer 64 bit. 3243 3244 OFTInteger are promoted to 64 bit. OFTString features will be 3245 translated using CPLAtoGIntBig(). OFTReal fields will be cast to 3246 integer. Other field types, or errors will result in a return value of 3247 zero. 3248 3249 This function is the same as the C++ method 3250 OGRFeature::GetFieldAsInteger64(). 3251 3252 Parameters: 3253 ----------- 3254 3255 hFeat: handle to the feature that owned the field. 3256 3257 iField: the field to fetch, from 0 to GetFieldCount()-1. 3258 3259 the field value. 3260 3261 GDAL 2.0 3262 """ 3263 return _ogr.Feature_GetFieldAsInteger64(self, *args)
3264 3265
3266 - def GetFieldAsDouble(self, *args):
3267 """ 3268 GetFieldAsDouble(Feature self, int id) -> double 3269 GetFieldAsDouble(Feature self, char const * field_name) -> double 3270 3271 double 3272 OGR_F_GetFieldAsDouble(OGRFeatureH hFeat, int iField) 3273 3274 Fetch field value as a double. 3275 3276 OFTString features will be translated using CPLAtof(). OFTInteger 3277 fields will be cast to double. Other field types, or errors will 3278 result in a return value of zero. 3279 3280 This function is the same as the C++ method 3281 OGRFeature::GetFieldAsDouble(). 3282 3283 Parameters: 3284 ----------- 3285 3286 hFeat: handle to the feature that owned the field. 3287 3288 iField: the field to fetch, from 0 to GetFieldCount()-1. 3289 3290 the field value. 3291 """ 3292 return _ogr.Feature_GetFieldAsDouble(self, *args)
3293 3294
3295 - def GetFieldAsDateTime(self, *args):
3296 """ 3297 GetFieldAsDateTime(Feature self, int id) 3298 GetFieldAsDateTime(Feature self, char const * field_name) 3299 3300 int 3301 OGR_F_GetFieldAsDateTime(OGRFeatureH hFeat, int iField, int *pnYear, 3302 int *pnMonth, int *pnDay, int *pnHour, int *pnMinute, int *pnSecond, 3303 int *pnTZFlag) 3304 3305 Fetch field value as date and time. 3306 3307 Currently this method only works for OFTDate, OFTTime and OFTDateTime 3308 fields. 3309 3310 This function is the same as the C++ method 3311 OGRFeature::GetFieldAsDateTime(). 3312 3313 Parameters: 3314 ----------- 3315 3316 hFeat: handle to the feature that owned the field. 3317 3318 iField: the field to fetch, from 0 to GetFieldCount()-1. 3319 3320 pnYear: (including century) 3321 3322 pnMonth: (1-12) 3323 3324 pnDay: (1-31) 3325 3326 pnHour: (0-23) 3327 3328 pnMinute: (0-59) 3329 3330 pnSecond: (0-59) 3331 3332 pnTZFlag: (0=unknown, 1=localtime, 100=GMT, see data model for 3333 details) 3334 3335 TRUE on success or FALSE on failure. 3336 3337 See: Use OGR_F_GetFieldAsDateTimeEx() for second with millisecond 3338 accuracy. 3339 """ 3340 return _ogr.Feature_GetFieldAsDateTime(self, *args)
3341 3342
3343 - def GetFieldAsIntegerList(self, *args):
3344 """ 3345 GetFieldAsIntegerList(Feature self, int id) 3346 GetFieldAsIntegerList(Feature self, char const * field_name) 3347 3348 const int* 3349 OGR_F_GetFieldAsIntegerList(OGRFeatureH hFeat, int iField, int 3350 *pnCount) 3351 3352 Fetch field value as a list of integers. 3353 3354 Currently this function only works for OFTIntegerList fields. 3355 3356 This function is the same as the C++ method 3357 OGRFeature::GetFieldAsIntegerList(). 3358 3359 Parameters: 3360 ----------- 3361 3362 hFeat: handle to the feature that owned the field. 3363 3364 iField: the field to fetch, from 0 to GetFieldCount()-1. 3365 3366 pnCount: an integer to put the list count (number of integers) into. 3367 3368 the field value. This list is internal, and should not be modified, or 3369 freed. Its lifetime may be very brief. If *pnCount is zero on return 3370 the returned pointer may be NULL or non-NULL. 3371 """ 3372 return _ogr.Feature_GetFieldAsIntegerList(self, *args)
3373 3374
3375 - def GetFieldAsInteger64List(self, *args):
3376 """ 3377 GetFieldAsInteger64List(Feature self, int id) 3378 3379 const GIntBig* 3380 OGR_F_GetFieldAsInteger64List(OGRFeatureH hFeat, int iField, int 3381 *pnCount) 3382 3383 Fetch field value as a list of 64 bit integers. 3384 3385 Currently this function only works for OFTInteger64List fields. 3386 3387 This function is the same as the C++ method 3388 OGRFeature::GetFieldAsInteger64List(). 3389 3390 Parameters: 3391 ----------- 3392 3393 hFeat: handle to the feature that owned the field. 3394 3395 iField: the field to fetch, from 0 to GetFieldCount()-1. 3396 3397 pnCount: an integer to put the list count (number of integers) into. 3398 3399 the field value. This list is internal, and should not be modified, or 3400 freed. Its lifetime may be very brief. If *pnCount is zero on return 3401 the returned pointer may be NULL or non-NULL. 3402 3403 GDAL 2.0 3404 """ 3405 return _ogr.Feature_GetFieldAsInteger64List(self, *args)
3406 3407
3408 - def GetFieldAsDoubleList(self, *args):
3409 """ 3410 GetFieldAsDoubleList(Feature self, int id) 3411 GetFieldAsDoubleList(Feature self, char const * field_name) 3412 3413 const double* 3414 OGR_F_GetFieldAsDoubleList(OGRFeatureH hFeat, int iField, int 3415 *pnCount) 3416 3417 Fetch field value as a list of doubles. 3418 3419 Currently this function only works for OFTRealList fields. 3420 3421 This function is the same as the C++ method 3422 OGRFeature::GetFieldAsDoubleList(). 3423 3424 Parameters: 3425 ----------- 3426 3427 hFeat: handle to the feature that owned the field. 3428 3429 iField: the field to fetch, from 0 to GetFieldCount()-1. 3430 3431 pnCount: an integer to put the list count (number of doubles) into. 3432 3433 the field value. This list is internal, and should not be modified, or 3434 freed. Its lifetime may be very brief. If *pnCount is zero on return 3435 the returned pointer may be NULL or non-NULL. 3436 """ 3437 return _ogr.Feature_GetFieldAsDoubleList(self, *args)
3438 3439
3440 - def GetFieldAsStringList(self, *args):
3441 """ 3442 GetFieldAsStringList(Feature self, int id) -> char ** 3443 3444 char** 3445 OGR_F_GetFieldAsStringList(OGRFeatureH hFeat, int iField) 3446 3447 Fetch field value as a list of strings. 3448 3449 Currently this method only works for OFTStringList fields. 3450 3451 The returned list is terminated by a NULL pointer. The number of 3452 elements can also be calculated using CSLCount(). 3453 3454 This function is the same as the C++ method 3455 OGRFeature::GetFieldAsStringList(). 3456 3457 Parameters: 3458 ----------- 3459 3460 hFeat: handle to the feature that owned the field. 3461 3462 iField: the field to fetch, from 0 to GetFieldCount()-1. 3463 3464 the field value. This list is internal, and should not be modified, or 3465 freed. Its lifetime may be very brief. 3466 """ 3467 return _ogr.Feature_GetFieldAsStringList(self, *args)
3468 3469
3470 - def GetFieldAsBinary(self, *args):
3471 """ 3472 GetFieldAsBinary(Feature self, int id) -> OGRErr 3473 GetFieldAsBinary(Feature self, char const * field_name) -> OGRErr 3474 3475 GByte* 3476 OGR_F_GetFieldAsBinary(OGRFeatureH hFeat, int iField, int *pnBytes) 3477 3478 Fetch field value as binary. 3479 3480 This method only works for OFTBinary and OFTString fields. 3481 3482 This function is the same as the C++ method 3483 OGRFeature::GetFieldAsBinary(). 3484 3485 Parameters: 3486 ----------- 3487 3488 hFeat: handle to the feature that owned the field. 3489 3490 iField: the field to fetch, from 0 to GetFieldCount()-1. 3491 3492 pnBytes: location to place count of bytes returned. 3493 3494 the field value. This list is internal, and should not be modified, or 3495 freed. Its lifetime may be very brief. 3496 """ 3497 return _ogr.Feature_GetFieldAsBinary(self, *args)
3498 3499
3500 - def IsFieldSet(self, *args):
3501 """ 3502 IsFieldSet(Feature self, int id) -> bool 3503 IsFieldSet(Feature self, char const * field_name) -> bool 3504 3505 int OGR_F_IsFieldSet(OGRFeatureH 3506 hFeat, int iField) 3507 3508 Test if a field has ever been assigned a value or not. 3509 3510 This function is the same as the C++ method OGRFeature::IsFieldSet(). 3511 3512 Parameters: 3513 ----------- 3514 3515 hFeat: handle to the feature on which the field is. 3516 3517 iField: the field to test. 3518 3519 TRUE if the field has been set, otherwise false. 3520 """ 3521 return _ogr.Feature_IsFieldSet(self, *args)
3522 3523
3524 - def IsFieldNull(self, *args):
3525 """ 3526 IsFieldNull(Feature self, int id) -> bool 3527 IsFieldNull(Feature self, char const * field_name) -> bool 3528 3529 int OGR_F_IsFieldNull(OGRFeatureH 3530 hFeat, int iField) 3531 3532 Test if a field is null. 3533 3534 This function is the same as the C++ method OGRFeature::IsFieldNull(). 3535 3536 Parameters: 3537 ----------- 3538 3539 hFeat: handle to the feature on which the field is. 3540 3541 iField: the field to test. 3542 3543 TRUE if the field is null, otherwise false. 3544 3545 GDAL 2.2 3546 """ 3547 return _ogr.Feature_IsFieldNull(self, *args)
3548 3549
3550 - def IsFieldSetAndNotNull(self, *args):
3551 """ 3552 IsFieldSetAndNotNull(Feature self, int id) -> bool 3553 IsFieldSetAndNotNull(Feature self, char const * field_name) -> bool 3554 3555 int 3556 OGR_F_IsFieldSetAndNotNull(OGRFeatureH hFeat, int iField) 3557 3558 Test if a field is set and not null. 3559 3560 This function is the same as the C++ method 3561 OGRFeature::IsFieldSetAndNotNull(). 3562 3563 Parameters: 3564 ----------- 3565 3566 hFeat: handle to the feature on which the field is. 3567 3568 iField: the field to test. 3569 3570 TRUE if the field is set and not null, otherwise false. 3571 3572 GDAL 2.2 3573 """ 3574 return _ogr.Feature_IsFieldSetAndNotNull(self, *args)
3575 3576
3577 - def GetFieldIndex(self, *args):
3578 """ 3579 GetFieldIndex(Feature self, char const * field_name) -> int 3580 3581 int 3582 OGR_F_GetFieldIndex(OGRFeatureH hFeat, const char *pszName) 3583 3584 Fetch the field index given field name. 3585 3586 This is a cover for the OGRFeatureDefn::GetFieldIndex() method. 3587 3588 This function is the same as the C++ method 3589 OGRFeature::GetFieldIndex(). 3590 3591 Parameters: 3592 ----------- 3593 3594 hFeat: handle to the feature on which the field is found. 3595 3596 pszName: the name of the field to search for. 3597 3598 the field index, or -1 if no matching field is found. 3599 """ 3600 return _ogr.Feature_GetFieldIndex(self, *args)
3601 3602
3603 - def GetGeomFieldIndex(self, *args):
3604 """ 3605 GetGeomFieldIndex(Feature self, char const * field_name) -> int 3606 3607 int 3608 OGR_F_GetGeomFieldIndex(OGRFeatureH hFeat, const char *pszName) 3609 3610 Fetch the geometry field index given geometry field name. 3611 3612 This is a cover for the OGRFeatureDefn::GetGeomFieldIndex() method. 3613 3614 This function is the same as the C++ method 3615 OGRFeature::GetGeomFieldIndex(). 3616 3617 Parameters: 3618 ----------- 3619 3620 hFeat: handle to the feature on which the geometry field is found. 3621 3622 pszName: the name of the geometry field to search for. 3623 3624 the geometry field index, or -1 if no matching geometry field is 3625 found. 3626 3627 GDAL 1.11 3628 """ 3629 return _ogr.Feature_GetGeomFieldIndex(self, *args)
3630 3631
3632 - def GetFID(self, *args):
3633 """ 3634 GetFID(Feature self) -> GIntBig 3635 3636 GIntBig OGR_F_GetFID(OGRFeatureH 3637 hFeat) 3638 3639 Get feature identifier. 3640 3641 This function is the same as the C++ method OGRFeature::GetFID(). 3642 Note: since GDAL 2.0, this method returns a GIntBig (previously a 3643 long) 3644 3645 Parameters: 3646 ----------- 3647 3648 hFeat: handle to the feature from which to get the feature 3649 identifier. 3650 3651 feature id or OGRNullFID if none has been assigned. 3652 """ 3653 return _ogr.Feature_GetFID(self, *args)
3654 3655
3656 - def SetFID(self, *args):
3657 """ 3658 SetFID(Feature self, GIntBig fid) -> OGRErr 3659 3660 OGRErr OGR_F_SetFID(OGRFeatureH hFeat, 3661 GIntBig nFID) 3662 3663 Set the feature identifier. 3664 3665 For specific types of features this operation may fail on illegal 3666 features ids. Generally it always succeeds. Feature ids should be 3667 greater than or equal to zero, with the exception of OGRNullFID (-1) 3668 indicating that the feature id is unknown. 3669 3670 This function is the same as the C++ method OGRFeature::SetFID(). 3671 3672 Parameters: 3673 ----------- 3674 3675 hFeat: handle to the feature to set the feature id to. 3676 3677 nFID: the new feature identifier value to assign. 3678 3679 On success OGRERR_NONE, or on failure some other value. 3680 """ 3681 return _ogr.Feature_SetFID(self, *args)
3682 3683
3684 - def DumpReadable(self, *args):
3685 """ 3686 DumpReadable(Feature self) 3687 3688 void 3689 OGR_F_DumpReadable(OGRFeatureH hFeat, FILE *fpOut) 3690 3691 Dump this feature in a human readable form. 3692 3693 This dumps the attributes, and geometry; however, it doesn't 3694 definition information (other than field types and names), nor does it 3695 report the geometry spatial reference system. 3696 3697 This function is the same as the C++ method 3698 OGRFeature::DumpReadable(). 3699 3700 Parameters: 3701 ----------- 3702 3703 hFeat: handle to the feature to dump. 3704 3705 fpOut: the stream to write to, such as strout. 3706 """ 3707 return _ogr.Feature_DumpReadable(self, *args)
3708 3709
3710 - def UnsetField(self, *args):
3711 """ 3712 UnsetField(Feature self, int id) 3713 UnsetField(Feature self, char const * field_name) 3714 3715 void OGR_F_UnsetField(OGRFeatureH 3716 hFeat, int iField) 3717 3718 Clear a field, marking it as unset. 3719 3720 This function is the same as the C++ method OGRFeature::UnsetField(). 3721 3722 Parameters: 3723 ----------- 3724 3725 hFeat: handle to the feature on which the field is. 3726 3727 iField: the field to unset. 3728 """ 3729 return _ogr.Feature_UnsetField(self, *args)
3730 3731
3732 - def SetFieldNull(self, *args):
3733 """ 3734 SetFieldNull(Feature self, int id) 3735 SetFieldNull(Feature self, char const * field_name) 3736 3737 void 3738 OGR_F_SetFieldNull(OGRFeatureH hFeat, int iField) 3739 3740 Clear a field, marking it as null. 3741 3742 This function is the same as the C++ method 3743 OGRFeature::SetFieldNull(). 3744 3745 Parameters: 3746 ----------- 3747 3748 hFeat: handle to the feature on which the field is. 3749 3750 iField: the field to set to null. 3751 3752 GDAL 2.2 3753 """ 3754 return _ogr.Feature_SetFieldNull(self, *args)
3755 3756
3757 - def SetFieldInteger64(self, *args):
3758 """ 3759 SetFieldInteger64(Feature self, int id, GIntBig value) 3760 3761 void 3762 OGR_F_SetFieldInteger64(OGRFeatureH hFeat, int iField, GIntBig nValue) 3763 3764 Set field to 64 bit integer value. 3765 3766 OFTInteger, OFTInteger64 and OFTReal fields will be set directly. 3767 OFTString fields will be assigned a string representation of the 3768 value, but not necessarily taking into account formatting constraints 3769 on this field. Other field types may be unaffected. 3770 3771 This function is the same as the C++ method OGRFeature::SetField(). 3772 3773 This method has only an effect on the in-memory feature object. If 3774 this object comes from a layer and the modifications must be 3775 serialized back to the datasource, OGR_L_SetFeature() must be used 3776 afterwards. Or if this is a new feature, OGR_L_CreateFeature() must be 3777 used afterwards. 3778 3779 Parameters: 3780 ----------- 3781 3782 hFeat: handle to the feature that owned the field. 3783 3784 iField: the field to fetch, from 0 to GetFieldCount()-1. 3785 3786 nValue: the value to assign. 3787 3788 GDAL 2.0 3789 """ 3790 return _ogr.Feature_SetFieldInteger64(self, *args)
3791 3792
3793 - def SetField(self, *args):
3794 """ 3795 SetField(Feature self, int id, char const * value) 3796 SetField(Feature self, char const * field_name, char const * value) 3797 SetField(Feature self, int id, double value) 3798 SetField(Feature self, char const * field_name, double value) 3799 SetField(Feature self, int id, int year, int month, int day, int hour, int minute, float second, int tzflag) 3800 SetField(Feature self, char const * field_name, int year, int month, int day, int hour, int minute, float second, int tzflag) 3801 """ 3802 return _ogr.Feature_SetField(self, *args)
3803 3804
3805 - def SetFieldIntegerList(self, *args):
3806 """ 3807 SetFieldIntegerList(Feature self, int id, int nList) 3808 3809 void 3810 OGR_F_SetFieldIntegerList(OGRFeatureH hFeat, int iField, int nCount, 3811 const int *panValues) 3812 3813 Set field to list of integers value. 3814 3815 This function currently on has an effect of OFTIntegerList, 3816 OFTInteger64List and OFTRealList fields. 3817 3818 This function is the same as the C++ method OGRFeature::SetField(). 3819 3820 This method has only an effect on the in-memory feature object. If 3821 this object comes from a layer and the modifications must be 3822 serialized back to the datasource, OGR_L_SetFeature() must be used 3823 afterwards. Or if this is a new feature, OGR_L_CreateFeature() must be 3824 used afterwards. 3825 3826 Parameters: 3827 ----------- 3828 3829 hFeat: handle to the feature that owned the field. 3830 3831 iField: the field to set, from 0 to GetFieldCount()-1. 3832 3833 nCount: the number of values in the list being assigned. 3834 3835 panValues: the values to assign. 3836 """ 3837 return _ogr.Feature_SetFieldIntegerList(self, *args)
3838 3839
3840 - def SetFieldInteger64List(self, *args):
3841 """ 3842 SetFieldInteger64List(Feature self, int id, int nList) 3843 3844 void 3845 OGR_F_SetFieldInteger64List(OGRFeatureH hFeat, int iField, int nCount, 3846 const GIntBig *panValues) 3847 3848 Set field to list of 64 bit integers value. 3849 3850 This function currently on has an effect of OFTIntegerList, 3851 OFTInteger64List and OFTRealList fields. 3852 3853 This function is the same as the C++ method OGRFeature::SetField(). 3854 3855 This method has only an effect on the in-memory feature object. If 3856 this object comes from a layer and the modifications must be 3857 serialized back to the datasource, OGR_L_SetFeature() must be used 3858 afterwards. Or if this is a new feature, OGR_L_CreateFeature() must be 3859 used afterwards. 3860 3861 Parameters: 3862 ----------- 3863 3864 hFeat: handle to the feature that owned the field. 3865 3866 iField: the field to set, from 0 to GetFieldCount()-1. 3867 3868 nCount: the number of values in the list being assigned. 3869 3870 panValues: the values to assign. 3871 3872 GDAL 2.0 3873 """ 3874 return _ogr.Feature_SetFieldInteger64List(self, *args)
3875 3876
3877 - def SetFieldDoubleList(self, *args):
3878 """ 3879 SetFieldDoubleList(Feature self, int id, int nList) 3880 3881 void 3882 OGR_F_SetFieldDoubleList(OGRFeatureH hFeat, int iField, int nCount, 3883 const double *padfValues) 3884 3885 Set field to list of doubles value. 3886 3887 This function currently on has an effect of OFTIntegerList, 3888 OFTInteger64List, OFTRealList fields. 3889 3890 This function is the same as the C++ method OGRFeature::SetField(). 3891 3892 This method has only an effect on the in-memory feature object. If 3893 this object comes from a layer and the modifications must be 3894 serialized back to the datasource, OGR_L_SetFeature() must be used 3895 afterwards. Or if this is a new feature, OGR_L_CreateFeature() must be 3896 used afterwards. 3897 3898 Parameters: 3899 ----------- 3900 3901 hFeat: handle to the feature that owned the field. 3902 3903 iField: the field to set, from 0 to GetFieldCount()-1. 3904 3905 nCount: the number of values in the list being assigned. 3906 3907 padfValues: the values to assign. 3908 """ 3909 return _ogr.Feature_SetFieldDoubleList(self, *args)
3910 3911
3912 - def SetFieldStringList(self, *args):
3913 """ 3914 SetFieldStringList(Feature self, int id, char ** pList) 3915 3916 void 3917 OGR_F_SetFieldStringList(OGRFeatureH hFeat, int iField, CSLConstList 3918 papszValues) 3919 3920 Set field to list of strings value. 3921 3922 This function currently on has an effect of OFTStringList fields. 3923 3924 This function is the same as the C++ method OGRFeature::SetField(). 3925 3926 This method has only an effect on the in-memory feature object. If 3927 this object comes from a layer and the modifications must be 3928 serialized back to the datasource, OGR_L_SetFeature() must be used 3929 afterwards. Or if this is a new feature, OGR_L_CreateFeature() must be 3930 used afterwards. 3931 3932 Parameters: 3933 ----------- 3934 3935 hFeat: handle to the feature that owned the field. 3936 3937 iField: the field to set, from 0 to GetFieldCount()-1. 3938 3939 papszValues: the values to assign. List of NUL-terminated string, 3940 ending with a NULL pointer. 3941 """ 3942 return _ogr.Feature_SetFieldStringList(self, *args)
3943 3944
3945 - def SetFieldBinaryFromHexString(self, *args):
3946 """ 3947 SetFieldBinaryFromHexString(Feature self, int id, char const * pszValue) 3948 SetFieldBinaryFromHexString(Feature self, char const * field_name, char const * pszValue) 3949 """ 3950 return _ogr.Feature_SetFieldBinaryFromHexString(self, *args)
3951 3952
3953 - def SetFrom(self, *args, **kwargs):
3954 """ 3955 SetFrom(Feature self, Feature other, int forgiving=1) -> OGRErr 3956 3957 OGRErr OGR_F_SetFrom(OGRFeatureH 3958 hFeat, OGRFeatureH hOtherFeat, int bForgiving) 3959 3960 Set one feature from another. 3961 3962 Overwrite the contents of this feature from the geometry and 3963 attributes of another. The hOtherFeature does not need to have the 3964 same OGRFeatureDefn. Field values are copied by corresponding field 3965 names. Field types do not have to exactly match. OGR_F_SetField*() 3966 function conversion rules will be applied as needed. 3967 3968 This function is the same as the C++ method OGRFeature::SetFrom(). 3969 3970 Parameters: 3971 ----------- 3972 3973 hFeat: handle to the feature to set to. 3974 3975 hOtherFeat: handle to the feature from which geometry, and field 3976 values will be copied. 3977 3978 bForgiving: TRUE if the operation should continue despite lacking 3979 output fields matching some of the source fields. 3980 3981 OGRERR_NONE if the operation succeeds, even if some values are not 3982 transferred, otherwise an error code. 3983 """ 3984 return _ogr.Feature_SetFrom(self, *args, **kwargs)
3985 3986
3987 - def SetFromWithMap(self, *args):
3988 """ 3989 SetFromWithMap(Feature self, Feature other, int forgiving, int nList) -> OGRErr 3990 3991 OGRErr 3992 OGR_F_SetFromWithMap(OGRFeatureH hFeat, OGRFeatureH hOtherFeat, int 3993 bForgiving, const int *panMap) 3994 3995 Set one feature from another. 3996 3997 Overwrite the contents of this feature from the geometry and 3998 attributes of another. The hOtherFeature does not need to have the 3999 same OGRFeatureDefn. Field values are copied according to the provided 4000 indices map. Field types do not have to exactly match. 4001 OGR_F_SetField*() function conversion rules will be applied as needed. 4002 This is more efficient than OGR_F_SetFrom() in that this doesn't 4003 lookup the fields by their names. Particularly useful when the field 4004 names don't match. 4005 4006 This function is the same as the C++ method OGRFeature::SetFrom(). 4007 4008 Parameters: 4009 ----------- 4010 4011 hFeat: handle to the feature to set to. 4012 4013 hOtherFeat: handle to the feature from which geometry, and field 4014 values will be copied. 4015 4016 panMap: Array of the indices of the destination feature's fields 4017 stored at the corresponding index of the source feature's fields. A 4018 value of -1 should be used to ignore the source's field. The array 4019 should not be NULL and be as long as the number of fields in the 4020 source feature. 4021 4022 bForgiving: TRUE if the operation should continue despite lacking 4023 output fields matching some of the source fields. 4024 4025 OGRERR_NONE if the operation succeeds, even if some values are not 4026 transferred, otherwise an error code. 4027 """ 4028 return _ogr.Feature_SetFromWithMap(self, *args)
4029 4030
4031 - def GetStyleString(self, *args):
4032 """ 4033 GetStyleString(Feature self) -> char const * 4034 4035 const char* 4036 OGR_F_GetStyleString(OGRFeatureH hFeat) 4037 4038 Fetch style string for this feature. 4039 4040 Set the OGR Feature Style Specification for details on the format of 4041 this string, and ogr_featurestyle.h for services available to parse 4042 it. 4043 4044 This function is the same as the C++ method 4045 OGRFeature::GetStyleString(). 4046 4047 Parameters: 4048 ----------- 4049 4050 hFeat: handle to the feature to get the style from. 4051 4052 a reference to a representation in string format, or NULL if there 4053 isn't one. 4054 """ 4055 return _ogr.Feature_GetStyleString(self, *args)
4056 4057
4058 - def SetStyleString(self, *args):
4059 """ 4060 SetStyleString(Feature self, char const * the_string) 4061 4062 void 4063 OGR_F_SetStyleString(OGRFeatureH hFeat, const char *pszStyle) 4064 4065 Set feature style string. 4066 4067 This method operate exactly as OGR_F_SetStyleStringDirectly() except 4068 that it does not assume ownership of the passed string, but instead 4069 makes a copy of it. 4070 4071 This function is the same as the C++ method 4072 OGRFeature::SetStyleString(). 4073 4074 Parameters: 4075 ----------- 4076 4077 hFeat: handle to the feature to set style to. 4078 4079 pszStyle: the style string to apply to this feature, cannot be NULL. 4080 4081 """ 4082 return _ogr.Feature_SetStyleString(self, *args)
4083 4084
4085 - def GetFieldType(self, *args):
4086 """ 4087 GetFieldType(Feature self, int id) -> OGRFieldType 4088 GetFieldType(Feature self, char const * field_name) -> OGRFieldType 4089 """ 4090 return _ogr.Feature_GetFieldType(self, *args)
4091 4092
4093 - def Validate(self, *args):
4094 """ 4095 Validate(Feature self, int flags, int bEmitError=True) -> int 4096 4097 int OGR_F_Validate(OGRFeatureH 4098 hFeat, int nValidateFlags, int bEmitError) 4099 4100 Validate that a feature meets constraints of its schema. 4101 4102 The scope of test is specified with the nValidateFlags parameter. 4103 4104 Regarding OGR_F_VAL_WIDTH, the test is done assuming the string width 4105 must be interpreted as the number of UTF-8 characters. Some drivers 4106 might interpret the width as the number of bytes instead. So this test 4107 is rather conservative (if it fails, then it will fail for all 4108 interpretations). 4109 4110 This function is the same as the C++ method OGRFeature::Validate(). 4111 4112 Parameters: 4113 ----------- 4114 4115 hFeat: handle to the feature to validate. 4116 4117 nValidateFlags: OGR_F_VAL_ALL or combination of OGR_F_VAL_NULL, 4118 OGR_F_VAL_GEOM_TYPE, OGR_F_VAL_WIDTH and 4119 OGR_F_VAL_ALLOW_NULL_WHEN_DEFAULT with '|' operator 4120 4121 bEmitError: TRUE if a CPLError() must be emitted when a check fails 4122 4123 TRUE if all enabled validation tests pass. 4124 4125 GDAL 2.0 4126 """ 4127 return _ogr.Feature_Validate(self, *args)
4128 4129
4130 - def FillUnsetWithDefault(self, *args):
4131 """ 4132 FillUnsetWithDefault(Feature self, int bNotNullableOnly=False, char ** options=None) 4133 4134 void 4135 OGR_F_FillUnsetWithDefault(OGRFeatureH hFeat, int bNotNullableOnly, 4136 char **papszOptions) 4137 4138 Fill unset fields with default values that might be defined. 4139 4140 This function is the same as the C++ method 4141 OGRFeature::FillUnsetWithDefault(). 4142 4143 Parameters: 4144 ----------- 4145 4146 hFeat: handle to the feature. 4147 4148 bNotNullableOnly: if we should fill only unset fields with a not-null 4149 constraint. 4150 4151 papszOptions: unused currently. Must be set to NULL. 4152 4153 GDAL 2.0 4154 """ 4155 return _ogr.Feature_FillUnsetWithDefault(self, *args)
4156 4157
4158 - def GetNativeData(self, *args):
4159 """ 4160 GetNativeData(Feature self) -> char const * 4161 4162 const char* 4163 OGR_F_GetNativeData(OGRFeatureH hFeat) 4164 4165 Returns the native data for the feature. 4166 4167 The native data is the representation in a "natural" form that comes 4168 from the driver that created this feature, or that is aimed at an 4169 output driver. The native data may be in different format, which is 4170 indicated by OGR_F_GetNativeMediaType(). 4171 4172 Note that most drivers do not support storing the native data in the 4173 feature object, and if they do, generally the NATIVE_DATA open option 4174 must be passed at dataset opening. 4175 4176 The "native data" does not imply it is something more performant or 4177 powerful than what can be obtained with the rest of the API, but it 4178 may be useful in round-tripping scenarios where some characteristics 4179 of the underlying format are not captured otherwise by the OGR 4180 abstraction. 4181 4182 This function is the same as the C++ method 4183 OGRFeature::GetNativeData(). 4184 4185 Parameters: 4186 ----------- 4187 4188 hFeat: handle to the feature. 4189 4190 a string with the native data, or NULL if there is none. 4191 4192 GDAL 2.1 4193 4194 See: 4195 https://trac.osgeo.org/gdal/wiki/rfc60_improved_roundtripping_in_ogr 4196 4197 """ 4198 return _ogr.Feature_GetNativeData(self, *args)
4199 4200
4201 - def GetNativeMediaType(self, *args):
4202 """ 4203 GetNativeMediaType(Feature self) -> char const * 4204 4205 const char* 4206 OGR_F_GetNativeMediaType(OGRFeatureH hFeat) 4207 4208 Returns the native media type for the feature. 4209 4210 The native media type is the identifier for the format of the native 4211 data. It follows the IANA RFC 2045 4212 (seehttps://en.wikipedia.org/wiki/Media_type), e.g. 4213 "application/vnd.geo+json" for JSon. 4214 4215 This function is the same as the C function 4216 OGR_F_GetNativeMediaType(). 4217 4218 Parameters: 4219 ----------- 4220 4221 hFeat: handle to the feature. 4222 4223 a string with the native media type, or NULL if there is none. 4224 4225 GDAL 2.1 4226 4227 See: 4228 https://trac.osgeo.org/gdal/wiki/rfc60_improved_roundtripping_in_ogr 4229 4230 """ 4231 return _ogr.Feature_GetNativeMediaType(self, *args)
4232 4233
4234 - def SetNativeData(self, *args):
4235 """ 4236 SetNativeData(Feature self, char const * nativeData) 4237 4238 void 4239 OGR_F_SetNativeData(OGRFeatureH hFeat, const char *pszNativeData) 4240 4241 Sets the native data for the feature. 4242 4243 The native data is the representation in a "natural" form that comes 4244 from the driver that created this feature, or that is aimed at an 4245 output driver. The native data may be in different format, which is 4246 indicated by OGR_F_GetNativeMediaType(). 4247 4248 This function is the same as the C++ method 4249 OGRFeature::SetNativeData(). 4250 4251 Parameters: 4252 ----------- 4253 4254 hFeat: handle to the feature. 4255 4256 pszNativeData: a string with the native data, or NULL if there is 4257 none. 4258 4259 GDAL 2.1 4260 4261 See: 4262 https://trac.osgeo.org/gdal/wiki/rfc60_improved_roundtripping_in_ogr 4263 4264 """ 4265 return _ogr.Feature_SetNativeData(self, *args)
4266 4267
4268 - def SetNativeMediaType(self, *args):
4269 """ 4270 SetNativeMediaType(Feature self, char const * nativeMediaType) 4271 4272 void 4273 OGR_F_SetNativeMediaType(OGRFeatureH hFeat, const char 4274 *pszNativeMediaType) 4275 4276 Sets the native media type for the feature. 4277 4278 The native media type is the identifier for the format of the native 4279 data. It follows the IANA RFC 2045 4280 (seehttps://en.wikipedia.org/wiki/Media_type), e.g. 4281 "application/vnd.geo+json" for JSon. 4282 4283 This function is the same as the C++ method 4284 OGRFeature::SetNativeMediaType(). 4285 4286 Parameters: 4287 ----------- 4288 4289 hFeat: handle to the feature. 4290 4291 pszNativeMediaType: a string with the native media type, or NULL if 4292 there is none. 4293 4294 GDAL 2.1 4295 4296 See: 4297 https://trac.osgeo.org/gdal/wiki/rfc60_improved_roundtripping_in_ogr 4298 4299 """ 4300 return _ogr.Feature_SetNativeMediaType(self, *args)
4301 4302
4303 - def SetFieldString(self, *args):
4304 """ 4305 SetFieldString(Feature self, int id, char const * value) 4306 4307 void 4308 OGR_F_SetFieldString(OGRFeatureH hFeat, int iField, const char 4309 *pszValue) 4310 4311 Set field to string value. 4312 4313 OFTInteger fields will be set based on an atoi() conversion of the 4314 string. OFTInteger64 fields will be set based on an CPLAtoGIntBig() 4315 conversion of the string. OFTReal fields will be set based on an 4316 CPLAtof() conversion of the string. Other field types may be 4317 unaffected. 4318 4319 This function is the same as the C++ method OGRFeature::SetField(). 4320 4321 This method has only an effect on the in-memory feature object. If 4322 this object comes from a layer and the modifications must be 4323 serialized back to the datasource, OGR_L_SetFeature() must be used 4324 afterwards. Or if this is a new feature, OGR_L_CreateFeature() must be 4325 used afterwards. 4326 4327 Parameters: 4328 ----------- 4329 4330 hFeat: handle to the feature that owned the field. 4331 4332 iField: the field to fetch, from 0 to GetFieldCount()-1. 4333 4334 pszValue: the value to assign. 4335 """ 4336 return _ogr.Feature_SetFieldString(self, *args)
4337 4338
4339 - def Reference(self):
4340 pass
4341
4342 - def Dereference(self):
4343 pass
4344
4345 - def Destroy(self):
4346 "Once called, self has effectively been destroyed. Do not access. For backwards compatibility only" 4347 _ogr.delete_Feature(self) 4348 self.thisown = 0
4349
4350 - def __cmp__(self, other):
4351 """Compares a feature to another for equality""" 4352 return self.Equal(other)
4353
4354 - def __copy__(self):
4355 return self.Clone()
4356 4357 # This makes it possible to fetch fields in the form "feature.area". 4358 # This has some risk of name collisions.
4359 - def __getattr__(self, key):
4360 """Returns the values of fields by the given name""" 4361 if key == 'this': 4362 return self.__dict__[key] 4363 4364 idx = self.GetFieldIndex(key) 4365 if idx < 0: 4366 idx = self.GetGeomFieldIndex(key) 4367 if idx < 0: 4368 raise AttributeError(key) 4369 else: 4370 return self.GetGeomFieldRef(idx) 4371 else: 4372 return self.GetField(idx)
4373 4374 # This makes it possible to set fields in the form "feature.area". 4375 # This has some risk of name collisions.
4376 - def __setattr__(self, key, value):
4377 """Set the values of fields by the given name""" 4378 if key == 'this' or key == 'thisown': 4379 self.__dict__[key] = value 4380 else: 4381 idx = self.GetFieldIndex(key) 4382 if idx != -1: 4383 self.SetField2(idx, value) 4384 else: 4385 idx = self.GetGeomFieldIndex(key) 4386 if idx != -1: 4387 self.SetGeomField(idx, value) 4388 else: 4389 self.__dict__[key] = value
4390 4391 # This makes it possible to fetch fields in the form "feature['area']".
4392 - def __getitem__(self, key):
4393 """Returns the values of fields by the given name / field_index""" 4394 if isinstance(key, (str, type(u''))): 4395 fld_index = self.GetFieldIndex(key) 4396 else: 4397 fld_index = key 4398 if key == self.GetFieldCount(): 4399 raise IndexError 4400 if fld_index < 0: 4401 if isinstance(key, (str, type(u''))): 4402 fld_index = self.GetGeomFieldIndex(key) 4403 if fld_index < 0: 4404 raise KeyError("Illegal field requested in GetField()") 4405 else: 4406 return self.GetGeomFieldRef(fld_index) 4407 else: 4408 return self.GetField(fld_index)
4409 4410 # This makes it possible to set fields in the form "feature['area'] = 123".
4411 - def __setitem__(self, key, value):
4412 """Returns the value of a field by field name / index""" 4413 if isinstance(key, (str, type(u''))): 4414 fld_index = self.GetFieldIndex(key) 4415 else: 4416 fld_index = key 4417 if key == self.GetFieldCount(): 4418 raise IndexError 4419 if fld_index < 0: 4420 if isinstance(key, (str, type(u''))): 4421 fld_index = self.GetGeomFieldIndex(key) 4422 if fld_index < 0: 4423 raise KeyError("Illegal field requested in SetField()") 4424 else: 4425 return self.SetGeomField(fld_index, value) 4426 else: 4427 return self.SetField2(fld_index, value)
4428
4429 - def GetField(self, fld_index):
4430 if isinstance(fld_index, (str, type(u''))): 4431 fld_index = self.GetFieldIndex(fld_index) 4432 if (fld_index < 0) or (fld_index > self.GetFieldCount()): 4433 raise KeyError("Illegal field requested in GetField()") 4434 if not (self.IsFieldSet(fld_index)) or self.IsFieldNull(fld_index): 4435 return None 4436 fld_type = self.GetFieldType(fld_index) 4437 if fld_type == OFTInteger: 4438 return self.GetFieldAsInteger(fld_index) 4439 if fld_type == OFTInteger64: 4440 return self.GetFieldAsInteger64(fld_index) 4441 if fld_type == OFTReal: 4442 return self.GetFieldAsDouble(fld_index) 4443 if fld_type == OFTStringList: 4444 return self.GetFieldAsStringList(fld_index) 4445 if fld_type == OFTIntegerList: 4446 return self.GetFieldAsIntegerList(fld_index) 4447 if fld_type == OFTInteger64List: 4448 return self.GetFieldAsInteger64List(fld_index) 4449 if fld_type == OFTRealList: 4450 return self.GetFieldAsDoubleList(fld_index) 4451 ## if fld_type == OFTDateTime or fld_type == OFTDate or fld_type == OFTTime: 4452 # return self.GetFieldAsDate(fld_index) 4453 # default to returning as a string. Should we add more types? 4454 try: 4455 return self.GetFieldAsString(fld_index) 4456 except: 4457 # For Python3 on non-UTF8 strings 4458 return self.GetFieldAsBinary(fld_index)
4459 4460 # With several override, SWIG cannot dispatch automatically unicode strings 4461 # to the right implementation, so we have to do it at hand
4462 - def SetField(self, *args):
4463 """ 4464 SetField(self, int id, char value) 4465 SetField(self, char name, char value) 4466 SetField(self, int id, int value) 4467 SetField(self, char name, int value) 4468 SetField(self, int id, double value) 4469 SetField(self, char name, double value) 4470 SetField(self, int id, int year, int month, int day, int hour, int minute, 4471 int second, int tzflag) 4472 SetField(self, char name, int year, int month, int day, int hour, 4473 int minute, int second, int tzflag)