I'm attempting to export data from the points layer imported from an Open Street Maps pbf file to a GeoPackage file.
In both the script I write to automate the export as well as when I export using QGIS, the data_type column in the gpkg_contents table is set to 'features'.
This is unexpected because when I usually do any export to GeoPackage using any of the other layers, this data_type column is set to one of the geometry types defined by the GeoPackage standard.
My script to export the data to a new DB:
labelDB = QgsVectorLayer("Point", "labels", "memory")
labelDB.startEditing()
labelDB.addAttribute(QgsField("label", QVariant.String))
labelDB.commitChanges()
pointsLayer = QgsVectorLayer("%s/%s|layername=%s" % (input, file, "points"), "points", "ogr")
if pointsLayer.isValid():
pointsLayer.setSubsetString("place = 'country'")
#move the resulting features to the labels db
for feature in pointsLayer.getFeatures():
labelFeature = QgsFeature()
labelFeature.setFields(labelDB.fields())
labelFeature.setGeometry(feature.geometry())
#get the english name for the country
name = ""
otherTags = feature["other_tags"].split(",")
for tag in otherTags:
kvp = tag.split('=>')
if kvp[0].replace("\"", "") == "name:en":
name = kvp[1].replace("\"", "")
labelFeature.setAttribute("label", name)
labelDB.startEditing()
labelDB.addFeature(labelFeature)
labelDB.commitChanges()
QgsVectorFileWriter.writeAsVectorFormat(labelDB, labelsOutDir + "/labels", "utf-8", labelDB.crs(), "GPKG")
How would I go about ensuring that the data is stored as Points instead of features?