qdgc
Overview
| Package | Version | Category | License | Language |
|---|---|---|---|---|
qdgc | 0.1.0 | GIS | Apache-2.0 | SQL |
| ID | Extension | Bin | Lib | Load | Create | Trust | Reloc | Schema |
|---|---|---|---|---|---|---|---|---|
| 1700 | qdgc | No | No | No | Yes | Yes | Yes | - |
| 1710 | qdgc_postgis | No | No | No | Yes | No | Yes | - |
| Related | h3 pgrouting pg_geohash q3c postgis_topology pg_polyline pg_eviltransform mobilitydb earthdistance pointcloud |
|---|---|
| Depended By | qdgc_postgis |
PGXN distribution qdgc also ships qdgc_postgis; the GitHub v0.1.0 tag belongs to qdgc-py and is not this PGXN release.
Version
| Type | Repo | Version | PG Ver | Package | Deps |
|---|---|---|---|---|---|
| EXT | PIGSTY | 0.1.0 | 1817161514 | qdgc | - |
| RPM | PIGSTY | 0.1.0 | 1817161514 | qdgc_$v | - |
| DEB | PIGSTY | 0.1.0 | 1817161514 | postgresql-$v-qdgc | - |
| OS / PG | PG18 | PG17 | PG16 | PG15 | PG14 |
|---|---|---|---|---|---|
| el8.x86_64 | PIGSTY 0.1.0 el8.x86_64.pg18 : qdgc_18 qdgc_18-0.1.0-1PIGSTY.el8.noarch.rpm
| PIGSTY 0.1.0 el8.x86_64.pg17 : qdgc_17 qdgc_17-0.1.0-1PIGSTY.el8.noarch.rpm
| PIGSTY 0.1.0 el8.x86_64.pg16 : qdgc_16 qdgc_16-0.1.0-1PIGSTY.el8.noarch.rpm
| PIGSTY 0.1.0 el8.x86_64.pg15 : qdgc_15 qdgc_15-0.1.0-1PIGSTY.el8.noarch.rpm
| PIGSTY 0.1.0 el8.x86_64.pg14 : qdgc_14 qdgc_14-0.1.0-1PIGSTY.el8.noarch.rpm
|
| el8.aarch64 | PIGSTY 0.1.0 el8.aarch64.pg18 : qdgc_18 qdgc_18-0.1.0-1PIGSTY.el8.noarch.rpm
| PIGSTY 0.1.0 el8.aarch64.pg17 : qdgc_17 qdgc_17-0.1.0-1PIGSTY.el8.noarch.rpm
| PIGSTY 0.1.0 el8.aarch64.pg16 : qdgc_16 qdgc_16-0.1.0-1PIGSTY.el8.noarch.rpm
| PIGSTY 0.1.0 el8.aarch64.pg15 : qdgc_15 qdgc_15-0.1.0-1PIGSTY.el8.noarch.rpm
| PIGSTY 0.1.0 el8.aarch64.pg14 : qdgc_14 qdgc_14-0.1.0-1PIGSTY.el8.noarch.rpm
|
| el9.x86_64 | PIGSTY 0.1.0 el9.x86_64.pg18 : qdgc_18 qdgc_18-0.1.0-1PIGSTY.el9.noarch.rpm
| PIGSTY 0.1.0 el9.x86_64.pg17 : qdgc_17 qdgc_17-0.1.0-1PIGSTY.el9.noarch.rpm
| PIGSTY 0.1.0 el9.x86_64.pg16 : qdgc_16 qdgc_16-0.1.0-1PIGSTY.el9.noarch.rpm
| PIGSTY 0.1.0 el9.x86_64.pg15 : qdgc_15 qdgc_15-0.1.0-1PIGSTY.el9.noarch.rpm
| PIGSTY 0.1.0 el9.x86_64.pg14 : qdgc_14 qdgc_14-0.1.0-1PIGSTY.el9.noarch.rpm
|
| el9.aarch64 | PIGSTY 0.1.0 el9.aarch64.pg18 : qdgc_18 qdgc_18-0.1.0-1PIGSTY.el9.noarch.rpm
| PIGSTY 0.1.0 el9.aarch64.pg17 : qdgc_17 qdgc_17-0.1.0-1PIGSTY.el9.noarch.rpm
| PIGSTY 0.1.0 el9.aarch64.pg16 : qdgc_16 qdgc_16-0.1.0-1PIGSTY.el9.noarch.rpm
| PIGSTY 0.1.0 el9.aarch64.pg15 : qdgc_15 qdgc_15-0.1.0-1PIGSTY.el9.noarch.rpm
| PIGSTY 0.1.0 el9.aarch64.pg14 : qdgc_14 qdgc_14-0.1.0-1PIGSTY.el9.noarch.rpm
|
| el10.x86_64 | PIGSTY 0.1.0 el10.x86_64.pg18 : qdgc_18 qdgc_18-0.1.0-1PIGSTY.el10.noarch.rpm
| PIGSTY 0.1.0 el10.x86_64.pg17 : qdgc_17 qdgc_17-0.1.0-1PIGSTY.el10.noarch.rpm
| PIGSTY 0.1.0 el10.x86_64.pg16 : qdgc_16 qdgc_16-0.1.0-1PIGSTY.el10.noarch.rpm
| PIGSTY 0.1.0 el10.x86_64.pg15 : qdgc_15 qdgc_15-0.1.0-1PIGSTY.el10.noarch.rpm
| PIGSTY 0.1.0 el10.x86_64.pg14 : qdgc_14 qdgc_14-0.1.0-1PIGSTY.el10.noarch.rpm
|
| el10.aarch64 | PIGSTY 0.1.0 el10.aarch64.pg18 : qdgc_18 qdgc_18-0.1.0-1PIGSTY.el10.noarch.rpm
| PIGSTY 0.1.0 el10.aarch64.pg17 : qdgc_17 qdgc_17-0.1.0-1PIGSTY.el10.noarch.rpm
| PIGSTY 0.1.0 el10.aarch64.pg16 : qdgc_16 qdgc_16-0.1.0-1PIGSTY.el10.noarch.rpm
| PIGSTY 0.1.0 el10.aarch64.pg15 : qdgc_15 qdgc_15-0.1.0-1PIGSTY.el10.noarch.rpm
| PIGSTY 0.1.0 el10.aarch64.pg14 : qdgc_14 qdgc_14-0.1.0-1PIGSTY.el10.noarch.rpm
|
| d12.x86_64 | PIGSTY 0.1.0 d12.x86_64.pg18 : postgresql-18-qdgc postgresql-18-qdgc_0.1.0-1PIGSTY~bookworm_all.deb
| PIGSTY 0.1.0 d12.x86_64.pg17 : postgresql-17-qdgc postgresql-17-qdgc_0.1.0-1PIGSTY~bookworm_all.deb
| PIGSTY 0.1.0 d12.x86_64.pg16 : postgresql-16-qdgc postgresql-16-qdgc_0.1.0-1PIGSTY~bookworm_all.deb
| PIGSTY 0.1.0 d12.x86_64.pg15 : postgresql-15-qdgc postgresql-15-qdgc_0.1.0-1PIGSTY~bookworm_all.deb
| PIGSTY 0.1.0 d12.x86_64.pg14 : postgresql-14-qdgc postgresql-14-qdgc_0.1.0-1PIGSTY~bookworm_all.deb
|
| d12.aarch64 | PIGSTY 0.1.0 d12.aarch64.pg18 : postgresql-18-qdgc postgresql-18-qdgc_0.1.0-1PIGSTY~bookworm_all.deb
| PIGSTY 0.1.0 d12.aarch64.pg17 : postgresql-17-qdgc postgresql-17-qdgc_0.1.0-1PIGSTY~bookworm_all.deb
| PIGSTY 0.1.0 d12.aarch64.pg16 : postgresql-16-qdgc postgresql-16-qdgc_0.1.0-1PIGSTY~bookworm_all.deb
| PIGSTY 0.1.0 d12.aarch64.pg15 : postgresql-15-qdgc postgresql-15-qdgc_0.1.0-1PIGSTY~bookworm_all.deb
| PIGSTY 0.1.0 d12.aarch64.pg14 : postgresql-14-qdgc postgresql-14-qdgc_0.1.0-1PIGSTY~bookworm_all.deb
|
| d13.x86_64 | PIGSTY 0.1.0 d13.x86_64.pg18 : postgresql-18-qdgc postgresql-18-qdgc_0.1.0-1PIGSTY~trixie_all.deb
| PIGSTY 0.1.0 d13.x86_64.pg17 : postgresql-17-qdgc postgresql-17-qdgc_0.1.0-1PIGSTY~trixie_all.deb
| PIGSTY 0.1.0 d13.x86_64.pg16 : postgresql-16-qdgc postgresql-16-qdgc_0.1.0-1PIGSTY~trixie_all.deb
| PIGSTY 0.1.0 d13.x86_64.pg15 : postgresql-15-qdgc postgresql-15-qdgc_0.1.0-1PIGSTY~trixie_all.deb
| PIGSTY 0.1.0 d13.x86_64.pg14 : postgresql-14-qdgc postgresql-14-qdgc_0.1.0-1PIGSTY~trixie_all.deb
|
| d13.aarch64 | PIGSTY 0.1.0 d13.aarch64.pg18 : postgresql-18-qdgc postgresql-18-qdgc_0.1.0-1PIGSTY~trixie_all.deb
| PIGSTY 0.1.0 d13.aarch64.pg17 : postgresql-17-qdgc postgresql-17-qdgc_0.1.0-1PIGSTY~trixie_all.deb
| PIGSTY 0.1.0 d13.aarch64.pg16 : postgresql-16-qdgc postgresql-16-qdgc_0.1.0-1PIGSTY~trixie_all.deb
| PIGSTY 0.1.0 d13.aarch64.pg15 : postgresql-15-qdgc postgresql-15-qdgc_0.1.0-1PIGSTY~trixie_all.deb
| PIGSTY 0.1.0 d13.aarch64.pg14 : postgresql-14-qdgc postgresql-14-qdgc_0.1.0-1PIGSTY~trixie_all.deb
|
| u22.x86_64 | PIGSTY 0.1.0 u22.x86_64.pg18 : postgresql-18-qdgc postgresql-18-qdgc_0.1.0-1PIGSTY~jammy_all.deb
| PIGSTY 0.1.0 u22.x86_64.pg17 : postgresql-17-qdgc postgresql-17-qdgc_0.1.0-1PIGSTY~jammy_all.deb
| PIGSTY 0.1.0 u22.x86_64.pg16 : postgresql-16-qdgc postgresql-16-qdgc_0.1.0-1PIGSTY~jammy_all.deb
| PIGSTY 0.1.0 u22.x86_64.pg15 : postgresql-15-qdgc postgresql-15-qdgc_0.1.0-1PIGSTY~jammy_all.deb
| PIGSTY 0.1.0 u22.x86_64.pg14 : postgresql-14-qdgc postgresql-14-qdgc_0.1.0-1PIGSTY~jammy_all.deb
|
| u22.aarch64 | PIGSTY 0.1.0 u22.aarch64.pg18 : postgresql-18-qdgc postgresql-18-qdgc_0.1.0-1PIGSTY~jammy_all.deb
| PIGSTY 0.1.0 u22.aarch64.pg17 : postgresql-17-qdgc postgresql-17-qdgc_0.1.0-1PIGSTY~jammy_all.deb
| PIGSTY 0.1.0 u22.aarch64.pg16 : postgresql-16-qdgc postgresql-16-qdgc_0.1.0-1PIGSTY~jammy_all.deb
| PIGSTY 0.1.0 u22.aarch64.pg15 : postgresql-15-qdgc postgresql-15-qdgc_0.1.0-1PIGSTY~jammy_all.deb
| PIGSTY 0.1.0 u22.aarch64.pg14 : postgresql-14-qdgc postgresql-14-qdgc_0.1.0-1PIGSTY~jammy_all.deb
|
| u24.x86_64 | PIGSTY 0.1.0 u24.x86_64.pg18 : postgresql-18-qdgc postgresql-18-qdgc_0.1.0-1PIGSTY~noble_all.deb
| PIGSTY 0.1.0 u24.x86_64.pg17 : postgresql-17-qdgc postgresql-17-qdgc_0.1.0-1PIGSTY~noble_all.deb
| PIGSTY 0.1.0 u24.x86_64.pg16 : postgresql-16-qdgc postgresql-16-qdgc_0.1.0-1PIGSTY~noble_all.deb
| PIGSTY 0.1.0 u24.x86_64.pg15 : postgresql-15-qdgc postgresql-15-qdgc_0.1.0-1PIGSTY~noble_all.deb
| PIGSTY 0.1.0 u24.x86_64.pg14 : postgresql-14-qdgc postgresql-14-qdgc_0.1.0-1PIGSTY~noble_all.deb
|
| u24.aarch64 | PIGSTY 0.1.0 u24.aarch64.pg18 : postgresql-18-qdgc postgresql-18-qdgc_0.1.0-1PIGSTY~noble_all.deb
| PIGSTY 0.1.0 u24.aarch64.pg17 : postgresql-17-qdgc postgresql-17-qdgc_0.1.0-1PIGSTY~noble_all.deb
| PIGSTY 0.1.0 u24.aarch64.pg16 : postgresql-16-qdgc postgresql-16-qdgc_0.1.0-1PIGSTY~noble_all.deb
| PIGSTY 0.1.0 u24.aarch64.pg15 : postgresql-15-qdgc postgresql-15-qdgc_0.1.0-1PIGSTY~noble_all.deb
| PIGSTY 0.1.0 u24.aarch64.pg14 : postgresql-14-qdgc postgresql-14-qdgc_0.1.0-1PIGSTY~noble_all.deb
|
| u26.x86_64 | PIGSTY 0.1.0 u26.x86_64.pg18 : postgresql-18-qdgc postgresql-18-qdgc_0.1.0-1PIGSTY~resolute_all.deb
| PIGSTY 0.1.0 u26.x86_64.pg17 : postgresql-17-qdgc postgresql-17-qdgc_0.1.0-1PIGSTY~resolute_all.deb
| PIGSTY 0.1.0 u26.x86_64.pg16 : postgresql-16-qdgc postgresql-16-qdgc_0.1.0-1PIGSTY~resolute_all.deb
| PIGSTY 0.1.0 u26.x86_64.pg15 : postgresql-15-qdgc postgresql-15-qdgc_0.1.0-1PIGSTY~resolute_all.deb
| PIGSTY 0.1.0 u26.x86_64.pg14 : postgresql-14-qdgc postgresql-14-qdgc_0.1.0-1PIGSTY~resolute_all.deb
|
| u26.aarch64 | PIGSTY 0.1.0 u26.aarch64.pg18 : postgresql-18-qdgc postgresql-18-qdgc_0.1.0-1PIGSTY~resolute_all.deb
| PIGSTY 0.1.0 u26.aarch64.pg17 : postgresql-17-qdgc postgresql-17-qdgc_0.1.0-1PIGSTY~resolute_all.deb
| PIGSTY 0.1.0 u26.aarch64.pg16 : postgresql-16-qdgc postgresql-16-qdgc_0.1.0-1PIGSTY~resolute_all.deb
| PIGSTY 0.1.0 u26.aarch64.pg15 : postgresql-15-qdgc postgresql-15-qdgc_0.1.0-1PIGSTY~resolute_all.deb
| PIGSTY 0.1.0 u26.aarch64.pg14 : postgresql-14-qdgc postgresql-14-qdgc_0.1.0-1PIGSTY~resolute_all.deb
|
Build
You can build the RPM / DEB packages for qdgc using pig build:
pig build pkg qdgc # build RPM / DEB packages
Install
You can install qdgc directly. First, make sure the PGDG and PIGSTY repositories are added and enabled:
pig repo add pgsql -u # Add repo and update cache
Install the extension using pig or apt/yum/dnf:
pig install qdgc; # Install for current active PG version
pig ext install -y qdgc -v 18 # PG 18
pig ext install -y qdgc -v 17 # PG 17
pig ext install -y qdgc -v 16 # PG 16
pig ext install -y qdgc -v 15 # PG 15
pig ext install -y qdgc -v 14 # PG 14
dnf install -y qdgc_18 # PG 18
dnf install -y qdgc_17 # PG 17
dnf install -y qdgc_16 # PG 16
dnf install -y qdgc_15 # PG 15
dnf install -y qdgc_14 # PG 14
apt install -y postgresql-18-qdgc # PG 18
apt install -y postgresql-17-qdgc # PG 17
apt install -y postgresql-16-qdgc # PG 16
apt install -y postgresql-15-qdgc # PG 15
apt install -y postgresql-14-qdgc # PG 14
Create Extension:
CREATE EXTENSION qdgc;
Usage
Sources:
- PGXN qdgc 0.1.0 release
- Official 0.1.0 README
- Official qdgc control file
- Official qdgc 0.1.0 extension SQL
qdgc 0.1.0 is the trusted, relocatable, pure-SQL core of the QDGC extension family. It encodes longitude and latitude as Extended Quarter Degree Grid Cell codes, decodes their bounds, navigates the prefix hierarchy, reports level metrics, and fills longitude/latitude bounding boxes. It has no PostGIS or compiled-library dependency; geometry, geography, and polygon-fill operations belong to the companion qdgc_postgis extension.
Core Workflow
CREATE EXTENSION qdgc;
-- qdgc_encode uses (longitude, latitude, level).
SELECT qdgc_encode(31.4, 2.7, 5);
-- E031N02ADBAC
-- The h3-style alias reverses the coordinate arguments.
SELECT qdgc_latlng_to_cell(2.7, 31.4, 5);
SELECT *
FROM qdgc_cell_to_bounds('E031N02ADBAC');
SELECT qdgc_cell_to_parent('E031N02ADBAC', 3);
SELECT * FROM qdgc_cell_to_children('E031N02AD', 5);
QDGC hierarchy is encoded directly in the text: a child code begins with its parent code. That makes prefix filtering useful for rollups and descendant lookups:
CREATE TABLE observations (
id bigint GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
qdgc_code text NOT NULL
);
CREATE INDEX observations_qdgc_idx ON observations (qdgc_code);
SELECT qdgc_cell_to_parent(qdgc_code, 3) AS level_3_cell,
count(*)
FROM observations
GROUP BY 1;
SELECT *
FROM observations
WHERE qdgc_code LIKE 'E031N02AB%';
Bounding Boxes and Level Metrics
The core extension can enumerate rectangular coverage without PostGIS. Pass min_lon > max_lon for a box that crosses the antimeridian.
SELECT qdgc_bbox_cell_count(30.0, 1.0, 32.0, 3.0, 7);
SELECT *
FROM qdgc_bbox_to_cells(30.0, 1.0, 32.0, 3.0, 7);
SELECT qdgc_level_degrees(7);
SELECT qdgc_get_num_cells(7);
SELECT qdgc_average_cell_area(7, 2.0, 'km^2');
SELECT qdgc_version();
qdgc_average_cell_area is a spherical estimate. Use qdgc_cell_area_km2 from qdgc_postgis when a cell-specific WGS84 spheroid measurement is required.
Important Objects
qdgc_encode(lon, lat, level)andqdgc_latlng_to_cell(lat, lng, level)create codes; the argument order is intentionally different.qdgc_is_valid_cell,qdgc_get_level,qdgc_cell_to_bounds,qdgc_cell_to_lonlat, andqdgc_cell_to_latlnginspect or decode a code.qdgc_cell_to_parentandqdgc_cell_to_childrennavigate the four-way prefix hierarchy.qdgc_bbox_to_cellsenumerates cells meeting a bounding box, whileqdgc_bbox_cell_countcalculates the count without materializing the set.qdgc_level_degrees,qdgc_get_num_cells, andqdgc_average_cell_areareport grid-level metrics.
Operational Notes
- Upstream requires PostgreSQL 13 or newer and tests PostgreSQL 13 through 17. PostgreSQL 18 is not part of the published 0.1.0 test matrix.
- The control file sets
trusted = trueandrelocatable = true. Noshared_preload_libraries,LOAD, server restart, or native library is required. - Relocatable functions call one another by unqualified name. Install
qdgcinto a schema on the activesearch_path; the defaultpublicschema satisfies this boundary. - Coordinates are longitude/latitude degrees.
qdgc_encodetakes longitude first, whileqdgc_latlng_to_celltakes latitude first. - Result cardinality grows by four for every additional child level. Count a bounding-box fill before materializing it, and avoid requesting deep descendants without a deliberate result-size bound.
Feedback
Was this page helpful?
Thanks for the feedback! Please let us know how we can improve.
Sorry to hear that. Please let us know how we can improve.