2

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.

PolyGeo
65.5k29 gold badges115 silver badges350 bronze badges
asked Nov 26, 2019 at 9:49

1 Answer 1

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

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.