pg_eviltransform

pg_eviltransform

pg_eviltransform : Coordinate transforms for BD09/GCJ02 via PostGIS ST_Transform

Overview

IDExtensionPackageVersionCategoryLicenseLanguage
1580
pg_eviltransform
pg_eviltransform
0.0.2
GIS
MIT
Rust
AttributeHas BinaryHas LibraryNeed LoadHas DDLRelocatableTrusted
--s-d-r
No
Yes
No
Yes
yes
no
Relationships
Schemaseviltransform_internal
Requires
postgis
See Also
postgis
pgrouting
pg_geohash
h3
q3c
earthdistance
tzf
geoip

Packages

TypeRepoVersionPG Major CompatibilityPackage PatternDependencies
EXT
PIGSTY
0.0.2
18
17
16
15
14
pg_eviltransformpostgis
RPM
PIGSTY
0.0.2
18
17
16
15
14
pg_eviltransform_$vpostgis36_$v
DEB
PIGSTY
0.0.2
18
17
16
15
14
postgresql-$v-eviltransformpostgresql-$v-postgis
Linux / PGPG18PG17PG16PG15PG14
el8.x86_64
PIGSTY 0.0.2
PIGSTY 0.0.2
PIGSTY 0.0.2
PIGSTY 0.0.2
PIGSTY 0.0.2
el8.aarch64
PIGSTY 0.0.2
PIGSTY 0.0.2
PIGSTY 0.0.2
PIGSTY 0.0.2
PIGSTY 0.0.2
el9.x86_64
PIGSTY 0.0.2
PIGSTY 0.0.2
PIGSTY 0.0.2
PIGSTY 0.0.2
PIGSTY 0.0.2
el9.aarch64
PIGSTY 0.0.2
PIGSTY 0.0.2
PIGSTY 0.0.2
PIGSTY 0.0.2
PIGSTY 0.0.2
el10.x86_64
PIGSTY 0.0.2
PIGSTY 0.0.2
PIGSTY 0.0.2
PIGSTY 0.0.2
PIGSTY 0.0.2
el10.aarch64
PIGSTY 0.0.2
PIGSTY 0.0.2
PIGSTY 0.0.2
PIGSTY 0.0.2
PIGSTY 0.0.2
d12.x86_64
PIGSTY 0.0.2
PIGSTY 0.0.2
PIGSTY 0.0.2
PIGSTY 0.0.2
PIGSTY 0.0.2
d12.aarch64
PIGSTY 0.0.2
PIGSTY 0.0.2
PIGSTY 0.0.2
PIGSTY 0.0.2
PIGSTY 0.0.2
d13.x86_64
PIGSTY 0.0.2
PIGSTY 0.0.2
PIGSTY 0.0.2
PIGSTY 0.0.2
PIGSTY 0.0.2
d13.aarch64
PIGSTY 0.0.2
PIGSTY 0.0.2
PIGSTY 0.0.2
PIGSTY 0.0.2
PIGSTY 0.0.2
u22.x86_64
PIGSTY 0.0.2
PIGSTY 0.0.2
PIGSTY 0.0.2
PIGSTY 0.0.2
PIGSTY 0.0.2
u22.aarch64
PIGSTY 0.0.2
PIGSTY 0.0.2
PIGSTY 0.0.2
PIGSTY 0.0.2
PIGSTY 0.0.2
u24.x86_64
PIGSTY 0.0.2
PIGSTY 0.0.2
PIGSTY 0.0.2
PIGSTY 0.0.2
PIGSTY 0.0.2
u24.aarch64
PIGSTY 0.0.2
PIGSTY 0.0.2
PIGSTY 0.0.2
PIGSTY 0.0.2
PIGSTY 0.0.2
PackageVersionOSORGSIZEFile URL
pg_eviltransform_180.0.2el8.x86_64pigsty300.7 KiBpg_eviltransform_18-0.0.2-1PIGSTY.el8.x86_64.rpm
pg_eviltransform_180.0.2el8.aarch64pigsty194.6 KiBpg_eviltransform_18-0.0.2-1PIGSTY.el8.aarch64.rpm
pg_eviltransform_180.0.2el9.x86_64pigsty315.6 KiBpg_eviltransform_18-0.0.2-1PIGSTY.el9.x86_64.rpm
pg_eviltransform_180.0.2el9.aarch64pigsty207.5 KiBpg_eviltransform_18-0.0.2-1PIGSTY.el9.aarch64.rpm
pg_eviltransform_180.0.2el10.x86_64pigsty316.2 KiBpg_eviltransform_18-0.0.2-1PIGSTY.el10.x86_64.rpm
pg_eviltransform_180.0.2el10.aarch64pigsty208.3 KiBpg_eviltransform_18-0.0.2-1PIGSTY.el10.aarch64.rpm
postgresql-18-eviltransform0.0.2d12.x86_64pigsty249.0 KiBpostgresql-18-eviltransform_0.0.2-1PIGSTY~bookworm_amd64.deb
postgresql-18-eviltransform0.0.2d12.aarch64pigsty150.6 KiBpostgresql-18-eviltransform_0.0.2-1PIGSTY~bookworm_arm64.deb
postgresql-18-eviltransform0.0.2d13.x86_64pigsty248.7 KiBpostgresql-18-eviltransform_0.0.2-1PIGSTY~trixie_amd64.deb
postgresql-18-eviltransform0.0.2d13.aarch64pigsty150.8 KiBpostgresql-18-eviltransform_0.0.2-1PIGSTY~trixie_arm64.deb
postgresql-18-eviltransform0.0.2u22.x86_64pigsty280.4 KiBpostgresql-18-eviltransform_0.0.2-1PIGSTY~jammy_amd64.deb
postgresql-18-eviltransform0.0.2u22.aarch64pigsty174.5 KiBpostgresql-18-eviltransform_0.0.2-1PIGSTY~jammy_arm64.deb
postgresql-18-eviltransform0.0.2u24.x86_64pigsty277.8 KiBpostgresql-18-eviltransform_0.0.2-1PIGSTY~noble_amd64.deb
postgresql-18-eviltransform0.0.2u24.aarch64pigsty173.1 KiBpostgresql-18-eviltransform_0.0.2-1PIGSTY~noble_arm64.deb
PackageVersionOSORGSIZEFile URL
pg_eviltransform_170.0.2el8.x86_64pigsty300.7 KiBpg_eviltransform_17-0.0.2-1PIGSTY.el8.x86_64.rpm
pg_eviltransform_170.0.2el8.aarch64pigsty194.6 KiBpg_eviltransform_17-0.0.2-1PIGSTY.el8.aarch64.rpm
pg_eviltransform_170.0.2el9.x86_64pigsty315.5 KiBpg_eviltransform_17-0.0.2-1PIGSTY.el9.x86_64.rpm
pg_eviltransform_170.0.2el9.aarch64pigsty207.5 KiBpg_eviltransform_17-0.0.2-1PIGSTY.el9.aarch64.rpm
pg_eviltransform_170.0.2el10.x86_64pigsty315.9 KiBpg_eviltransform_17-0.0.2-1PIGSTY.el10.x86_64.rpm
pg_eviltransform_170.0.2el10.aarch64pigsty208.1 KiBpg_eviltransform_17-0.0.2-1PIGSTY.el10.aarch64.rpm
postgresql-17-eviltransform0.0.2d12.x86_64pigsty248.5 KiBpostgresql-17-eviltransform_0.0.2-1PIGSTY~bookworm_amd64.deb
postgresql-17-eviltransform0.0.2d12.aarch64pigsty150.6 KiBpostgresql-17-eviltransform_0.0.2-1PIGSTY~bookworm_arm64.deb
postgresql-17-eviltransform0.0.2d13.x86_64pigsty248.6 KiBpostgresql-17-eviltransform_0.0.2-1PIGSTY~trixie_amd64.deb
postgresql-17-eviltransform0.0.2d13.aarch64pigsty150.7 KiBpostgresql-17-eviltransform_0.0.2-1PIGSTY~trixie_arm64.deb
postgresql-17-eviltransform0.0.2u22.x86_64pigsty280.1 KiBpostgresql-17-eviltransform_0.0.2-1PIGSTY~jammy_amd64.deb
postgresql-17-eviltransform0.0.2u22.aarch64pigsty174.5 KiBpostgresql-17-eviltransform_0.0.2-1PIGSTY~jammy_arm64.deb
postgresql-17-eviltransform0.0.2u24.x86_64pigsty277.7 KiBpostgresql-17-eviltransform_0.0.2-1PIGSTY~noble_amd64.deb
postgresql-17-eviltransform0.0.2u24.aarch64pigsty173.2 KiBpostgresql-17-eviltransform_0.0.2-1PIGSTY~noble_arm64.deb
PackageVersionOSORGSIZEFile URL
pg_eviltransform_160.0.2el8.x86_64pigsty300.5 KiBpg_eviltransform_16-0.0.2-1PIGSTY.el8.x86_64.rpm
pg_eviltransform_160.0.2el8.aarch64pigsty194.6 KiBpg_eviltransform_16-0.0.2-1PIGSTY.el8.aarch64.rpm
pg_eviltransform_160.0.2el9.x86_64pigsty315.5 KiBpg_eviltransform_16-0.0.2-1PIGSTY.el9.x86_64.rpm
pg_eviltransform_160.0.2el9.aarch64pigsty207.6 KiBpg_eviltransform_16-0.0.2-1PIGSTY.el9.aarch64.rpm
pg_eviltransform_160.0.2el10.x86_64pigsty315.9 KiBpg_eviltransform_16-0.0.2-1PIGSTY.el10.x86_64.rpm
pg_eviltransform_160.0.2el10.aarch64pigsty208.5 KiBpg_eviltransform_16-0.0.2-1PIGSTY.el10.aarch64.rpm
postgresql-16-eviltransform0.0.2d12.x86_64pigsty248.3 KiBpostgresql-16-eviltransform_0.0.2-1PIGSTY~bookworm_amd64.deb
postgresql-16-eviltransform0.0.2d12.aarch64pigsty150.7 KiBpostgresql-16-eviltransform_0.0.2-1PIGSTY~bookworm_arm64.deb
postgresql-16-eviltransform0.0.2d13.x86_64pigsty247.9 KiBpostgresql-16-eviltransform_0.0.2-1PIGSTY~trixie_amd64.deb
postgresql-16-eviltransform0.0.2d13.aarch64pigsty150.8 KiBpostgresql-16-eviltransform_0.0.2-1PIGSTY~trixie_arm64.deb
postgresql-16-eviltransform0.0.2u22.x86_64pigsty280.2 KiBpostgresql-16-eviltransform_0.0.2-1PIGSTY~jammy_amd64.deb
postgresql-16-eviltransform0.0.2u22.aarch64pigsty174.5 KiBpostgresql-16-eviltransform_0.0.2-1PIGSTY~jammy_arm64.deb
postgresql-16-eviltransform0.0.2u24.x86_64pigsty277.8 KiBpostgresql-16-eviltransform_0.0.2-1PIGSTY~noble_amd64.deb
postgresql-16-eviltransform0.0.2u24.aarch64pigsty173.1 KiBpostgresql-16-eviltransform_0.0.2-1PIGSTY~noble_arm64.deb
PackageVersionOSORGSIZEFile URL
pg_eviltransform_150.0.2el8.x86_64pigsty300.4 KiBpg_eviltransform_15-0.0.2-1PIGSTY.el8.x86_64.rpm
pg_eviltransform_150.0.2el8.aarch64pigsty194.7 KiBpg_eviltransform_15-0.0.2-1PIGSTY.el8.aarch64.rpm
pg_eviltransform_150.0.2el9.x86_64pigsty315.5 KiBpg_eviltransform_15-0.0.2-1PIGSTY.el9.x86_64.rpm
pg_eviltransform_150.0.2el9.aarch64pigsty207.5 KiBpg_eviltransform_15-0.0.2-1PIGSTY.el9.aarch64.rpm
pg_eviltransform_150.0.2el10.x86_64pigsty315.8 KiBpg_eviltransform_15-0.0.2-1PIGSTY.el10.x86_64.rpm
pg_eviltransform_150.0.2el10.aarch64pigsty208.2 KiBpg_eviltransform_15-0.0.2-1PIGSTY.el10.aarch64.rpm
postgresql-15-eviltransform0.0.2d12.x86_64pigsty249.1 KiBpostgresql-15-eviltransform_0.0.2-1PIGSTY~bookworm_amd64.deb
postgresql-15-eviltransform0.0.2d12.aarch64pigsty150.6 KiBpostgresql-15-eviltransform_0.0.2-1PIGSTY~bookworm_arm64.deb
postgresql-15-eviltransform0.0.2d13.x86_64pigsty248.2 KiBpostgresql-15-eviltransform_0.0.2-1PIGSTY~trixie_amd64.deb
postgresql-15-eviltransform0.0.2d13.aarch64pigsty150.8 KiBpostgresql-15-eviltransform_0.0.2-1PIGSTY~trixie_arm64.deb
postgresql-15-eviltransform0.0.2u22.x86_64pigsty280.2 KiBpostgresql-15-eviltransform_0.0.2-1PIGSTY~jammy_amd64.deb
postgresql-15-eviltransform0.0.2u22.aarch64pigsty174.5 KiBpostgresql-15-eviltransform_0.0.2-1PIGSTY~jammy_arm64.deb
postgresql-15-eviltransform0.0.2u24.x86_64pigsty277.7 KiBpostgresql-15-eviltransform_0.0.2-1PIGSTY~noble_amd64.deb
postgresql-15-eviltransform0.0.2u24.aarch64pigsty173.2 KiBpostgresql-15-eviltransform_0.0.2-1PIGSTY~noble_arm64.deb
PackageVersionOSORGSIZEFile URL
pg_eviltransform_140.0.2el8.x86_64pigsty300.3 KiBpg_eviltransform_14-0.0.2-1PIGSTY.el8.x86_64.rpm
pg_eviltransform_140.0.2el8.aarch64pigsty194.6 KiBpg_eviltransform_14-0.0.2-1PIGSTY.el8.aarch64.rpm
pg_eviltransform_140.0.2el9.x86_64pigsty315.1 KiBpg_eviltransform_14-0.0.2-1PIGSTY.el9.x86_64.rpm
pg_eviltransform_140.0.2el9.aarch64pigsty207.6 KiBpg_eviltransform_14-0.0.2-1PIGSTY.el9.aarch64.rpm
pg_eviltransform_140.0.2el10.x86_64pigsty315.7 KiBpg_eviltransform_14-0.0.2-1PIGSTY.el10.x86_64.rpm
pg_eviltransform_140.0.2el10.aarch64pigsty208.1 KiBpg_eviltransform_14-0.0.2-1PIGSTY.el10.aarch64.rpm
postgresql-14-eviltransform0.0.2d12.x86_64pigsty248.0 KiBpostgresql-14-eviltransform_0.0.2-1PIGSTY~bookworm_amd64.deb
postgresql-14-eviltransform0.0.2d12.aarch64pigsty150.7 KiBpostgresql-14-eviltransform_0.0.2-1PIGSTY~bookworm_arm64.deb
postgresql-14-eviltransform0.0.2d13.x86_64pigsty248.8 KiBpostgresql-14-eviltransform_0.0.2-1PIGSTY~trixie_amd64.deb
postgresql-14-eviltransform0.0.2d13.aarch64pigsty150.6 KiBpostgresql-14-eviltransform_0.0.2-1PIGSTY~trixie_arm64.deb
postgresql-14-eviltransform0.0.2u22.x86_64pigsty280.1 KiBpostgresql-14-eviltransform_0.0.2-1PIGSTY~jammy_amd64.deb
postgresql-14-eviltransform0.0.2u22.aarch64pigsty174.5 KiBpostgresql-14-eviltransform_0.0.2-1PIGSTY~jammy_arm64.deb
postgresql-14-eviltransform0.0.2u24.x86_64pigsty277.7 KiBpostgresql-14-eviltransform_0.0.2-1PIGSTY~noble_amd64.deb
postgresql-14-eviltransform0.0.2u24.aarch64pigsty173.2 KiBpostgresql-14-eviltransform_0.0.2-1PIGSTY~noble_arm64.deb

