I want some alternate to this code as this code just labels only the current feature in the loop .

FEATURES = point_layer3.selectedFeatures()
for  f in FEATURES:        
    total = f['parkeer_approx']
    alloted = parking_capacity[f.id()-int(1)]
    print(str(f['identificatie']), alloted['parking_id'])
    layer = point_layer3
    layer.setCustomProperty("labeling", "pal")
    layer.setCustomProperty("labeling/enabled", "true")
    layer.setCustomProperty("labeling/fontFamily", "Arial")
    layer.setCustomProperty("labeling/fontSize", "10")
    layer.setCustomProperty("labeling/isExpression", "true")
    layer.setCustomProperty("labeling/fieldName", 'CASE WHEN "identificatie" = \'{}\' THEN "parkeer_approx" ELSE '' END'.format(str(f['identificatie'])))

    layer.setCustomProperty("labeling/placement", "2")

What I wanted to do is that I want to label all the features if they satisfies the CASE. Suppose there are 8 features selected in the layer so i wanted to label only those 8 features one by one if they satisfies the CASE.

  • look at this gis.stackexchange.com/a/191513/49538
    – Fran Raga
    Jul 31, 2019 at 6:29
  • Why do u iterate over features with per layer settings ?
    – Snaileater
    Jul 31, 2019 at 8:15
  • @snaileater i have try it other way around by just keeping the expression in the for loop so i can check the condition for each feature but that doesn't helped too.. Jul 31, 2019 at 9:56
  • @FranRaga i have three conditions to be checked for each feature and assign that color or label according to that condition and that link you shared just works if i have a single condition for eg : if i have to show parkings who have more than 20 space... Jul 31, 2019 at 10:00


Your Answer

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

Browse other questions tagged or ask your own question.