New answers tagged

0

You probably need to compile the UI file as well as any resources (.qrc) file. Most plugins have a xxx.ui an a corresponding xxx.py file, example: https://github.com/sourcepole/qgis-openlayers-plugin/tree/master/openlayers has ui_about_dialog.ui and ui_about_dialog.py - you make the .py from the .ui using pyuic4, normally driven by a Makefile rule. Again, ...


0

Next function can change raster values greater than 98 for 0. def changeRasterValues(band): fmttypes = {'Byte':'B', 'UInt16':'H', 'Int16':'h', 'UInt32':'I', 'Int32':'i', 'Float32':'f', 'Float64':'d'} data_type = band.DataType BandType = gdal.GetDataTypeName(band.DataType) raster = [] for y in range(band.YSize): scanline = ...


1

The API documentation says: "The context parameters theExtent, theWidth and theHeight are important to identify on the same zoom level as a displayed map and to do effective caching (WCS; Web Coverage Service). If context params are not specified the highest resolution is used". Then, I think that it always returns one value. For this reason, if you want to ...


1

This is an approximate answer, because there is a small possibility of a mistake if two "clusters" of polygons are very close together, it is long, but hopefully quite straight forward. Buffer the polygon layer by a small amount, tick the dissolve box. Spatial join the polygon layer to the buffer layer ("Buffer1") This will give you a table with several ...


0

There's a tutorial in the QGIS documentation, might help: https://docs.qgis.org/2.2/en/docs/pyqgis_developer_cookbook/network_analysis.html


2

Here's what I did to implement a second Toolbar button and its corresponding dialog: Edit the plugin.py file to add a run2() method, a self.dlg2 variable, a new action in initGui(), and this import: from plugin_dialog2 import pluginDialog2 Copy and paste the UI file and rename it as form2.ui (optionally, open it in Qt-Designer and change the windowTitle ...


2

Without knowing exactly where you're up to it's a bit difficult, but here's the nuts and bolts: layermap = QgsMapLayerRegistry.instance().mapLayers() RemoveLayers = [] for name, layer in layermap.iteritems(): if layer.isValid(): if layer.type() == QgsMapLayer.VectorLayer: if layer.featureCount() == 0: ...


6

Better than a script, there's a plugin to achieve it, and it's called "Remove empty layers from the map." http://plugins.qgis.org/plugins/RemoveEmptyLayers/ Disclaimer: I'm the plugin's author.


1

You can use None as output parameter. Doing so, QGIS Processing creates a temporary vector file for you: processing.runandload("qgis:createpointsalonglines", "Clipped" ,100,0,0,None) Or: res = processing.runalg("qgis:createpointsalonglines", "Clipped" ,100,0,0,None) iface.addVectorLayer(res['output'],'my points','ogr') In my case (on a GNU/Linux), the ...


2

You can create views on your table to access the different geometry types as separate layers in QGIS, for example: CREATE VIEW parcel_polygons AS SELECT id, name, geom::geometry(MultiPolygon, 4326) FROM parcels WHERE GeometryType(geom) = 'MULTIPOLYGON'; CREATE VIEW parcel_points AS SELECT id, name, geom::geometry(Point, 4326) FROM parcels WHERE ...


1

Even though you're running the QGIS Desktop with GRASS the GRASS plugin is not on by default, you have to go to Plugins -> Manage and Install... then to the installed plugins. There you'll find an entry for GRASS 7, check its box and then you'll have the GRASS tools under the plugin menu. If you don't have the GRASS 7 entry in the installed plugins go back ...


1

Not sure if QGIS can achieve this natively as I also receive an error (using QGIS 2.14.1-Essen for Win 7 64-bit). Instead use OGR from the Processing Toolbox to convert your shapefile to DGN format: Processing Toolbox > GDAL/OGR > [OGR] Conversion > Convert format


0

This is not happening on OSX, but I am using 2.14.2. Try upgrading to 2.14.2. It should be available for Ubuntu. Does the issue persist?


1

rasterMenu = qgis.utils.iface.rasterMenu() for rasterMenuItem in rasterMenu.actions(): if 'Heatmap' in rasterMenuItem.text(): heatmapMenu = rasterMenuItem for heatmapMenuItem in heatmapMenu.menu().actions(): print heatmapMenuItem if 'Heatmap' in heatmapMenuItem.text(): heatmapMenuItem.trigger()


5

Right, you need to use QSettings to store values across QGIS sessions. QSettings is multi-platform, so you don't need to worry about where it stores the data on Linux, on Windows, or on Mac, it handles it for you. You need to call QSettings in this way: from PyQt4.QtCore import QSettings settings = QSettings() You can use QSettings() every time you ...


2

To automatically open the QGIS Python Console when QGIS starts, you can read How to show Python console at QGIS program start. However, I guess your ultimate intention is to run the script (even if it doesn't run from the QGIS Python Console), so you can create (if it doesn't exist already) a startup.py file in the QGIS Python directory: On GNU/Linux: ...


