Tag Info

Hot answers tagged

4

You need to specify that this function requires the geometry with the kwarg usesgeometry=True. If you don't, you may get a geometry but there is no guarantee (as you realized). This works starting from QGIS 2.4 from qgis.utils import qgsfunction from qgis.core import QGis @qgsfunction(0, "Python", usesgeometry=True) def test(values, feature, parent): ...


2

Just create a list of all ids from the features you get in the iterator. ids = [f.id() for f in layer.getFeatures(QgsFeatureRequest().setFilterExpression(u'"DN"!=3'))] layer.deleteFeatures( ids )


2

Solved it with: wfs_vector_layer.triggerRepaint() From this answer: How to automatically reloaded raster layer if source is changed in QGIS?


2

QgsMapToolEmitPoint implements the method canvasPressEvent while QgsMapToolAddFeature implements the method canvasReleaseEvent to trigger its actions. CanvasPressEvent is called before canvasReleaseEvent so if you replace the maptool in the first method, the second one will be called on the new map tool. I would recommend to create a new map tool that does ...


1

I finally found out why field attributes weren't properly updated. I was related to the data provider, but it is a very specific case because I made myself in trouble not using the 'ogr style' spatialite driver when writing my Spatialite files. Here is why it broke and how I repaired it: I am performing local extract of a PG database. I decided to store ...


1

Here is a way to set a primitive progress bar. Design is based on example you can found within the PyQgis Dev. Cookbook (see section 11.2) Example is designed to work with features of a QgsVectorLayer but it shows the main steps you could adapt for your process algo. The key to your problem is to find a way to evaluate the progression of your algo within ...


1

Don't know if this is just a typo in your post, but if not, this could cause a blank image.. # set layer set layers = qgis.utils.iface.legendInterface.layers() This should actually be qgis.utils.iface.legendInterface().layers() (note that legendInterface must be the method call, done by adding braces() ) lst = [] for layer in layers: ...


1

I'd add my answer as a comment, but since I can't comment (no reputation enough), I'll add as an answer. It seems that you are trying to add centroid connectors to feed into a traffic assignment algorithm. Right? I should say that doing it automatically is not considered best practice in this industry, but it you are going to do it, I'd like to suggest you ...


1

The problem must come from the Python PATH. To find out: Create a python and copy it into the directory pyshp-master (the one that contains shapefile.py) file. Try again to import your shapefile with python. NB : I test the import it works perfectly. I download pyshp from https://github.com/GeospatialPython/pyshp


1

Where can I activate/implement these settings in my standalone app? Is this the setting that is read by QgsMapCanvas.setCachingEnabled(bool)? Yes, to the latter. That is what is called when the Options dialog is confirmed and closed. Oddly, the caching setting is only read in on QgisApp::QgisApp initialization when QgisApp::createOverview() is called. ...


1

Sorry, you asked for PyQGIS but this is just standard Python. Here's a script I put together: import os, sys, subprocess # in folder and out folder arguments, if you want you can hard code # these paths instead of using arguments. InFolder = sys.argv[1] OutFolder = sys.argv[2] # GDAL_Translate = "C:\\YOUR\PATH\TO\GDAL_Translate.exe" # this is my path ...


1

Ok then, after a few searches : U got to use the two lists provided by the SelectionChanged signal : QgsFeatureIds selected,QgsFeatureIds deselected (as mentionned in the API doc...) to check what is really changing in your selection, of course multiple features selection is to take in account ...



Only top voted, non community-wiki answers of a minimum length are eligible