Tag Info

New answers tagged

0

In PYQGIS a shape file can be save as a .csv with coordinates by: QgsVectorFileWriter.writeAsVectorFormat(vlayer, "xy.csv", "utf-8", None, "CSV", layerOptions ='GEOMETRY=AS_WKT') This is not working in QGIS 2.2 but will work again in QGIS 2.4.


0

It would be better if you ask the user password. You can assign a variable and get the value of the variable from user with a dialog. refer to the link please How to connect a PyQGIS plugin with Postgres?


1

Yes: 1) The proposed solution (Using processing algorithms from the console) import processing # find the algorithm processing.alglist("Multipart to singleparts") Multipart to singleparts----------------------------->qgis:multiparttosingleparts # help processing.alghelp("qgis:multiparttosingleparts") ALGORITHM: Multipart to singleparts ...


0

If the selected features and your created layer both share an identical column in their attributes tables. (ie maybe under ID they are both called FT001) then you can do a join and this will add additional attribute details from your selected feature layer. This is also handy if you want to just add a .csv folder and equipe a shapefile with the csv data. Is ...


1

http://www.qgis.org/en/docs/pyqgis_developer_cookbook/composer.html has a simple Python example. http://spatialgalaxy.net/2012/01/27/qgis-running-scripts-in-the-python-console/ has a more detailed example.


1

This is a bug in 2.2 with the canvas and it's redraw event. The redraw event is called when the widget is first shown and it kicks off a timer which stops the canvas from painting. The workaround is as simple as calling: canvas.refresh() canvas.repaint() The first time the widget is shown.


0

I fixed this error by switching to version 2.0.1 I think it's a bug from 2.2. I'm not sure, because I have no experience in qgis.


1

In Qgis 1.8 this is not available in the gui library. Only from version 1.9.


0

You can still use QVariant but don't use it as a type. E.g. the following is still fine: from PyQt4.QtCore import QVariant vl.startEditing() vl.addAttribute(QgsField("id", QVariant.Int)) However, it is no longer required (and no longer allowed) to use QVariant as a datatype. This means, instead of QVariant(fid) you should just use fid. You already have ...


1

This is not possible right now (without reimplementing the whole form view in python). Please open a feature request, consider creating a pull request or funding somebody to implement this.


0

Here is my code: class ShapeViewer(QMainWindow, Ui_MainWindow): def __init__(self): QMainWindow.__init__(self) self.setupUi(self) self.canvas = QgsMapCanvas() self.canvas.useImageToRender(False) self.layout = QVBoxLayout(self.frame) self.layout.addWidget(self.canvas) file = ...


0

I have tried to use the batch file to set the eclipse before and it did not work. Probably I have received the same error message as you. Later, I tried to set the path & pythonhome directly in the eclipse interpreter environment setting. And it works for me. PATH: C:\OSGeo4W\bin;C:\OSGeo4W\apps\qgis\bin PYTHONPATH: C:\OSGeo4W\apps\python27


2

from PyQt4.QtGui import QApplication, QTableView # Get a list of all open attribute table dialogs attrTables = [d for d in QApplication.instance().allWidgets() if d.objectName() == u'QgsAttributeTableDialog' or d.objectName() == u'AttributeTable' ] # Set the column width for the first column in the first dialog to 200 ...


0

Sounds like a projection issue, If you can't see the layer, and it is part of the TOC.


3

Following Polygeo's suggestion: It is a problem of Python and the Windows registry: For the moment, PyScripter can only use the Python versions that have entries in the Windows registry (as the official Python distribution versions, the Enthought Python Distribution or ArcPy) The standalone QGIS installer installs Python 2.7 but does not create any ...


0

See http://spatialgalaxy.net/2013/11/06/getting-paths-with-pyqgis for a discussion of paths in PyQGIS.


1

That's a known issue of QGIS 2.2 but it should be fixed in the dev version and will be in 2.4. See http://hub.qgis.org/issues/9780


1

You have to configure a new interpreter. The python selected for the interpreter should be the OSGeo4w Python, not the system Python. For any given Pydev project you pick which interpreter to use. That way ArcPy and OSGeo Python are never together in the path. Just update, the paths and versions to match. ...


3

That documentation in the cookbook is a little out of date. You shouldn't need to use QString at all now, and the following code should work: actionZoomIn = QAction("Zoom in", self) actionZoomOut = QAction("Zoom out", self) actionPan = QAction("Pan", self) Basically, just remove all references to QString - they'll be converted automatically behind the ...


0

The raster tool of QGIS uses GDAL commands You can also use these GDAL commands (gdalwrap or gdal_translate) in a Python script, look at how to for loop a folder to batch clip rasters by polygon using python and QGIS or Extract raster windows from satellite imagery with GDAL and in pure Python Python GDAL/OGR Cookbook: Python Clip a GeoTiff with Shapefile ...


1

This one-liner will hide the raster toolbar from QGIS UI: iface.rasterToolBar().setVisible(False)


1

That was just discussed on the mailing list: #add toolbar tb = iface.addToolBar("My Toolbar") #remove toolbar del tb I don't think you can disable the standard toolbars that way though. Maybe look into the customization functionality instead.



Top 50 recent answers are included