我有以下列表(从 numpy 列表转换为 QgsPoint),并希望为该列表中的每个单独数组创建层。有解决办法吗?
我将 numpy 数组转换为 QgsPoint:
for a in numpy_object_array_new: #this is the list
temp = []
for j in range(a.shape[0]):
temp.append(QgsPoint(a[j][0], a[j][1]))
flood_points_test_new.append(temp)
因此我得到:
len(numpy_object_array_new)= 4
len(numpy_object_array_new[0]) = 10
len(numpy_object_array_new[1]) = 15 etc...
numpy_object_array_new[0] = [<QgsPoint: Point (4619064.44109291024506092 2812031.86061978759244084)>, <QgsPoint: Point (4619068.87150056380778551 2812569.46716303238645196)>, ... >]
并且想为 my_list[0], my_list[1] ... my_list[i] 中的每个数组获取层不幸的是,以下方法不起作用,因为它是一个列表:
layer_HQ100 = QgsVectorLayer('Point?crs=epsg:3035', 'HQ_100 Point' , "memory")
pr_HQ100 = layer_HQ100.dataProvider()
pt_HQ100 = QgsFeature()
for i in range(len(polyline)):
pt_HQ100.setGeometry(polyline[i])
pr_HQ100.addFeatures([pt_HQ100])
layer_HQ100.updateExtents()
QgsProject.instance().addMapLayer(layer_HQ100)
有什么解决办法吗?