Tag Info

Hot answers tagged

5

What you need is the QGIS plugin Load Them All. Apart from loading files from several directories at once, you can: Reflect the directory structure in the QGIS Table of Contents (by means of nested layer groups). Apply alphanumeric filters so that you just load layers that match your filter (think of regular expressions). Load only certain geometry or ...


3

If I got you right, you can use the SIGNAL selectionChanged from your vector layer and connect it to your other function (which must accept an argument to receive selected features' ids). For example, load a vector layer to QGIS, activate it in the ToC and run the following code in the QGIS Python console. You should see the function is running after a new ...


2

You are probably setting a connection between a SIGNAL (button clicked) and a SLOT (your method showTable) every time your plugin is open (run() method?) and you are not disconnecting such SIGNAL/SLOT when your plugin is closed. This leads to a new call to showTable() every time you open your plugin, because there's a new connection calling it. A couple of ...


2

Connect to the project read signal to know when a project is loaded def project_loaded(dom): print QgsProject.instance().readPath("./") QgsProject.intance().readProject.connect(project_loaded)


2

You can set the base directory of the "Add Vector Layer" dialog, reflecting the latest active layer's path, this way: import os from PyQt4.QtCore import QSettings def setOpenDir( layer ): # Check if layer exists, has a proper path, and is of type vector if layer and os.path.exists( layer.source() ) and layer.type() == 0: layerPath = ...


2

In an email exchange with Radim Blazek in the grass-user mailing list he explained: QGis from OSGeo4Win is compiled with GRASS 6, you cannot get it working with GRASS 7. Reinstalling will not help. The provider and the plugin has first to be fixed to support build with both GRASS 6 and GRASS 7. This is in the first package of proposed upgrade: ...


2

Keep things simple, you don't need a special function selectedfeatures here, you can do everything at once (try your script in the Python console before). 1) you don't need the Valtestand state_and_cities variables: layer = iface.activeLayer() idx = layer.fieldNameIndex('name') idx1 = feature.fieldNameIndex('state') for feature in layer.selectedFeatures(): ...


2

If you have installed a 64-bit version of QGIS on Windows and you find that Personal GeoDatabases (*.mdb) no longer work for you, then this solution might apply; I'm on QGIS 2.8.1 rather than 2.6, but I assume that the issue and thus the solution is the same. The underlying issue relates to this GDAL bug: Problem reading MDBs (64-bit) Step 1 Download the ...


1

Based on the answer by Adam Bioletti, further tests to the process described show that the only essential requirement is to start editing the memory layer before making any changes, such as creating attributes and features, and then commit the changes. This can be done before adding the layer to map registry. Here's an update of the Cookbook's code that ...


1

Note that GRASS GIS 7 comes with an updated vector format (esp. new spatial index). In order to use older vector data (from GRASS GIS 6) in GRASS GIS 7 the user has to rebuild the topology. Additionally it is recommended to switch the database backend from DBF files to SQLite. Both can be done in an automated way per MAPSET as described in this wiki page: ...


1

One way to achive this is store the user activity in a variable like self.user_action then in your accept() method (which is called when you click Run button), use it to determine what to do def accept(): if self.user_action == 'DROPDOWN_SELECTION': self.run_function1() elif self.user_action == 'MAP_SELECTION': self.run_function2()


1

I believe you want this line: nearCity = feature.attributes()[idx] to be: nearCity = f.attributes()[idx] Using the feature variable will always point to the last value in selection. (This is untested advice, so I might not be understanding something fundamental here.)


1

Do you need the memory layer at all? Have a look at the "directly from features" example in the PyQGIS cookbook to see how to create a persistent Shapefile from features, so that you avoid creating a memory layer.


1

the Line, feature = layer.selectedFeatures() returns a list of QgsFeature. You will need to loop over it to process individual selections, like below. layer = qgis.utils.iface.activeLayer() for feature in layer.selectedFeatures(): mbuf = feature.geometry().buffer(50, 2) iterFeat = layer.getFeatures() for f in iterFeat: geom2 = ...


1

You can overwrite the close function of your UI as well, that the plugin is reloaded every time you close it. def closeEvent(self, event): qgis.utils.reloadPlugin('YourPluginName') This will reload the plugin completely and will empty all your boxes. In this way you don't have to care about clearing the boxes because the plugin will always load only ...


1

Both underdark‚ô¶'s and gcarrillo's replies provide valid answers. How exactly the issue should be handled however depends on the use case, and if necessary, options should be provided.


1

In my opinion you should empty the combo box before populating it. The rationale behind that is that the layer might have changed so it's not a good idea to set a flag and ignore everything that might happen afterwards.


1

The Measure area tool does not create a layer which can be input for Processing. You need to create a new polygon layer, for example a Memory layer, see http://docs.qgis.org/testing/en/docs/pyqgis_developer_cookbook/vector.html#memory-provider and Using in-memory vector layer with QGIS processing / SEXTANTE


1

You only need to run pyrcc4 -o resources_rc.py resources.qrc The .ui file is loaded dynamically in the recent versions of the default plugin code. For example, if the plugin is called test, the corresponding GUI loading code in test_dialog.py is FORM_CLASS, _ = uic.loadUiType(os.path.join( os.path.dirname(__file__), 'test_dialog_base.ui')) All ...


1

On QGis 2.8 this problem is caused by a known, but yet unreported bug (access to the QGis bug tracker seems restricted). Before it is fixed it is not possible to create new mapsets in QGis. However, the user can create a new mapset directly with GRASS and then open it with the GRASS plug-in in QGis.


1

What about the Oslandia Versioning Plugin for QGIS? http://www.oslandia.com/qgis-versioning-plugin-en.html Contrary to the promises on the website, I can't find it in the QGIS Plugin Repository.



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