Hello, this is my code:
--- id_ = 'my_layer_2bbd2539_97b3_417d_8a2a_97ec4f755a82' crs = QgsCoordinateReferenceSystem() crs.createFromString('epsg:4326') crs2 = QgsCoordinateReferenceSystem() crs2.createFromString('epsg:32632') lay = QgsProject.instance().mapLayers()[id_] lay.selectByExpression('"fclass" = \'{}\''.format(w)) new = processing.run('native:saveselectedfeatures', {'INPUT': lay, 'OUTPUT': 'memory:'})['OUTPUT'] opts = QgsVectorFileWriter.SaveVectorOptions() opts.fileEncoding = 'UTF-8' opts.driverName = 'ESRI Shapefile' if os.path.exists('/home/rr/test.shp'): opts.actionOnExistingFile = QgsVectorFileWriter.ActionOnExistingFile.AppendToLayerAddFields # important ctx = QgsCoordinateTransformContext() ctx.addCoordinateOperation(crs, crs2, '', False) err = QgsVectorFileWriter.writeAsVectorFormatV2(new, '/home/rr/test.shp', ctx, opts) lay.removeSelection() --- The result still has WGS84-coordinates. What I'm doing wrong? I can't use native:reprojectlayer because I need the append-feature from the QgsVectorFileWriter.
_______________________________________________ QGIS-Developer mailing list QGIS-Developer@lists.osgeo.org List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer