I have about 200 .xyz files I want to import into my QgisQGIS project. I've tried using this answer https://gis.stackexchange.com/a/310415 but haven't been able to make it work. I'm getting this
exec(Path('C:/Users/AppData/Local/Temp/tmp8k1lnjji.py').read_text())
as an output and no error messages so it seems like QgisQGIS is reading my files but not doing anything with them? To be honest I have no idea what I'm doing with the pythonPython console so please tell me what I'm. What am I doing wrong?
thisThis is the adjusted code I'm using:
import os.path, glob
from qgis.core import QgsProject, QgsVectorLayer
layers=[]
for file in glob.glob('D:/Documents/Uni/Master/Masterarbeit/Daten/2014/100*.xyz'): # Change this base path
uri = "file:///" + file + "?delimiter=%s&xField=%s&yField=%s&useHeader=no&crs=epsg:31467" % (" ", "field_1","field_2")
vlayer = QgsVectorLayer(uri, os.path.basename(file), "delimitedtext")
vlayer.setFieldAlias(0,'X')
vlayer.setFieldAlias(1,'Y')
vlayer.setFieldAlias(2,'Z')
layers.append(vlayer)
QgsProject.instance().addMapLayers(layers)
I'm on Windows 10 with QgisQGIS version 3.28.5. This
This is what the data looks like:
3465888.000 5910084.000 -10.431
3465888.000 5910086.000 -10.399
3465888.000 5910088.000 -10.421
3465888.000 5910090.000 -10.473
3465888.000 5910092.000 -10.536