developmentseed / developmentseed/lonboard

[BUG] `apply_categorical_cmap` does not work with boolean data

Open
#1,122 1 comment 0 reactions 0 assignees View on GitHub
bug
Dominant language
Python
Stars
964
Forks
54
Avg merge
5m
Merged PRs (30d)
1

Description

## Context

I have a dataset with a column with boolean data. I want to show that on a map, colored by whether the boolean field is true or false, using `apply_categorical_cmap`. A stripped down example:

```python
import numpy as np
from lonboard.colormap import apply_categorical_cmap

values = np.array([True, False])
get_color = apply_categorical_cmap(values, {False: [255, 0, 0], True: [0, 255, 0]})
```

## Resulting error

```
Traceback (most recent call last):
File "", line 1, in
File "/snipped/.venv/lib/python3.12/site-packages/lonboard/colormap.py", line 207, in apply_categorical_cmap
values = ChunkedArray(dictionary_encode(values))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Exception: C Data interface error: C Data interface error: Compute error: Boolean not supported in rank
```

## Environment

- OS: Arch Linux
- Lonboard Version: 0.14.0

It is not a big problem to cast the data to integer 0/1 first, but just thought I'd report it as it would be nice if it works out of the box :).

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.