I am trying to interpolate lines using Interpolation plugin in QGIS. There is an option for exporting triangulation file. I don't want to create raster interpolation. In this case, I want only triangulation file. My code:
from qgis.core import QgsRasterLayer, QgsVectorLayer, edit, QgsFeatureRequest, QgsMapLayerRegistry import qgis.analysis resolution = 0.1 q5_edited = QgsVectorLayer("C:\\Users\\testuser\\Documents\\exp_q5_23.shp", "CONTOUR", "ogr") q20_edited = QgsVectorLayer("C:\\Users\\testuser\\Documents\\exp_q20_23.shp", "CONTOUR", "ogr") q5_index = q5_edited.fieldNameIndex('intpol') q20_index = q20_edited.fieldNameIndex('intpol') ld_q20 = qgis.analysis.QgsInterpolator.LayerData() ld_q5 = qgis.analysis.QgsInterpolator.LayerData() ld_q20.vectorLayer = q20_edited ld_q20.zCoordInterpolation=False ld_q20.InterpolationAttribute = q20_index ld_q20.mInputType = 1 #1 = structureLines, 2 = breakLines ld_q5.vectorLayer = q5_edited ld_q5.zCoordInterpolation = False ld_q5.interpolationAttribute = q5_index ld_q5.mInputType = 1 itp = qgis.analysis.QgsTINInterpolator([ld_q20, ld_q5]) itp.setExportTriangulationToFile(True) itp.setTriangulationFilePath('C:\\Users\\testuser\\Documents\\dualedge.shp') rect = q20_edited.extent() ncol = int((rect.xMaximum() - rect.xMinimum())/resolution) nrow = int((rect.yMaximum() - rect.yMinimum())/resolution) test = qgis.analysis.QgsGridFileWriter(itp,"C:\\Users\\testuser\\Documents\\dualedge_raster.tif",rect,ncol,nrow,resolution,resolution) test.writeFile(True)
True and set the
setTriangulationFilePath to path where I want to create triangulation file. But the triangulation file is created only when the last line is run
test.writeFile(True). This command creates triangulation file (.shp) and raster file (.tif). I checked the code of
writeFile function (https://qgis.org/api/qgsgridfilewriter_8cpp_source.html) but I can't find the place where triangulation file is created I found only the writing to a raster file. I hoped there will be some function which creates triangulation file before creating the raster file.
How the triangulation file is created and is it possible to create triangulation file without creating raster? I need it because we interpolate a very big vector data which makes raster really big and we don't need a raster, just a triangulation.