> For the complete documentation index, see [llms.txt](https://developers.felt.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developers.felt.com/felt-style-language/types-of-visualizations/categorical-visualizations.md).

# Categorical visualizations

Categorical visualizations use a categorical attribute and the categories within it to apply styling to discrete categories of the attribute. (On raster datasets, categories are raw pixel values instead — see [Raster visualizations](/felt-style-language/types-of-visualizations/raster.md).)

Categorical visualizations are defined using `"type": "categorical"` and, for every supported style and label property used, either a single value that will apply to all categories or an array of different values for each category.

You can list the `categories` explicitly, or use a shortcut when you don't know the exact values: `{"type": "top", "count": N}` keeps the N most common values (vector), and `{"type": "all"}` covers every unique pixel value (raster). When `showOther: true` is combined with an **explicit** `categories` array, paint/label arrays need **N + 1** values — the extra one styles the "Other" bucket. For colors, prefer a [`@palette`](/felt-style-language/colors-and-palettes.md) shortcut over a hand-built array.

### Example

The Global Power Plants layer in Felt is an example of a categorical layer on a vector dataset

![](/files/DK11QRpkbreaYa33GkZ5)

and is defined by the following style

```jsx
{
  "version": "2.3.1",
  "type": "categorical",
  "config": {
    "categoricalAttribute": "primary_fuel",
    "categories": ["Solar", "Hydro", "Wind", "Gas", "Coal", "Oil", "Nuclear"],
    "showOther": false
  },
  "legend": {"displayName": {}},
  "attributes": {
    "capacity_mw": {"displayName": "Capacity (MW)"},
    "name": {"displayName": "Name"},
    "primary_fuel": {"displayName": "Primary Fuel"}
  },
  "paint": {
    "color": [
      "#E5C550",
      "#7AB6C2",
      "#AB71A4",
      "#CC615C",
      "#AD7B68",
      "#EB9360",
      "#DEA145"
    ],
    "isSandwiched": false,
    "opacity": 1,
    "size": [{"linear": [[3, 1.5], [20, 8]]}]
  }
}
```

Notice that we are saying that the `primary_fuel` data attribute will be used to categorize elements and that the possible values of that attribute that we are interested in are `"Nuclear"`, `"Oil"`, `"Coal"`, `"Gas"`, `"Wind"`, `"Hydro"` and `"Solar"`. Also notice that we are defining either a single value that will apply to all categories (i.e. `size`) or a value for each category (i.e. `color`)

### More patterns

**Palette shortcut + "top N".** When you don't know the exact category values, let Felt pick the most common ones and color them from a categorical palette:

```json
{
  "version": "2.3.1",
  "type": "categorical",
  "config": {
    "categoricalAttribute": "fuel_type",
    "categories": {"type": "top", "count": 10},
    "showOther": true
  },
  "paint": {
    "color": "@catPalette4",
    "size": 4,
    "strokeColor": "auto",
    "strokeWidth": 1,
    "opacity": 0.9,
    "isClickable": true
  },
  "legend": {"displayName": "auto"}
}
```

**A different icon per category.** `iconImage` and the paint arrays follow the same N (or N + 1 with `showOther`) pattern as `color`:

```json
{
  "version": "2.3.1",
  "type": "categorical",
  "config": {
    "categoricalAttribute": "facility_type",
    "categories": ["hospital", "school", "fire_station"],
    "showOther": true
  },
  "paint": {
    "iconImage": ["hospital", "school", "fire", "dot"],
    "iconFrame": "frame-circle",
    "color": ["#E74C3C", "#3498DB", "#E67E22", "#95A5A6"],
    "size": 4,
    "opacity": 0.9,
    "isClickable": true
  },
  "legend": {
    "displayName": {
      "hospital": "Hospitals",
      "school": "Schools",
      "fire_station": "Fire Stations"
    }
  }
}
```

**Styling "Other" separately.** With `showOther: true`, the trailing array element targets the "Other" bucket — here it is made smaller and more transparent than the named categories:

```json
{
  "version": "2.3.1",
  "type": "categorical",
  "config": {
    "categoricalAttribute": "status",
    "categories": ["active", "pending", "closed"],
    "showOther": true
  },
  "paint": {
    "color": ["#22C55E", "#F59E0B", "#EF4444", "#9CA3AF"],
    "size": [8, 8, 8, 4],
    "opacity": [0.9, 0.9, 0.9, 0.5],
    "strokeColor": "auto",
    "strokeWidth": 1
  },
  "legend": {"displayName": "auto"}
}
```

{% hint style="info" %}
Lines support color variation per category but not per-category icons. For categorical **polygons**, color is the only visual variable — keep to 5–7 categories so large filled areas stay distinguishable. Lines can still use a [paint array](/felt-style-language/style-definition-blocks/the-paint-block.md#paint-arrays-casing-and-layered-rendering) for casing under each colored category.
{% endhint %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://developers.felt.com/felt-style-language/types-of-visualizations/categorical-visualizations.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
