I have a line layer (multiple lines but not large) that I'm working with in my PyQGIS plugin and I need to save the layer as a KML file in the end. My code looks like this:
saveLocation = filePath + "\\output.kml"
QgsVectorFileWriter.writeAsVectorFormat(layer,
saveLocation, "utf-8", layer.crs(), "KML")
The layer I use is already reprojected to EPSG 4326. The plugin runs without error and a KML file does get saved in the specified location. However, when adding the KML file to the map it is empty -- some features from the layer remain in the attribute table but it seems like geometry info is lost completely. This method used to work.
Is the method deprecated somewhat, or is there something I'm doing wrong?
result, error = QgsVectorFileWriter.writeAsVectorFormat(...)
. Then checkprint(result)
andprint(error)
to get more info, if any.