pg_healpix
pg_healpix · Provides PostgreSQL functions that convert sky coordinates to and from HEALPix nested and ring pixel identifiers.
Overview
| ID | Extension | Package | Version | Category | License | Language |
|---|---|---|---|---|---|---|
| 100505 | pg_healpix | pg_healpix | 1.0 | GIS | GPL-2.0 | C |
PostgreSQL · 10, 11, 12, 13
Usage
Sources:
- pg_healpix README at the reviewed commit
- Version 1.0 SQL interface
- Coordinate conversion implementation
pg_healpix exposes four C functions for converting astronomical right ascension and declination to HEALPix pixel identifiers and back. It supports both nested and ring pixel ordering. Inputs and returned coordinates are degrees; the reverse functions return a two-element array ordered as right ascension and declination.
Core Workflow
Use the inverse function with the same ordering scheme as the forward conversion. The returned coordinates represent the center of the selected HEALPix pixel, so a coordinate-to-pixel-to-coordinate round trip is a quantization operation rather than an exact restoration of the original point.
Function Index
healpix_ang2ipix_nest(bigint, double precision, double precision)returns a nestedipix.healpix_ang2ipix_ring(bigint, double precision, double precision)returns a ringipix.healpix_ipix2ang_nest(bigint, bigint)returns a right-ascension/declination array for a nestedipix.healpix_ipix2ang_ring(bigint, bigint)returns a right-ascension/declination array for a ringipix.
All four functions are declared IMMUTABLE, PARALLEL SAFE, and STRICT, making them eligible for expression indexes, generated expressions, and parallel plans when PostgreSQL’s normal rules permit.
Input Constraints
nsidemust be a positive power of two no greater than8192.ipixmust be at least zero and less than12 * nside * nside.- Declination must map to a polar angle between zero and pi, which corresponds to the conventional range from
-90through90degrees. Right ascension is converted from degrees and may wrap beyond one revolution. - Non-finite angular inputs return
NULL; SQL null inputs also returnNULLbecause the functions are strict.
Catalog and control identify version 1.0. Upstream publishes no current PostgreSQL compatibility matrix, and the catalog only records older server majors; test compilation, numerical agreement, index behavior, and representative boundary values on the exact server major and HEALPix tooling used by the application.