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.addAttribute(QgsField("label", QVariant.String))    

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()


        #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)


    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?

1 Answer 1


You must mix the data_type in the gpkg_contents table with the geometry_type_name in the gpkg_geometry_columns table. "Features" is what you are supposed to see as data_type.


The data_type specifies the type of content contained in the table, for example "features" per clause Features, "attributes" per clause Attributes, "tiles" per clause Tiles, or an implementer-defined value for other data tables per clause in an Extended GeoPackage.

But in gpkg_geometry_columns:

The geometry_type_name value in a gpkg_geometry_columns row SHALL be one of the uppercase geometry type names specified in Geometry Types (Normative).

  • Damn, I've had another look at the different GeoPackage databases and you're absolutely correct, I've mixed up the tables between the different databases and erroneously thought it was different. This was actually caused by me not understanding that the point values didn't have envelopes included in the binary header (where as all the other layer types did) and I was parsing them incorrectly thinking they did, leading me to believe it was storing it differently. Thanks for reality check.
    – Walter
    Feb 2, 2020 at 18:24

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.