Skip to main content
12 events
when toggle format what by license comment
Apr 13, 2017 at 12:33 history edited CommunityBot
replaced http://gis.stackexchange.com/ with https://gis.stackexchange.com/
Jan 31, 2017 at 3:27 comment added user52245 @iant I posted a link to another custom expression that will get the scale of your composer map programmatically.
Jan 31, 2017 at 3:27 history edited user52245 CC BY-SA 3.0
added link to another related script to more fully answer the original question
Jan 30, 2017 at 8:53 comment added user52245 @iant could you please confirm manually plugging in the scale works in attribute tables? If so, I'll edit my post to include an additional function to automate that.
Jan 26, 2017 at 18:51 history edited user52245 CC BY-SA 3.0
added 6 characters in body
Jan 26, 2017 at 9:40 comment added user52245 Does your map scale vary from page to page? Try manually putting in the scale instead of the @map_scale variable. my guess would be the attribute table has no way of knowing your map scale. (Because for instance you could have multiple map items in composer at different scales)
Jan 26, 2017 at 9:36 comment added Ian Turton The only minor issue is that the function doesn't seem to work as a filter in attribute tables in print composer.
Jan 26, 2017 at 9:05 vote accept Ian Turton
Jan 26, 2017 at 9:00 history edited user52245 CC BY-SA 3.0
added 93 characters in body; added 10 characters in body; added 71 characters in body
Jan 16, 2017 at 0:43 comment added user52245 You could use pil's imagefont.getsize(). That would give you an exact width of a string rendered in your chosen font, but I think that would have a major performance hit. The rough math above is far simpler, especially if you have hundreds of labels on screen
Jan 15, 2017 at 22:54 comment added Steven Kay I was thinking of something similar too. Especially if using map units and a projection in meters. The new(ish) geometry operators could also help here, assuming the labels are centered on the centroid. This will work better with a fixed-width (monospaced) font than a proportional font (Where a 'W' is much wider than an 'i', for example). You're on to something here, but I suspect proportional fonts and kerning will add complexity.
Jan 15, 2017 at 20:11 history answered user52245 CC BY-SA 3.0