本文整理汇总了Python中qgis.core.QgsFeature.deleteAttribute方法的典型用法代码示例。如果您正苦于以下问题:Python QgsFeature.deleteAttribute方法的具体用法?Python QgsFeature.deleteAttribute怎么用?Python QgsFeature.deleteAttribute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类qgis.core.QgsFeature
的用法示例。
在下文中一共展示了QgsFeature.deleteAttribute方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_DeleteAttribute
# 需要导入模块: from qgis.core import QgsFeature [as 别名]
# 或者: from qgis.core.QgsFeature import deleteAttribute [as 别名]
def test_DeleteAttribute(self):
feat = QgsFeature()
feat.addAttribute(1, "text")
feat.deleteAttribute(1)
myCount = len(feat.attributeMap())
myExpectedCount = 0
myMessage = '\nExpected: %s\nGot: %s' % (myExpectedCount, myCount)
assert myCount == myExpectedCount, myMessage
示例2: test_DeleteAttribute
# 需要导入模块: from qgis.core import QgsFeature [as 别名]
# 或者: from qgis.core.QgsFeature import deleteAttribute [as 别名]
def test_DeleteAttribute(self):
feat = QgsFeature()
feat.initAttributes(3)
feat[0] = "text1"
feat[1] = "text2"
feat[2] = "text3"
feat.deleteAttribute(1)
myAttrs = [feat[0], feat[1]]
myExpectedAttrs = ["text1", "text3"]
myMessage = "\nExpected: %s\nGot: %s" % (str(myExpectedAttrs), str(myAttrs))
assert myAttrs == myExpectedAttrs, myMessage
示例3: test_DeleteAttribute
# 需要导入模块: from qgis.core import QgsFeature [as 别名]
# 或者: from qgis.core.QgsFeature import deleteAttribute [as 别名]
def test_DeleteAttribute(self):
feat = QgsFeature()
feat.initAttributes(3)
feat[0] = QVariant("text1")
feat[1] = QVariant("text2")
feat[2] = QVariant("text3")
feat.deleteAttribute(1)
myAttrs = [ str(feat[0].toString()), str(feat[1].toString()) ]
myExpectedAttrs = [ "text1", "text3" ]
myMessage = '\nExpected: %s\nGot: %s' % (str(myExpectedAttrs), str(myAttrs))
assert myAttrs == myExpectedAttrs, myMessage
示例4: test_DeleteAttributeByName
# 需要导入模块: from qgis.core import QgsFeature [as 别名]
# 或者: from qgis.core.QgsFeature import deleteAttribute [as 别名]
def test_DeleteAttributeByName(self):
fields = QgsFields()
field1 = QgsField("my_field")
fields.append(field1)
field2 = QgsField("my_field2")
fields.append(field2)
feat = QgsFeature(fields)
feat.initAttributes(2)
feat[0] = "text1"
feat[1] = "text2"
with self.assertRaises(KeyError):
feat.deleteAttribute("not present")
self.assertTrue(feat.deleteAttribute("my_field"))
self.assertEqual(feat.attributes(), ["text2"])