I am generating new raster files from vector layers on a project. I would like to save them in the same directory as the project or layer files.
How do I find this path using PyQGIS?
Answer
For python console:
QgsProject.instance().readPath("./") # also try "../"
Or with
dir(QgsProject.instance())
you find something like
fileName()
For python plugin (not tested!):
from PyQt4.QtGui import QMessageBox
from qgis.core import QgsProject
path_absolute = QgsProject.instance().readPath("./")
QMessageBox.information(None, "Title", "AP: " + unicode(path_absolute))
No comments:
Post a Comment