2

I am trying to create a closed linestring made of a number of circularstrings, but have got stuck. I cannot see how to add the geometry from both strings.

This is what I have so far. QGIS version 3.4.2

vl = QgsVectorLayer("LineString", "temp", "memory")
from qgis.PyQt.QtCore import QVariant
pr = vl.dataProvider()
pr.addAttributes([QgsField("name", QVariant.String)])
vl.updateFields() 
cString1=QgsCircularString.fromTwoPointsAndCenter(QgsPoint(306580,167317),QgsPoint(306680,167317),QgsPoint(306680,167217))
cString2=QgsCircularString.fromTwoPointsAndCenter(QgsPoint(306680,167317),QgsPoint(306580,167317),QgsPoint(306680,167417))

geom_cString1=QgsGeometry(cString1)
geom_cString2=QgsGeometry(cString2)
f = QgsFeature()
f.setGeometry(geom_cString1)
f.setAttributes(["One"])
pr.addFeature(f)
vl.updateExtents() 
QgsProject.instance().addMapLayer(vl)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.