Curso de Programación QGIS 3 con Python (3/5)

preview_player
Показать описание

Vídeo producido por el Gabinete de Tele-Educación de la Universidad Politécnica de Madrid
Рекомендации по теме
Комментарии
Автор

Llegue unos años tarde, pero felicitaciones por tan espectacular explicación. Gracias!

dulcineacaffy
Автор

Qué hace la linea de código features.append(feature) ???
gracias!!

alvaromateos
Автор

El programa que de python me da errores al ejecutar:
Traceback (most recent call last):
File "C:\PROGRA~1\QGIS3~1.6\apps\Python37\lib\code.py", line 90, in runcode
exec(code, self.locals)
File "<input>", line 1, in <module>
File "<string>", line 19, in <module>
File "<string>", line 9, in createLayer
TypeError: 'QgsFields' object is not callable


El programa....
def createLayer(n):
Layer=QgsVectorLayer("Point?crs=EPSG:4326", "capa", "memory")

Layer.updateFields()
feature=[]
fields=Layer.fields()
for i in range(n):
feature=QgsFeature()
feature.setFields(fields())
x=random.uniform(-180, 180)
y=random.uniform(-90, 90)
pt=QgsPointXY(x, y)

feature.setGeometry(geom)
feature.setAttribut=(0, 1)
feature.append(feature)

return Layer
randomLayer=createLayer(1)

tgjf