All Questions
80
questions
1
vote
1
answer
44
views
Layers corrupted after saving, closing and opening of QGIS project with PyQGIS
Using a Python script, I create a layer from a CSV file and then write it out to a gpkg file.
I then create a group in the layer tree, load it in the gpkg file and add it as a child of the group. This ...
2
votes
1
answer
53
views
Adding CSV layer without headers with PyQGIS
I have a CSV file with no headers like this
FOO:ObjList(EPSG:25832)
640410.2620,5493340.3749,23/2024#566.520,00##
640406.4920,5493342.0019,23/2024#566.520,00##
640391.6548,5493327.6581,23/2024#566.520,...
-1
votes
1
answer
96
views
PyQGIS: Transform Lat-Long CSV into a UTM project
I have a UTM project in QGIS and need to import some CSV files that are in Latitude Longitude format. When I import it using the GUI, it knows that it is in CRS: 4326 and does a ballpark reprojection ...
3
votes
1
answer
89
views
This code is giving me empty line layer
This code run well but produces an empty line layer with no attribute
from qgis.core import QgsPointXY, QgsFeature, QgsGeometry, QgsProject, QgsVectorLayer
from qgis.utils import iface
# Path to your ...
-1
votes
1
answer
77
views
Loading CSV files using PyQGIS [closed]
This script works with older version of QGIS but not the latest one.
What is wrong with this script?
I do not think the space in the directory name is the cause.
import os.path, glob
from qgis.core ...
2
votes
1
answer
70
views
"Incorrect parameter value for LAYERS" error when saving CSV to GeoPackage with PyQGIS
I am using QGIS 3.32.3 and am trying to save a CSV file to a GeoPackage with PyQGIS using the current directory as part of the string. When trying to do this it shows:
'Incorrect parameter value for ...
5
votes
1
answer
84
views
Setting QgsVectorLayer created from CSV in editing mode with PyQGIS
I'm working on QGIS 3.28.10 and I want to create a QgsVectorLayer from a CSV file with PyQGIS script, but the resulting layer is not editable. Does anyone know how to set this layer as editable?
My ...
1
vote
2
answers
265
views
Transforming QgsPoint from one CRS to another using PyQGIS
I would like to change the coordinates of QgsPoints imported from a csv file before saving it in shapefile.
I succeed to do all the step except the crs transformation, the output is keeping EPSG: 4326 ...
1
vote
0
answers
96
views
Usage of QgsVectorFileWriter.ActionOnExistingFile() in PyQGIS
I am currently trying to find a way to overwrite a CSV file saved in my QGIS project as a component in my larger project to save files. The end goal is that the CSV is 1) saved if the project has not ...
4
votes
2
answers
385
views
Exporting attribute table to CSV via pure Python in QGIS
I would like to use pure Python to export the attribute table as csv. For the variable data, I need a list that will read the whole attribute table. Is that possible?
import csv
layer = iface....
1
vote
1
answer
157
views
PyQGIS export layers to CSV
This code exports all layers starting with xxx_ to CSV format. But all fields are exported as string. How can I export the fields with numbers as integer or double?
#
#https://gis.stackexchange.com/...
3
votes
0
answers
124
views
Can't load delimitedtext layer
I am on Linux Debian with Python
Python 3.9.2 (default, Feb 28 2021, 17:03:44)
[GCC 10.2.1 20210110] on linux
Here is my code :
# -*- coding: utf-8 -*-
import sys
import os
from qgis.core import ...
5
votes
1
answer
242
views
Export WKT to CSV from QgsVectorLayer with QGIS Python
I'm trying to export QgsVectorLayer format into a csv with WKT?
I'm really have a hard time understanding the QGIS python documentation. I don't even see any option for Geometry. Even though I saw ...
0
votes
1
answer
256
views
How to import multiple .csv files as .shp into Qgis with CRS and z [closed]
I am trying to load multiple (50) .csv files to Qgis as shp layers.
My files are in a specific CRS (EPSG: 32642) and are points in z,y,z.
I first looked for a plugin to do this and then decided to do ...
2
votes
1
answer
354
views
Creating polyline from CSV data using PyQGIS
In QGIS by means of Python I would like to add a line (polyline) from a CSV file which has the following format for the coordinates:
[[7.89471262378373, 48.405478200932436], [7.896052894441773,
48....