2

Many QGIS Plugins uses GitHub as their primary issue tracker. Issue tracker is usually specified in the plugin's metadata <home>/.qgis2/python/plugins/<plugin>/metadata.txt. For plugins that use GitHub issue tracker, one can use Report plugin to facilitate reporting of the bugs/enhancements.


0

Solution 2 doesn't work because 'my_layer.getFeatures(request)' is a QgsFeatureIterator object. You have to create, for example, a memory layer with the features "into" this object. In my case, I used the next shapefile, with 8 features, for selecting the features with indexes 1, 5 and 7. The complete code is: layer = iface.activeLayer() request = ...


2

By using a temporary file, as reassignment of the standard output (Python Console), next code works. ... import sys, os import tempfile as tmpf ... else: #save a reference to the Python Console of QGIS before reassignment oldstdout = sys.stdout #creating a temporary file file = ...


1

Found a way, basically you just need to specify the column when populating the QTableWidget (mentioned in comment): qTable = self.dockwidget.tableWidget data = [] group1 = root.findGroup('Group1') group2 = root.findGroup('Group2') for child in group1.children(): data.append(child.name()) for child in group2.children(): data.append(child.name()) ...


0

What you actually want to perform is an interpolation. Heat maps are used to estimate point density between observed points. When you check "Use weights from field", you are expressing that each point has a count other than 1, but the method is still estimating a point density. Interpolation, on the other hand, estimates values at unknown points between ...


0

You might try creating an unweighted heat map raster then use the raster calculator to divide the weighted raster by the unweighted one and see if that gives you what you're looking for


5

Let me share how it works for me: self.setWindowTitle(title) #data = 'Recordset back from postgis' nb_row = len(data) nb_col = 2 qTable.setRowCount(nb_row) qTable.setColumnCount(nb_col) for row in range (nb_row): for col in range(nb_col): item = QTableWidgetItem(str(data[row][col])) qTable.setItem(row,col,item) ...


1

Solution is not to change the compiler, because QGIS compilation was succesful, just my plugins gave the error. So I scrabble about sth in the project properties of qgis and found a preprocessing directive /D nullptr=0 This I copied to my plugins and it worked fine. Don't know, when this was added. Also don't know where to get the information, if sth. ...


0

On a Mac running MacOS 10.11.4 (El Capitan) this worked for me: Download and install the latest QGIS. (Version 2.14.2 was posted to the download site around May 7, 2016.) Launch the app and go to Plugins > Manage and install > Installed, then look in the list of plugins for one called "Processing" and check the box. Restart.


0

This is how I fixed the problem: Run->cmd Go to the location of your plugin builder (i.e: c:/users/rafik_pc/.qgis2/python/plugins/pluginbuilder) type the following command: pyrcc4 -py2 resources.qrc -o resources.py (I used -py2 because I'm using python 2.7) restart your QGIS. DONE.


1

What finally worked was uninstalling the later version of python (2.7.10) and setting the paths to the OSGeo4W64 python directory (while maintaining my arcgis python directories). I then reinstalled the later version of python and qgis runs without issue. Perhaps I didn't need to do the uninstall and reinstall and could have just confirmed and reordered the ...


2

The error message 'module' object has no attribute 'openssl_md_meth_names' seems to be related to python, see https://github.com/Homebrew/legacy-homebrew/issues/36346 for MAC OS and http://stackoverflow.com/questions/27890225/attributeerror-module-object-has-no-attribute-python for linux. QGIS usually has its own python to run, but if your system PATH has ...


0

You might use this code if you want but you need to improve it. from PyQt4.QtCore import * from PyQt4.QtXml import * from PyQt4.QtGui import * layers =iface.legendInterface().layers() canvas=iface.mapCanvas() for layer in layers: myFile = "your qpt path" myTemplateFile = file(myFile, 'rt') myTemplateContent = myTemplateFile.read() ...


4

The error occurs because the plugin (in its version 0.51) does not filter out Raster layers from the QGIS ToC and lists them in its own GUI. The plugin should only deal with Vector layers, since it acts on vector geometries. I sent a pull request to the plugin's author with code to fix this problem, which was accepted and merged by him. The author has just ...


0

I think i cracked it. I get skewed rater if my Project CRS is set up as Slovenian National Grid. If i set it up as WGS84 and import Tif Raster it gives me error and sets up raster CRS to WGS84. That puts tif in the middle of Atlantic. But if i then correct project CRS back to Slovenian National Grid and also Raster CRS - Raster is not skewed and in right ...


2

QMS is certainly installable using Ubuntu 14.04 and QGIS 2.14.1 so I suspect your issue is the age of your QGIS install if it really is 2.0.



Top 50 recent answers are included