I have a stand alone pyqgis application that can load vector map layers. I want to export all of the map layers into a single geojson file. I can do it by creating an all-included QgsVectorLayer, then uses the QgsVectorFileWriter.writeAsVectorFormat() method to output that layer to one geojson file. The problem with this approach is that all features have to have the SAME number of properties/attributes, otherwise you can't keep adding new features into the layer. GeoJson can have features that have different number of properties, and I would like to take advantage of that, but I don't know how to generate a collection of features with different number of properties to be exported into a single geojson file. I would prefer to stay with PyQgis utilities and not import additional libraries, but if I have to, I would like to know as well.


Your Answer

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

Browse other questions tagged or ask your own question.