View a markdown version of this page

H3_Polyfill - Amazon Redshift

Amazon Redshift will no longer support the use of Python UDFs after June 30, 2026. We will start enforcing it in phases. For more information on the details of Python end of life and migration options, see the blog post that was published on June 30, 2025.

H3_Polyfill

H3_Polyfill returns the corresponding H3 cell IDs that correspond to the hexagons and pentagons that are contained in the input polygon of the given resolution. For information about H3 indexing, see H3.

Syntax

H3_Polyfill(geom, resolution)

Arguments

geom

A value of data type GEOMETRY or an expression that evaluates to a GEOMETRY type. The geom must be a POLYGON.

resolution

A value of data type INTEGER or an expression that evaluates to an INTEGER type. The value represents the resolution of the H3 grid system. The value must be an integer between 0–15, inclusive. With 0 being the coarsest and 15 being the finest.

Return type

SUPER – represents a list of H3 cell IDs.

If geom is not a POLYGON, then an error is returned.

If resolution is out of bounds, then an error is returned.

If geom is empty, then NULL is returned.

Examples

The following SQL returns a SUPER data type array of H3 cell IDs from a polygon and resolution 4.

SELECT H3_Polyfill(ST_GeomFromText('POLYGON((0 0, 0 1, 1 1, 1 0, 0 0))'), 4);
h3_polyfill ---------------------------------------------------------------------------------------------------------------------------------------------------------- [596538848238895103,596538805289222143,596538856828829695,596538813879156735,596537920525959167,596538685030137855,596538693620072447,596538839648960511]