当前位置: 首页>>代码示例>>Python>>正文


Python QgsFeature.deleteAttribute方法代码示例

本文整理汇总了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        
开发者ID:homann,项目名称:Quantum-GIS,代码行数:10,代码来源:test_qgsfeature.py

示例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
开发者ID:ndavid,项目名称:QGIS,代码行数:13,代码来源:test_qgsfeature.py

示例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
开发者ID:geonux,项目名称:Quantum-GIS,代码行数:13,代码来源:test_qgsfeature.py

示例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"])
开发者ID:ndavid,项目名称:QGIS,代码行数:17,代码来源:test_qgsfeature.py


注:本文中的qgis.core.QgsFeature.deleteAttribute方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。