New answers tagged

0

You could use the currentText() method to fetch the selected layer in the combo box. layers = project.layerTreeRoot().children() selectedLayerName = self.dlg.Isochrones_SelectInputLayer.currentText() selectedLayer = [l.layer() for l in layers if l.name() == selectedLayerName][0] self.dlg.Isochrones_WalkSpeed_Override.setVectorLayer(selectedLayer) Having ...


1

QGIS support for blobs is currently limited to disk-based layers like gpkg and memory layers, not databases. (See Load PostGIS Layer with BLOB and use the form widget for binary fields (QGIS 3.6) not working ) If you can live with this limitation, or if blob support is later expanded to additional providers, see my question and answer here: Display photo ...


0

Found a solution although its a little rough and ready - however works for any shape polygon which is what I needed. Vector - research tools - regular points Select input extent layer, set spacing interval etc... Then once ran, clipped to points just within the polygon.


2

I think, you should use toProperty() method, which returns QgsProperty. Then you can use value() or valueAs***() methods of QgsProperty to get value of defined expression. Or you can get raw expression string with expressionString() method. See docs for QgsProperty. EDIT value() and valueAs***() returns tuple where first element is actual value and ...


2

You're right. QComboBox objects allow only single selection because they don't have ExtendedSelection option (as QListWidget objects) for activating multiple selection. However, you can also use a QTableWidget object whose ExtendedSelection option is already activated by default. In following code you have an example. from PyQt5.QtCore import Qt class ...


5

It is possible and you do not need a plugin for it (Assuming you are using QGIS3) Zoom to an area covering where you want the points Then, Go to Vector -> Research tools -> Regular points Set input extent to Use Canvas extent and set point spacing to 1 Press "Run" You will probably get more points than you want / need, so for next step select the ...


3

