Skip to main content

All Questions

Tagged with
Filter by
Sorted by
Tagged with
3 votes
1 answer
343 views

Deleting shapefile after removing it with removeMapLayer using PyQGIS

I am currently working on a script that searches for a currently loaded layer in PyQGIS and does some calculations. Then it removes the layer and deletes the whole shapefile in its directory. ...
eagleadmiral's user avatar
4 votes
1 answer
1k views

"AttributeError: 'dict' object has no attribute 'fields'" error when creating and deleting fields in the attribute table using PyQGIS

I am currently making a code that will buffer the points then extract vertices and add new coordinates. but I also want to change the "max depth" column to "Height Theo" and then ...
PyCher's user avatar
  • 171
3 votes
1 answer
182 views

Why is it slow when deleting features in gpkg using PyQGIS?

Deleting features in a somewhat big GeoPackage takes a really long time and I am not sure if I do something wrong or if it is normal that it takes such a long time. Data: line GeoPackage layer ...
Kalak's user avatar
  • 4,049
4 votes
1 answer
313 views

Deleting specific attributes of layer using PyQGIS

I want to delete specific columns in the attribute table of my layer: except for the "LAYER" Column. This is my code: clip = processing.runAndLoadResults("native:clip", ...
charliey's user avatar
  • 163
9 votes
1 answer
229 views

Deleting parts of MultiPolygon based on area using PyQGIS

I have a layer with MultiPolygons. Some of them have parts less than five m2 which I want to delete. The QgsGeometry class has methods: parts() and deletePart(self, partNum: int). On parts() I can ...
ThiPa's user avatar
  • 659
4 votes
1 answer
165 views

Adding and deleting fields in shapefile using PyQGIS

As part of a project, I have to extract X, Y coordinates from points in a shapefile, and classify each point as North or South, or East or West. To do so, I created new fields: a field to store the X ...
Mommo_Mia's user avatar
4 votes
2 answers
646 views

Deleting all fields from attribute table in QGIS processing script

I'm writing a script in the processing script editor of QGIS and at one point i want to delete all columns of my vector layer's attribute table. I tried to do it like this: lst = list(range(0,-1)) ...
Anni98's user avatar
  • 107
4 votes
1 answer
1k views

Deleting folder and processed files in QGIS using PyQGIS

My script creates a folder named 'output' and saves processed files there. I am trying to delete this folder and all files within it, if I need to re-run the script (see reproducible example at the ...
Andre Silva's user avatar
  • 10.3k
4 votes
1 answer
212 views

Setting selected features in list without specifying their layer using PyQGIS

To get selected features I usually do: layer.selectedFeatures(). Is there a method to retrieve selected features in a list without specifying the layer they belong to ? I selected features with the &...
Anthony's user avatar
  • 133
1 vote
1 answer
250 views

Deleting created custom CRS using PyQGIS

How can I delete custom CRS by PyQGIS? My not working solution is: my_crs = QgsCoordinateReferenceSystem() my_crs.createFromProj4("+proj=aea +lat_1=21 +lat_2=49 +lat_0=37 +lon_0=87 +x_0=0 +y_0=0 +...
Wenceslauw's user avatar
1 vote
0 answers
744 views

PyQGIS 'str' object has no attribute 'fields' [closed]

I'm trying to write my first Python script from template in QGIS. I want to delete all fields except specific ones. Therefore I create a list to fill it with all the field names except the specific ...
kj0176's user avatar
  • 11
2 votes
0 answers
239 views

Permission error when trying to delete shapefiles with PyQGIS

The task is to merge many layers in a folder (temp_layer) and check for valid geometry for further processing. The folder where are the layer data are is external and should be copied local for ...
Димон Харламов's user avatar
1 vote
1 answer
306 views

Edit CSV not-spatial table in PyQGIS

I am trying to edit a not-spatial CSV table in PyQGIS 2.18 (i.e. deleting existing fields and adding new one ) for the first time (I can do it with polygonal vector layers but I guess something is ...
FedericaZ's user avatar
  • 185
3 votes
1 answer
99 views

Deleting columns by indexes with PyQGIS

In QGIS 3.4, I am building a model for importing and preparing multiple data by merging shapes and joining tables. I am almost finished with the model, but I haven't found a useful tool for deleting ...
Emu's user avatar
  • 33
3 votes
1 answer
1k views

Deleting vertices from line feature using PyQGIS

I have a line made of 17959 nodes. I want to delete several range of nodes from that line with a Python command. For example I want to delete all nodes between node 5530 to node 5861 and connect node ...
Marcel Campion's user avatar
1 vote
0 answers
1k views

Deleting shapefile with QGIS?

This is a follow-up question to an answer to Deleting Shapefiles using QGIS? I tried to run the script, however it always returns False and the shapefile is not deleted - any ideas what needs to be ...
Stephanie's user avatar
11 votes
2 answers
6k views

Deleting all features of Vector layer using PyQGIS

I am developing a Python plugin for QGIS. In the QGIS map window, certain features of a vector layer are selected and those features are highlighted. Now I need to delete all the existing features ...
Sjs's user avatar
  • 1,007
4 votes
1 answer
423 views

Recursive loop to modify vector layer and refresh mapcanvas

I'm trying to plot one point "jumping" each second in the canvas (like a gps tracking). I need to take points from a .csv file. This functionality is made in a QWidget of my application, so the code ...
Nacho F.'s user avatar
6 votes
1 answer
1k views

How to replace a shapefile name in a directory using Python QGIS?

How to replace name or delete .shp file from directory using Python QGIS ? import os import processing input = "//input.shp" output = "//output_100.shp" interval = 100 processing.runalg("qgis:...
Artec's user avatar
  • 982
13 votes
3 answers
12k views

Deleting selected features using PyQGIS

I have a shapefile with only one field "DN". I would like to delete all features which does not have specific value of the field. Let's say the "DN" can be 1,2 or 3. So far I was ...
MasterPJ's user avatar
  • 359
10 votes
3 answers
13k views

Deleting column/field in PyQGIS

How to remove or delete column fields in a shapefile using PyQGIS?
Nahm's user avatar
  • 871