I have labels that are being cut off when rendered in Mapbox Studio. As I understand it there is a 256×256 tile that gets rendered and if the label text "bleeds" into another tile it may get cut off. Research led me to a 'buffer-size:' thing but that isn't making any difference whether I set it to 0, 512, or 60000.
[GIS] How to fix label clipping in Mapbox Studio
mapboxtiles
Related Solutions
Setting the text-avoid-edges attribute to true probably can help. This should place the labels near the center of the tile, so they are less likely to be cut.
//source for strait label data is jfactory.11d0a600
#strait_labels [zoom=12] {
text-name: [name];
text-character-spacing: 7;
text-face-name: "Quintessential Regular";
text-fill: darken(saturate(@water, 20), 10);
text-halo-fill: @glacier;
text-halo-radius: 1;
text-halo-rasterizer: fast;
text-size: 36;
text-placement: line;
text-spacing: 360; //ineffective?
text-opacity: .7;
text-repeat-distance: 10; //ineffective?
//try this:
text-avoid-edges: true;
}
I did further research, and the following three "vendorOption" parameters were recommended where labels are left off when you really want them labeled in the tiles. I'll explain each briefly and why it did or did not help in my case.
<VendorOption name="spaceAround">-1</VendorOption>
<VendorOption name="conflictResolution">false</VendorOption>
<VendorOption name="partials">true</VendorOption>
The first "spaceAround" option, if less than zero, will draw labels even if they overlap labels that are already drawn, often making one or more illegible. This was not my issue. My labels were well spaced apart, just some were disappearing at certain zoom levels.
The next, "conflictResolution", I believe also says to draw the label even if it may conflict with another. I have not added this one, I don't think it is relevant to my issue.
The final "partials" set to true fixed my problem. If the tile processor thought the label would overlap the edge of the tile, it was removing it. That is the default behavior. That was causing them to disappear when zoomed in, depending on where it landed on the tile it existed on at that zoom level. So they were "randomly" disappearing. Once I set this to true, the labels all appear at every zoom level. So my problem is now solved.
I did set some "gutter" values to be up to 200 in some cases, in my attempts to resolve the issue. This may be slowing down my tile generation. I'll now probably go drop those down again. I think I want some gutter, so that the labels can overlap tile boundaries and still draw nicely.
So if you look at the SLD above, at the very end of it I've simply added this one VendorOption after the end of the Fill node:
</Fill>
<VendorOption name="partials">true</VendorOption>
</TextSymbolizer>
This is where you want to put it, at the very end of your TextSymbolizer.
Best Answer
Buffers are now handled in the source project, not in the style project (in TileMill, one project controlled both data source and style; in MapBox Studio, they are now two different projects).
So, assuming you have access to the source file, click on the label layer, and under the configure tab increase Buffer Size to a number half the width of your widest label (or just estimate).
See the source quickstart, source manual, and styling labels doc.
Edit If large labels are still an issue even with increased buffer size, it's possible to shrink text size for labels with high letter counts using regex expressions in the selectors. Something like
@text-size: 22;
See this answer to another question on conditional labeling.