Bug report #17446
QgsVectorFileWriter.writeAsVectorFormat() throws errors
|Affected QGIS version:||master||Regression?:||No|
|Operating System:||Easy fix?:||No|
|Pull Request or Patch supplied:||No||Resolution:||invalid|
|Crashes QGIS or corrupts data:||No||Copied to github as #:||25343|
I may have missed something, but I checked this https://qgis.org/api/api_break.html and the other tickets and could not find anything about the issue:
Saving a layer as a ShapeFile throws an error:
QgsVectorFileWriter.writeAsVectorFormat(my_layer, output_path, "utf-8", None, "ESRI Shapefile")
@Traceback (most recent call last):
File "C:\PROGRA~1\QGIS2~1.99\apps\Python36\lib\code.py", line 91, in runcode
File "<input>", line 1, in <module>
File "<string>", line 7, in <module>
TypeError: QgsVectorFileWriter.writeAsVectorFormat(): arguments did not match any overloaded call:
overload 1: argument 4 has unexpected type 'NoneType'
overload 2: argument 4 has unexpected type 'NoneType'
overload 3: argument 3 has unexpected type 'str'
This error (just some other "unexcpected" types) happens with GeoJSON, Spatialite, etc... as well. With the latest 2.18 LTR everything works fine.
#1 Updated by Even Rouault about 3 years ago
- Resolution set to invalid
- Status changed from Open to Closed
You probably missed:
"""writeAsVectorFormat() now takes a QgsCoordinateTransform reference, not a pointer. An invalid QgsCoordinateTransform should be used instead of a null pointer if no transformation is required.*"""