[Qgis-user] use Binary (Blob) in writeAsVectorFormat

Hugh Kelley hghklly at gmail.com
Fri Feb 3 11:24:04 PST 2023


Hi,

I'm attempting to use pyqgis to export a few things to shapefile.

the code below is working well except that a few of the attributes are
incompatible with shapefiles (amazing) lack of a binary datatype.

```py
pathToFile = "C:/Users/hkelley/Downloads/test_exports/

layers = QgsProject.instance().mapLayers()

for layer_id, layer in layers.items():
    print(layer.name())
    QgsVectorFileWriter.writeAsVectorFormat( layer,  pathToFile+ layer.name()
+ ".shp", "utf-8", layer.crs(), driverName="ESRI Shapefile" )
```

I see in the manual export options that I can check a box telling the
export process to use "Use Binary (BLOB)". Image linked below for clarity
[0]

I haven't yet figured out how to pass that option to writeAsVectorFormat.

any suggestions?

Iv'e had a pretty thorough look through the docs for writeAsVctorFormat, is
the solution related to
QgsVectorFileWriter.BoolOption(QgsVectorFileWriter.BoolOption)?



[0] https://imgur.com/a/9zSMHKq

-- 
Hugh Kelley
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-user/attachments/20230203/17e4db27/attachment.htm>


More information about the QGIS-User mailing list