1

After creating a user field in the auxiliary storage, how can I populate this field with a default value? Normally I'd do this in the attribute table with "Update All" or "Update Selected", but the auxiliary fields aren't available in the pulldown menu. The same is true in Field Calculator.

I've also tried Select All, and then Edit->Modify Attributes of Selected Features. I can enter the default value in this dialogue, but when I click OK the fields do not actually change. I get the same result if I try to enter a default value in the Attribute Form editor in Layer Properties (and I've selected "Apply default value on update").

2

I ran into this with the labeling tools in QGIS 3.0. I had styled the labels with data from the features, but needed to make some little adjustments. Moving a label removed the data defined styling for all my features. Ugh!

It turned out the labeling tools had overwritten my styling functions, so I had to copy the data to the auxiliary layer. Using the Python console:

project = QgsProject.instance()
layer = project.mapLayersByName('mylayer')[0] 
auxLayer = layer.auxiliaryLayer()
auxFields = auxLayer.fields()

for feature in layer.getFeatures():
    auxFeature = QgsFeature(auxFields)
    attribs = {
        'ASPK': feature.attribute('fid'),
        'labeling_labelrotation': feature.attribute('myrotation'),
        'labeling_size': feature.attribute('mysize'),
        'labeling_buffersize': feature.attribute('mysize') / 8
        }
    for key in attribs:
        auxFeature[key]=attribs[key]
    auxLayer.addFeature(auxFeature)

The field ASPK in the auxiliary layer contains the value of the field you have used to join the features with auxiliary storage. Also, it seems that the auxiliary layer does not have any features after it's created, so you have to create them as well.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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