Source

pig build pkg pg_eviltransform;		# build rpm/deb

Install

Make sure PGDG and PIGSTY repo available:

pig repo add pgsql -u   # add both repo and update cache

Install this extension with pig:

pig install pg_eviltransform;		# install via package name, for the active PG version

pig install pg_eviltransform -v 18;   # install for PG 18
pig install pg_eviltransform -v 17;   # install for PG 17
pig install pg_eviltransform -v 16;   # install for PG 16
pig install pg_eviltransform -v 15;   # install for PG 15
pig install pg_eviltransform -v 14;   # install for PG 14

Create this extension with:

CREATE EXTENSION pg_eviltransform CASCADE; -- requires postgis

Usage

pg_eviltransform: Coordinate transform between WGS84, GCJ02, and BD09

pg_eviltransform extends PostGIS ST_Transform with BD09/GCJ02 support for Chinese coordinate systems. It exposes ST_EvilTransform with the same overload interface as ST_Transform.

Custom SRIDs:

  • 990001: GCJ02
  • 990002: BD09

Functions

ST_EvilTransform(geometry, to_srid integer)
ST_EvilTransform(geometry, to_proj text)
ST_EvilTransform(geometry, from_proj text, to_srid integer)
ST_EvilTransform(geometry, from_proj text, to_proj text)

If neither side uses custom coordinates, it delegates directly to ST_Transform. If BD09/GCJ02 is involved, it transforms via WGS84 (4326) when needed.

Examples

-- WGS84 to GCJ02 using text literal
SELECT ST_EvilTransform(ST_SetSRID('POINT(120 30)'::geometry, 4326), 'GCJ02');

-- WGS84 to BD09 using text literal
SELECT ST_EvilTransform(ST_SetSRID('POINT(120 30)'::geometry, 4326), 'BD09');

-- WGS84 to GCJ02 using numeric SRID
SELECT ST_EvilTransform(ST_SetSRID('POINT(120 30)'::geometry, 4326), 990001);

-- BD09 to Web Mercator
SELECT ST_EvilTransform(
  ST_SetSRID('POINT(120.011070620552 30.0038830555128)'::geometry, 990002), 3857
);

-- from_proj / to_proj overload
SELECT ST_EvilTransform('POINT(120 30)'::geometry, 'EPSG:4326', 'GCJ02');

Performance

On PG18 with 200,000 rows, ST_EvilTransform is ~30-45x faster than the regex-based SQL approach.

Last updated on