Advertisement
Guest User

Untitled

a guest
Mar 2nd, 2015
218
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.36 KB | None | 0 0
  1. The test script is as follows:
  2.  
  3.     from PyQt4.QtCore import QFileInfo,QString,QStringList
  4.     from qgis.core import *
  5.  
  6.     QgsApplication([], False) #initialize the qgis application
  7.     QgsApplication.setPrefixPath("/usr/local", True)
  8.     QgsApplication.initQgis()
  9.     print "Version"
  10.     print QGis.QGIS_VERSION
  11.     print "Settings"
  12.     print QgsApplication.showSettings()
  13.     print "Provider list"
  14.     providers=QgsProviderRegistry.instance().providerList()
  15.     for provider in providers:
  16.         print provider
  17.     proj=QgsProject.instance()
  18.     proj.read(QFileInfo("project.qgs"))
  19.     root = QgsProject.instance().layerTreeRoot()
  20.     layer = QgsVectorLayer("Point", "Layer 1", "memory")
  21.     print layer.isValid()
  22.     print "***Adding layer...***"
  23.     QgsMapLayerRegistry.instance().addMapLayer(layer,True)
  24.     proj.write(QFileInfo("output.qgs"))
  25.  
  26. And produces the following output:
  27.  
  28.     Version
  29.     2.6.1-Brighton
  30.     Settings
  31.     Application state:
  32.     QGIS_PREFIX_PATH env var:      
  33.     Prefix:     /usr/local
  34.     Plugin Path:        /usr/local/lib/qgis/plugins
  35.     Package Data Path:  /usr/local/share/qgis
  36.     Active Theme Name: 
  37.     Active Theme Path:  :/images/themes//
  38.     Default Theme Path: :/images/themes/default/
  39.     SVG Search Paths:   /usr/share/qgis/svg/
  40.             /usr/local/share/qgis/svg/
  41.     User DB Path:   /usr/local/share/qgis/resources/qgis.db
  42.  
  43.     Provider list
  44.     memory
  45.     (..others omitted...)
  46.     wms
  47.     True
  48.     ***Adding layer...***
  49.     Segmentation fault
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement