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