Questions tagged [qgsvectorlayer]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
1
vote
0answers
21 views

Creating layer with WFS, but no features are added to the layer

I am creating a plugin that is gathering data from a WFS client. The WFS client was recently updated, and I had to update the URL and filter encoding that I was using. I updated the code, and it is ...
2
votes
1answer
36 views

Creating QgsVectorLayer from Pandas dataframe

I am writing a python script for QGIS. I have a pandas dataframe that I would like to use in order to create a QgsVectorLayer. At the moment I am saving the data frame into a .csv and then I load it:...
0
votes
0answers
38 views

Is it possible to read temporary QgsVectorLayer with fiona or geopandas?

I want to change all features' attribute without for loop. I checked pyQgis, geopandas and fiona api. However, I can't find a method. Geopandas and fiona want to file path but I don't have any path ...
1
vote
1answer
48 views

Importing shapefile into PyCHARM with QgsVectorLayer “Layer is not valid”

I'm using PyCharm with QGIS3 and Python3. I tried this code to import a shape file and the other to connect to PostGIS vector layer. The codes goes right on the python console of QGIS, but in the ...
1
vote
1answer
56 views

QgsVectorFileWriter.writeAsVectorFormat() just kills my kernel

I would like to save a vector layer with Pyqgis 3, looking at documentation, and other questions on this forum, I wrote : wrpath = "/home/.../joint.shp" _writer = QgsVectorFileWriter....
2
votes
1answer
60 views

Load layer From Oracle using QgsDataSourceUri in QGIS3 always return Invalid Layer

I'm tring to load spatial layer from Oracle but when i called function QgsVectorLayer(uri.uri(), "LAYER" , 'oracle') it still inValid layer This is my code > def LoadFromOracle(tablename): > ...
4
votes
0answers
84 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
74 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
77 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
51 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
33 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
68 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
23 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
104 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
63 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
35 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
457 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
574 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
74 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
199 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
265 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
141 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
160 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
90 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
389 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
129 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
475 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 ...