# placekey

[Placekey](https://www.placekey.io/faq) is a free and open universal standard identifier for any physical place, so that the data pertaining to those places can be shared across organizations easily. Since Placekey is based on H3, here we offer a way to transform to and from that index and delegate any extra functionality to H3 itself.

You can learn more about Placekey on [their website](https://www.placekey.io/) or in the [Spatial Indexes section](https://docs.carto.com/data-and-analysis/analytics-toolbox-for-bigquery/key-concepts/spatial-indexes#placekey) of this documentation.

## PLACEKEY\_FROMH3 <a href="#placekey_fromh3" id="placekey_fromh3"></a>

```sql
PLACEKEY_FROMH3(h3index)
```

**Description**

Returns the placekey equivalent of the given H3 index.

**Input parameters**

* `h3index`: `STRING` H3 identifier.

**Return type**

`STRING`

**Example**

{% tabs %}
{% tab title="carto-un" %}

```sql
SELECT `carto-un`.carto.PLACEKEY_FROMH3('84390cbffffffff');
-- @7dd-dc3-52k
```

{% endtab %}

{% tab title="carto-un-eu" %}

```sql
SELECT `carto-un-eu`.carto.PLACEKEY_FROMH3('84390cbffffffff');
-- @7dd-dc3-52k
```

{% endtab %}

{% tab title="manual" %}

```sql
SELECT carto.PLACEKEY_FROMH3('84390cbffffffff');
-- @7dd-dc3-52k
```

{% endtab %}
{% endtabs %}

## PLACEKEY\_ISVALID <a href="#placekey_isvalid" id="placekey_isvalid"></a>

```sql
PLACEKEY_ISVALID(placekey)
```

**Description**

Returns a boolean value `true` when the given string represents a valid Placekey, `false` otherwise.

**Input parameters**

* `placekey`: `STRING` Placekey identifier.

**Return type**

`BOOL`

**Examples**

{% tabs %}
{% tab title="carto-un" %}

```sql
SELECT `carto-un`.carto.PLACEKEY_ISVALID('@7dd-dc3-52k');
-- TRUE
```

{% endtab %}

{% tab title="carto-un-eu" %}

```sql
SELECT `carto-un-eu`.carto.PLACEKEY_ISVALID('@7dd-dc3-52k');
-- TRUE
```

{% endtab %}

{% tab title="manual" %}

```sql
SELECT carto.PLACEKEY_ISVALID('@7dd-dc3-52k');
-- TRUE
```

{% endtab %}
{% endtabs %}

{% tabs %}
{% tab title="carto-un" %}

```sql
SELECT `carto-un`.carto.PLACEKEY_ISVALID('7dd-dc3-52k');
-- TRUE
```

{% endtab %}

{% tab title="carto-un-eu" %}

```sql
SELECT `carto-un-eu`.carto.PLACEKEY_ISVALID('7dd-dc3-52k');
-- TRUE
```

{% endtab %}

{% tab title="manual" %}

```sql
SELECT carto.PLACEKEY_ISVALID('7dd-dc3-52k');
-- TRUE
```

{% endtab %}
{% endtabs %}

{% tabs %}
{% tab title="carto-un" %}

```sql
SELECT `carto-un`.carto.PLACEKEY_ISVALID('x');
-- FALSE
```

{% endtab %}

{% tab title="carto-un-eu" %}

```sql
SELECT `carto-un-eu`.carto.PLACEKEY_ISVALID('x');
-- FALSE
```

{% endtab %}

{% tab title="manual" %}

```sql
SELECT carto.PLACEKEY_ISVALID('x');
-- FALSE
```

{% endtab %}
{% endtabs %}

## PLACEKEY\_TOH3 <a href="#placekey_toh3" id="placekey_toh3"></a>

```sql
PLACEKEY_TOH3(placekey)
```

**Description**

Returns the H3 index equivalent of the given placekey.

**Input parameters**

* `placekey`: `STRING` Placekey identifier.

**Return type**

`STRING`

**Example**

{% tabs %}
{% tab title="carto-un" %}

```sql
SELECT `carto-un`.carto.PLACEKEY_TOH3('@7dd-dc3-52k');
-- 8a390cbffffffff
```

{% endtab %}

{% tab title="carto-un-eu" %}

```sql
SELECT `carto-un-eu`.carto.PLACEKEY_TOH3('@7dd-dc3-52k');
-- 8a390cbffffffff
```

{% endtab %}

{% tab title="manual" %}

```sql
SELECT carto.PLACEKEY_TOH3('@7dd-dc3-52k');
-- 8a390cbffffffff
```

{% endtab %}
{% endtabs %}

<img src="https://3029946802-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FybPdpmLltPkzGFvz7m8A%2Fuploads%2Fgit-blob-1c82685e4e434438152a8e3d867df996413489fe%2Feu-flag-website.png?alt=media&#x26;token=4343f6e5-973a-4e9a-8e14-50366a086f72" alt="EU flag" data-size="line">This project has received funding from the [European Union’s Horizon 2020](https://ec.europa.eu/programmes/horizon2020/en) research and innovation programme under grant agreement No 960401.


---

# Agent Instructions: 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:

```
GET https://docs.carto.com/data-and-analysis/analytics-toolbox-for-bigquery/sql-reference/placekey.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
