I have been working on putting together a simple script that converts a file geodatabase to a GeoPackage. I have a GeoPackage with empty tables set up so that the data in the gdb can be appended easily. I have tried different approaches and want to keep the code simple. I cannot for the life of me figure out how to make this work though.
Does anyone have any thoughts about what I am doing wrong? Basically, I am trying to iterate through every featureclass
in a GDB and export it/append it to a gpkg.
outputGpkg = r"D:\export.gpkg"
inputGdb = r"D:\import.gdb"
fileEncoding = "UTF-8"
gdbFcs = [ "Feature1", "Feature2", "FeatureN" ] # eventually I want to find a routine to pull fc names from gdb and populate the array
for fc in gdbFcs:
gdbLyr = QgsVectorLayer(inputGdb + "|layername=" + fc, fc, "ogr")
print(gdbLyr)
#if gdbLyr.type() == QgsMapLayer.VectorLayer:
# _writer = QgsVectorFileWriter.writeAsVectorFormat(gdbLyr, outputGpkg, fileEncoding, gdbLyr.crs())
_writer = QgsVectorFileWriter.writeAsVectorFormat(gdbLyr, outputGpkg, fileEncoding, gdbLyr.crs())