This article explains the term "tilestats" (tile statistics) and how they are actually very useful while working with your map, especially when adjusting the map style. You will learn how to find tilestats inside tiles.json file and how tilestats work for all attributes in data sources. You will also learn how to use tilestats while working with filters.
About tilestats
Tilestats or tile statistics are sometimes called also layer statistics of geostats. They aren't exactly statistics in the sense of the word. Tile statistics encapsulate comprehensive information regarding the layers within your tileset, offering insights into all attributes and geometry types associated with each layer. Tilestats also provide helpful information about available language mutations. In other words, tilestats give you a complete selection of parameters you can use when filtering features for your map.
You can find layer statistics here: Layers - Block (or Layer) - Data tab - Add Filter
In this picture, you can clearly see the historical center of Prague with just the "grass" class selected. The green areas show the grass, and the red areas show the areas that contain other (but not selected) classes - in this case, it is "farmland" and "wood". The brownish areas show places where several classes overlap (wood and grass). If we select "farmland" "grass" and "wood", the map will look like this:
And this is what the map looks like when you switch it to the style editor. This is the place where you can see/edit the map the way you want to publish it.
Example of tilestats for layer landcover
This is what the tilestats for the "landcover" layer look like inside the tiles.json code structure:
{
"layerCount": 1,
"layers": [
{
"layer": "landcover",
"geometry": "Polygon",
"attributes": [
{
"type": "String",
"values": [
"farmland",
"ice",
"wood",
"rock",
"grass",
"wetland",
"sand"
],
"attribute": "class"
},
{
"type": "String",
"values": [
"allotments",
"bare_rock",
"beach",
"bog",
"dune",
"scrub",
"shrubbery",
"farm",
"farmland",
"fell",
"forest",
"garden",
"glacier",
"grass",
"grassland",
"golf_course",
"heath",
"ice_shelf",
"mangrove",
"marsh",
"meadow",
"orchard",
"park",
"plant_nursery",
"recreation_ground",
"reedbed",
"saltern",
"saltmarsh",
"sand",
"scree",
"swamp",
"tidalflat",
"tundra",
"village_green",
"vineyard",
"wet_meadow",
"wetland",
"wood"
],
"attribute": "subclass"
}
],
"attributeCount": 2
}
]
}
This tilestats example for the place layer reveals the following technical details:
- Number of layers: 1
- Layer name: landcover
- Geometry type: Polygon
- Attributes: Two attributes are associated with this layer.
- "class" of type String with a predefined set of values
- "subclass: of type String with a predefined set of values
Example of tilestats for layer place
This is another example of the tilestats, this time for layer "place".
{
"languages": ["de","en","es","fr","it"],
"layerCount": 1,
"layers": {
"layer": "place",
"geometry": "Point",
"attributes": [
{
"type": "String",
"attribute": "name"
},
{
"type": "Number",
"values": [2,3,4,5,6],
"attribute": "capital"
},
{
"type": "String",
"values": [
"continent",
"country",
"state",
"province",
"city",
"town",
"village",
"hamlet",
"suburb",
"quarter",
"neighbourhood",
"isolated_dwelling",
"island"
],
"attribute": "class"
},
{
"max": 54,
"min": 0,
"type": "Number",
"attribute": "rank"
}
],
"attributeCount": 4
}
}
This tilestats example for the "place" layer reveals the following technical details:
- Number of layers: 1
- Layer name: place
- Geometry type: Point
- Attributes: Four attributes are associated with this layer.
- "name" of type String
- "capital" of type Number with values [2, 3, 4, 5, 6]
- "class" of type String with a predefined set of values
- "rank" of type Number with a minimum value of 0 and a maximum value of 54
- "name" of type String
- Available languages - language codes according to ISO 639-1 codes :
- "de" - German
- "en" - English
- "es" - Spanish
- "fr" - French
- "it" - Italian
- "de" - German
How does it enhance Customize
For attributes of string type - like "class" or "subclass", a list of possible values is something that is going to help you design your map quicker and in a convenient way without having to guess the values for each filter you will use.
For numeric attributes like "rank" or "elevation", Customize can dynamically render range sliders, allowing users to fine-tune the styling parameters with precision.
Now let's have a look at how you can use tilestats in all of the filters available in the Customize tool.
Filter types (visual filters)
Visual filters are great for anyone who wants to filter classes of each data source in their map in an easy and visually appealing way. Visual filters are designed to be as simple as possible and by simply clicking or un-clicking a certain feature, they let you choose what goes into your data preview and what does not.
They are easy to re-adjust or reset if you need to start from scratch. The reset button will mark all classes as "selected" (the exact opposite of what is shown in the picture).
The visual filters are easy to scrap if you do not need them anymore.
Filter types (native filters)
Native filters are the second type of filters available in the Customize tool. They will look familiar to those users who have been working with map design tools for several years already. They are, in fact, using a very similar flow as many open-source design tools (e.g. Maputnik). The native filters work with the keywords (class names) which are added to or deleted from the textbox. The downside of this approach is that you have to remember all the classes in your data source if you want to work efficiently. The advantage is that you see fewer features, and your workspace is not cluttered with unnecessary content. Which way will you choose?
You can see the native filter dialog window in the picture below.
Native filters also work with logical operators that allow the user set different conditions for displaying the classes inside the data source.
The native filters offer the following list of values (logical operators):
- == is queal to
- == is not queal to
- == is any of
- == is not any of
- == has any value
- == does not have value
Geometry contained (geometry icons and geometry selection)
Geometry is another very important parameter that defines each data source. The most common geometry types supported in the Customize tool are a point, a line string, a polygon, or "mixed" (valid for data sources where multiple geometries at once are present. The geometry type is also one of the tile statistics which helps users optimize their work with the application.
Data usage (red/green icons, understanding of how is data source used in style)
As shown at the beginning of this article different areas are shown in different colors relative to whether they are selected or not. In the first picture, it is just the "grass" class selected. The green areas show the grass, and the red areas show the areas that contain other (but not selected) classes - in this case, it is "farmland" and "wood".
And this is the same area, but this time no data source class is selected. The red color clearly shows the area where there are classes from the data source, but they are currently not selected. They are "grass", "farmland", and "wood". The red color is used to underline and stress the fact that there is something important missing on the map.
List of available languages
List of available languages is also contained within the tilestats. You can choose a language from the list in Settings -> Worldview -> Language
How to create layer statistics
MapTiler provides an open-source Tilestats tool which can be found in GitHub repository. More information about the tool and how to use it can be found in this article:
Tilestats tools - How to generate tilestats for your own vector tiles
Conclusion
The tilestats or tile statistics are a great way to show a quick overview of all layers attributes in any tileset. Using layer statistics is very useful while filtering the content which you want (or don't want) to use in your map. Filtering is possible in two ways - visual filtering and native filtering.
Useful links
Tilestats tools - How to generate tilestats for your own vector tiles
MapTiler Countries dataset
Origin of the MapTiler Planet data
How to download data from the MapTiler website
Comments
0 comments
Please sign in to leave a comment.