As The Qt Resource System Documentation says, the main reason of using resource file is to avoid the risk of losing the files. pyrcc5 generates all in one binary-like string which contains all resource files defined in .qrc file, and adds that string to .py file (in this case, resources.py), then you import that module (from .resources import * or from ...


7

pluginname/ top-level package __init__.py initialize the package luniPlugin.py dialogs/ sub module select_feature_dialog.py . . You have to specify explicitly sub module in the same package using .(dot). Use .dialogs.select_feature_dialog (Relative import): from .dialogs....


1

The Resource Sharing plugin version 0.6.0 (available since 4 December 2018) was the first version to support QGIS 3. Some issues (https://github.com/akbargumbira/qgis_resources_sharing/issues), but it is still quite useful for sharing your resources with the community. EDIT: As of today (7 February 2020), there has been an additional update (v0.7.0), which ...


3

because the server is down http://osm.inasafe.org/ Error 520 Ray ID: 560fb1f7a99df981 • 2020-02-06 19:57:59 UTC Web server is returning an unknown error


3

I encountered this problem. Some processing tools worked in QGIS 3.8, but doesn't work in QGIS 3.4. I don't know the reason, but changing native word into qgis in all processing.run ("native:tool_name", ...) solved the problem. (native:intersection -> qgis:intersection)


1

Move self.pushButton_2.clicked.connect(self.OpenQgis) outside the loop otherwise you are attaching to the button multiple events. It causes your "only" click to emit multiple calls and hence add multiple layers.


0

The most convenient solution for users of the plugin is to bundle wheel inside your plugin. Download wheel, place it in your plugin folder and import it from there. try: import elevation except ImportError: import sys import os this_dir = os.path.dirname(os.path.realpath(__file__)) path = os.path.join(this_dir, 'elevation-x.y.z-py2.py3-...


1

While building a plugin for QGIS using Plugin Builder, if you get ModuleNotFoundError: No module named '... .resources' error after running Makefile, you should first check if resources.py exists in the folder (source folder) created by Plugin Builder. If it does, copy that file into your plugin folder in QGIS plugin folder (target folder). If there is no ...


2

You can use Qt.MatchContains flag as filter mode. from PyQt5.QtCore import Qt from PyQt5.QtWidgets import QCompleter completer = QCompleter() completer.setFilterMode(Qt.MatchContains) For further information: Filter Modes for QCompleter.


1

The problem, I think is that you lost the reference to the QgsVectorLayer outside the function, the solution is to define self.layers, see below : class My_dlg(QMainWindow): def __init__(self, parent=None): super(My_dlg, self).__init__(parent) self.canvas = QgsMapCanvas() self.layers = [] self.canvas.setCanvasColor(Qt....


3

Try specifying the CRS when you construct your QgsVectorLayer object e.g. v_layer = QgsVectorLayer('LineString?crs=epsg:4326', 'line', 'memory') Unfortunately, you don't show us what objects you are passing to your drawLine() function as the line_start and line_end arguments, however running the code below which directly creates QgsPoint() objects for the ...


0

Edit Version 0.9.0 of the Resource Sharing plugin was made available on http://plugins.qgis.org today (https://plugins.qgis.org/plugins/qgis_resource_sharing), and the good news is that it includes support for R script collections. See https://gis.stackexchange.com/a/341008/22646 for more details, and for information about available collections and ...


1

For future reference: in May 2019 the "Make Valid" tool was added to the core QGIS 3 Processing toolbox, as "Fix Geometries" within the Vector Geometry group.


1

Try enabling macros from the menubar: Settings > Options > General Personally I set it to Always but depends on your use-case.


2

As GabrielDeLuca pointed out - the problem seems to be related to invalid geometries being created by the plugin. Changing the invalid features filtering did not really help, but when I ran the interpolation on a slightly smaller subset of my input points, everything worked fine. I guess the reason for the error was the test extent that I have selected. ...


5

Yes, the WKT plugin allows you to do that. Just paste each geometry in a new line: Which loads all 3 geometries as 3 layers: If you paste geometries of the same type, they will be created in the same layer, unless you check "Create a new layer for every geometry."


5

I have tested the plugin and it is working fine in my machine. One common way to download (SRTM among other) data is searching it in Earth Explorer site. All the information about how to use the site is in their Help page. If you want to download just that image, you can do it from the Download link provided in the following page: https://...


1

You've created a scratch layer that's MULTIPOLYGON type, but you're saving to a POLYGON type, which is causing your problem as for some reason these aren't compatible. This typically means you have polygons with inner holes or rings which then feature additional polygons inside the ring, or are storing all features with the same contour as one giant, ...


1

I expect it should be possible, but I suspect it is overkill for what you are describing. Adding QGIS to your workflow is beneficial when you either need to create quality visual maps, or when QGIS/PyQGIS is a useful coordinator for a more complex geospatial workflow. It's not 100% clear from your question, but it sounds as if your core, i.e. master, ...


1

In this case I found that I can use setTransformOriginPoint before my setRotation line to specify the point of rotation. self.rubberband.setTransformOriginPoint((self.rect.width()),(self.rect.height())) self.rubberband.setRotation(mapRotation) I thought it should be half hight, width bit that spun it off centre (code below) self....


0

Check out this answer from several years ago - you will need to use the GRASS toolset, but using v.clean correctly should still give you the result you require. Is there an open source tool to planarize graphs?


1

The error is not in the scripts themselves but in the structure created. Having a folder called myplugin and a file also called myplugin. QGIS cannot distinguish between them when reloading. When changing the script name, the reload worked correctly. myplugin ├── _init__.py ├── myplugin_main.py ├── myplugin_algorithm.py └── ...


1

You may also use the Snap geometries to layer processing tool: This algorithm snaps the geometries in a layer. Snapping can be done either to the geometries from another layer, or to geometries within the same layer.


1

I used both the location provider and Autocomplete API provided by https://github.com/location-iq/leaflet-geocoder. This autocomplete feature utilises a Search API that returns place predictions in response to an HTTP request. The request specifies a textual search string and optional geographic bounds and works as expected.


Top 50 recent answers are included