我刚开始在 Qgis GIS 软件中使用 Python Console。我想使用 Qgis 中存在的 Python 控制台添加一个多边形。我试图结合从几个文档中找到的代码。feat.setGeometry(QgsGeometry.fromPolygonXY([points]) 上面这行代码说“表达式不能包含赋值,也许你的意思是“==”警告来了。akcakent表可以在Qgis中编辑。错误在哪里我写的代码?你能帮我吗?
layers = QgsProject.instance().mapLayersByName('akcakent')
layer = QgsVectorLayer(layers[0].dataProvider().dataSourceUri(), '', 'ogr')
caps = layer.dataProvider().capabilities()
if caps & QgsVectorDataProvider.AddFeatures:
feat = QgsFeature(layer.fields())
feat.setAttribute(
[124067558, 637773842, 18, 616, 150216, 'KIRŞEHİR', 'AKÇAKENT', 'YAYLAÖZÜ', 120, 18,
'CEMALETTİN', 'YILMAZ', 11, 996, '15.10.2019 00:00:00', '15.10.2029 00:00:00', 'CEVİZ',
'YAYLAÖZÜ 120/18'])
points = [QgsPointXY(34.053635541202, 39.59019921065601),
QgsPointXY(34.053837103237, 39.59035923430099),
QgsPointXY(34.053332895004, 39.591078697114966),
QgsPointXY(34.052752319765, 39.590607693827991),
QgsPointXY(34.052868265722, 39.590297176571),
QgsPointXY(34.052315209862, 39.589806031292),
QgsPointXY(34.052372452976, 39.589741092592988),
QgsPointXY(34.053635541202, 39.59019921065601),
QgsPointXY(34.053635541202, 39.59019921065601)]
feat.setGeometry(QgsGeometry.fromPolygonXY([points])
(res, outFeats) = layer.dataProvider().addFeatures([feat])