0

I have the following map. I want the "North Loop Connector" on the east side of the map to have a different label. Is it possible to associate metadata with a line string then include that in the label? Presently I am using a custom format 'North Loop Connector\n'||round($length)||'M'.

The way I have been accomplishing this so far is to put each unique connector trail in a separate shape file, but that is going to make for a lot of shape files and is difficult to manage.

I've attached a 2nd image that shows what I have now, with the layer information open. Clicking either parts of the linestring brings up the same panel with no detail on the specific segment of the linestring. I need to be able to add data to the specific linestring segment, then display it in the expression for the layer.

enter image description here

enter image description here

3
  • I may be missing something but if you add a field with the values being your labels, then label using field that no metadata is needed, nor manual writing.
    – John
    Jul 10, 2023 at 20:33
  • 1
    Another option could be to use "rule-based" labelling in QGIS. You can set up conditions for specific labels / features and construct your label that way. All in one shapefile. Jul 11, 2023 at 0:08
  • I think the main problem is that I don't know how to get the data I need (ie: the trail name) into that portion of the linestring or how to reference it in the expression.
    – BrianV
    Jul 11, 2023 at 15:21

2 Answers 2

0

If I understand your question correctly then you just need to substitute the label text for the feature with the field that holds that data.
enter image description here

If not - perhaps add a bit more detail to the question relating to the features/attributes and what you need.

2
  • The expression you have is basically what I am doing now. Applying data to the feature would not work,. I need the data to live on a portion of the line string, is there a way to do that or no? In your proposed solution, would still have to apply my same workaround of creating separate layers for each piece of trail I want to have a different label. I updated my question above. Asked another way, can I click on a portion of a linestring, and apply data to only that portion, then use that in my expression?
    – BrianV
    Jul 11, 2023 at 15:10
  • 1
    A label derived from a linestring feature's attributes will apply to all segments of the linestring - one solution would be to split the linestrings and use a new field to hold the data you want to display
    – Aquamarine
    Jul 12, 2023 at 12:01
0

You can do this by creating a custom field at the shapefile level, then setting a specific value for the field at the feature level. To do this, enable Select Feature By Single Click

enter image description here

Once that is done, a toolbar button on the feature editing toolbar will appear. Click that button, and then you can set a different value for your field.

enter image description here

End result:

enter image description here

Your Answer

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

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