Mapbox Tiling Service
Beta

Union road features based on common attributes

This example uses a TIGER road export and performs a join on roads that have the same name. In the final tileset, this will turn multiple features into a single, continuous feature. Performing a union operation on features based on attributes is helpful for keeping tileset size down and preventing unnecessary dropped features.

{
"version": 1,
"layers": {
"roads": {
"source": "mapbox://tileset-source/{username}/tiger-data",
"minzoom": 5,
"maxzoom": 11,
"features": {
"filter": [
"all",
[ ">=", [ "get", "MTFCC" ], "S1000" ],
[ "<=", [ "get", "MTFCC" ], "S2000" ]
]
},
"tiles": {
"union": [
{
"group_by": [ "FULLNAME" ],
"maintain_direction": false
}
]
}
}
}
}
FieldDescriptionData type
sourceThe source data to use for this layer. Tileset sources are created with the Create a tileset source endpoint of Mapbox Tiling Service (MTS).String
minzoomSpecify the minimum zoom at which your tileset will be available. A value of 5 here ensures that the roads will be visible only when a user zooms in.Integer
maxzoomSpecify the maximum zoom at which your tileset will be available. A value of 11 here ensures that the roads will not be visible if a user zooms in significantly.Integer
features.filterKeep all features with an MTFCC attribute that has a value between S1000 and S2000 (TIGER's classifications for roads). This filter-expression performs a lexical comparison on this string attribute.Array<Expression>
tiles.unionUse the group_by method to union any features that have an identical FULLNAME attribute. Set maintain_direction to false so that block faces can be connected together no matter which direction their house numbering runs.Array<Object>
Was this page helpful?