In QGIS 3.10, the data for the layer SIMnodes seem to be OK as inspected in the respective data table but trying to save it into a shapefile:
cSIMnodes = QgsProject.instance().homePath() + '\\SIMnodes.shp'
QgsVectorFileWriter.writeAsVectorFormat(layer = SIMnodes,
fileName = cSIMnodes,
fileEncoding = 'UTF-8',
destCRS = QgsCoordinateReferenceSystem(4326),
driverName = 'ESRI Shapefile')
yields all real numbers in the resulting Esri shapefile to be wrong {for example 234.5 is written as 2.0}.
All integers and all strings are written well.
1 Answer 1
In my case, your request "QgsCoordinateReferenceSystem(4326)" doesn't work.
To export, the syntax is as follows :
layer = iface.activeLayer()
file_path = "C:/Users/v.bre/Desktop/test/test.shp"
encoding = "utf-8"
crs = QgsCoordinateReferenceSystem('EPSG:2154')
format = "ESRI Shapefile"
writer = QgsVectorFileWriter.writeAsVectorFormat(layer,file_path,encoding,layer.crs(),format)
answered Nov 27, 2019 at 11:39
lang-py