Re: [Qgis-user] Pyqgis how to append existing gpkg layer

2023-04-26 Thread andrea antonello via QGIS-User
Hi German, > that's right Andrea. It actually depends on whether you want to append > features to an existing layer, or to "append" (one could also say "create") > a layer (in)to an existing GPKG database. The latter case is well covered > by Anne's answer. > > See prior messages in this thread:

Re: [Qgis-user] Pyqgis how to append existing gpkg layer

2023-04-26 Thread Germán Carrillo via QGIS-User
Hi all, that's right Andrea. It actually depends on whether you want to append features to an existing layer, or to "append" (one could also say "create") a layer (in)to an existing GPKG database. The latter case is well covered by Anne's answer. See prior messages in this thread:

Re: [Qgis-user] Pyqgis how to append existing gpkg layer

2023-04-26 Thread andrea antonello via QGIS-User
Hi, from what I saw in the docs, you should be able to append to layers with the filewriter option AppendToLayerNoNewFields? The CreateOrOverwriteLayer overwrites the layer completely. Cheers, Andrea On Wed, Apr 26, 2023 at 2:58 PM Anne B. Nilsen via QGIS-User < qgis-user@lists.osgeo.org>

Re: [Qgis-user] Pyqgis how to append existing gpkg layer

2023-04-26 Thread Anne B. Nilsen via QGIS-User
Sorry, an error in the code in the previous answer. Correct code is (writer should be without indentation): ... def create_blank_gpkg_layer(gpkg_path: str, layer_name: str, geometry: int, crs: str, fields: QgsFields, append: bool = False ) ->

Re: [Qgis-user] Pyqgis how to append existing gpkg layer

2023-04-26 Thread Anne B. Nilsen via QGIS-User
I'm not a pyQGIS-expert, but with help from gis.stackechange.com I have managed to create an empty geopackage file and then adding several layers to it with this code: ... gpkg_reg = "karplanteregistrering.gpkg" # the NEW gpkg to be created if os.path.exists(gpkg_reg):

[Qgis-user] Pyqgis how to append existing gpkg layer

2023-04-19 Thread PIERRE Sylvain via QGIS-User
Hi dev and users I don't understand how to append an existing gpkg layer with pyqgis. I've tried many QgsVectorFileWriter options self.options.actionOnExistingFile = QgsVectorFileWriter.CreateOrOverwriteLayer reset final layer And self.options.EditionCapability =