It is my second day on PyQGIS. Not sure why layer doesn't return anything. Can anyone help me on this?
Code:
#!/usr/bin/python
from qgis.core import *
from qgis.utils import *
from PyQt4.QtCore import *
def main():
qgis_prefix="/usr"
QgsApplication.setPrefixPath(qgis_prefix, True)
QgsApplication.initQgis()
app = QgsApplication([], False)
uri = "elevp.csv?delimiter=%s&xField=%s&yField=%s&elevField=%s" % (";","x","y","elev")
vlayer = QgsVectorLayer(uri, "test", "delimitedtext")
QgsMapLayerRegistry.instance().addMapLayer(vlayer)
#print(QgsMapLayerRegistry.instance().mapLayers())
#iface.mapCanvas().setSelectionColor( QColor("red") )
layer = iface.activeLayer()
print(layer)
# Run main wrapper codes
main()
No comments:
Post a Comment