Questions tagged [qgsvectorlayer]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
3
votes
0answers
34 views

PyQgis 3 - Add New Layer to Spatialite Database

For the most part, working with QGIS layers has been a pleasure, but I've run into some difficulties recently when trying to create a new vector layer in the SQLite database I've been using. I've ...
4
votes
1answer
69 views

Why get the first and the last point code from a multilinestring layer in PyQGIS 3 doesn't works?

I need to get the first and the last vertex from a multilinestring layer from PostGIS and create a memory point layer with them. The code below works for some line layers and doesn't for others in ...
1
vote
1answer
42 views

Getting AttributeError when exporting Heatmap using qgis2web? [closed]

I want to make a heatmap layer on my webgis. using these options but when i'm trying to export it using qgis2web i always get this error. 2019-06-21T10:15:53 WARNING Traceback (most recent ...
2
votes
1answer
26 views

Area of click-selected features PyQGIS

I'm trying to get the total area for a reprojected layer made by number of features selected by clicking on a layer with PyQGIS, but when I use iface.activeLayer().selectedFeatures() a list of ...
2
votes
0answers
32 views

Algorithm “qgis:difference” returns multiple heterogeneous outputs

I use the qgis:difference algorithm but it returns multi-type outputs. Sometimes it's a QgsVectorLayer but sometimes a str such as : output_.... My question is : when the algorithm returns an empty ...
2
votes
1answer
49 views

processing.run() returns string instead of QgsVectorLayer with QgsProcessingFeatureSourceDefinition as parameter

I try to run qgis:difference on selected features of 2 layers. But the result of my code : parameters = {'INPUT': QgsProcessingFeatureSourceDefinition(layer1.id(), True), 'OVERLAY': ...
0
votes
0answers
15 views

QgsVectorLayer, configuring ogr uri for a shapefile (to set field datatypes)

I'd like to load a .shp and set the data type of one of the fields. I thought something like this would work: uri = 'C:/myfile.shp?field=myfield:integer' vlay = QgsVectorLayer(uri ,'some_name','ogr')...
1
vote
0answers
94 views

QGIS: Zoom to selected feature via plugin doesn't works in first attempt

I recently migrated from QGIS 2.18 to QGIS 3.6. In the plugin, I load a vector layer and then select and zoom to a particular feature. This worked fine in v2.18 but now on 3.6, what happens is the ...
1
vote
1answer
43 views

Overlay raster above uploaded shpfile but behind background?

I have a .shp file of the world oceans (hydropolys.shp) and create a map with it in QGIS, so the background of the image is the land. Does anyone have any suggestions on how I can overlay my raster ...
1
vote
0answers
25 views

QgsVectorLayerCache causes QGIS to crash when called within def run(self)

This is in reference to the similar question regarding QgsVectorLayerCache . The original code is taken from here I'm trying to implement this method within the def run(self) method. def run(self):...
1
vote
1answer
258 views

Python Scripting in QGIS to add features and select them?

I'm trying to migrate a python plugin I wrote from QGIS 2.18 to QGIS 3.4. In the plugin, I'm creating new vector features and eventually adding them to an existing vector layer. I'm trying to have the ...
3
votes
3answers
425 views

Following QGIS Python Programming Cookbook to create vector layer in memory? [closed]

I got the QGIS Python Programming Cookbook Second Edition, in hopes of improving my abilities around QGIS as well as making me confident in using Python. Keep in mind that my programming abilities are ...
2
votes
0answers
60 views

QGIS 3 imports DATE type colum in Oracle Database as QDate, losing hh:mm:ss

I am at the moment working on a lift for an QGIS 2 plugin to work with QGIS 3. The plugin specifies a QgsDataSourceUri and uses it in an QgsVectorLayer. In the specific table, laying in an Oracle ...
1
vote
1answer
126 views

PyQgis how could I get the id from a selected feature

using self.iface.mapCanvas().selectionChanged.connect(self.getselectionid) how could I get the id of a manually selected feature on the Qgis map specifically on a vectorlayer? so it can be used to ...
0
votes
1answer
240 views

AttributeError: 'QgsVectorLayer' object has no attribute 'setCacheImage'

When I call the following (using QGIS 3.0.2): self.layerCatalog = QgsCore.QgsVectorLayer( "MultiPolygon?%s" % s_fields, nameLayer, "memory") if self.iface.mapCanvas().isCachingEnabled(): ...
1
vote
0answers
115 views

Get error when QgsVectorLayer is not valid

In QGIS 2.18.16, with a custom plugin, I tried this code to create a new vector layer for WFS: v_layer = QgsVectorLayer(uri.uri(), "my WFS layer", "WFS", False) if not v_layer.isValid(): print ...
1
vote
1answer
137 views

pyqgis 3 QgsVectorLayer.startEditing() doesn't trigger vertex display

In pyqgis 2 standalone application, the following code will trigger the display of vertex as red cross mark, but in pyqgis 3.0.3 standalone application, it doesn't: layer.startEditing() mapCanvas....
5
votes
1answer
1k views

pyQGIS returns invalid layer with QgsVectorLayer in QGIS 3

I have the following problem : I've installed all pyQGIS environment on Windows 7. I work with 64 bits version of Python 3.6 and QGIS 3.0 and PyQt5. My Windows paths are ok. My objective is to create ...
2
votes
1answer
79 views

Create a vector layer in Coordinate Reference System USER:10001

I want to create a vector layer in the this CRS : USER:100001 but i doesn't work. It always tells me, i need to choose the CRS by myself. vl = QgsVectorLayer("Point?crs=user:100001", "...
1
vote
1answer
341 views

Using file path in QgsVectorLayer?

After hours of tries and errors I can't get this right in QGIS 2.99. I want to add a layer with the delimitedtext function in QgsVectorLayer but if I add this code to my plugin, or if I'm running it ...
0
votes
2answers
118 views

Unable to loop/delete with QgsVectorLayer and dataProvider

I have a csv file with the following columns: table geometry field type typeName len precision and my goal is to create a number of shp files programatically with PyQGIS. My script ...
2
votes
2answers
398 views

PyQgis open vector layer attribute table

Is there a Qgs dialog or widget that I can use in a standalone pyqgis application to open the attribute table of a QgsVectorLayer? this seems to be such a simple thing, there has to be an existing ...