# PROJ

> Reproject coordinates between CRSs and measure geodesic distances on the WGS84 ellipsoid

This page includes setup, release pins, credentials, hosting and verification evidence. [JSON alternative](https://query.farm/products/orchard/api/v1/connectors/proj.json) contains the same setup facts for structured readers; choose one format.

## Runtime and release

Use DuckDB or Haybarn **2.0.1** with **VGI protocol 3.4**.
Catalog alias: `proj`. Release: [v0.5.0](https://github.com/Query-farm/vgi-proj/releases/tag/v0.5.0). Metadata generated: 2026-12-01T18:22:16+00:00.

## Choose where it runs

- On your machine: use an installation method below. No Query Farm account is required for local execution.
- Self-host: follow [the connector deployment instructions](https://github.com/Query-farm/vgi-proj) and [connection guide](https://query.farm/vgi/connect-to-a-worker/). Use your real endpoint and its authentication settings.
- Query Farm hosted: [create a deployment](https://auth.queryfarm.cloud/console/new?worker=proj). Hosting has a $10 monthly minimum per organization; usage and license fees may apply. Copy the deployment-specific ATTACH from the console.

## Service credentials and prerequisites

No service credentials are declared by this connector. Individual datasets, input files or deployments may have their own prerequisites.

Secret parameter required flags describe the upstream declaration; they do not override the service-level mode above. Keep secrets in environment variables or the deployment secret store. SQL values in angle brackets are placeholders, not automatic environment lookups. Native DuckDB and Haybarn 2.0.1 do not provide a SQL getenv() function, even when worker-supplied snippets mention it. Read environment variables in your application and pass credential values through client parameter bindings (for example, Python con.execute("CREATE SECRET stripe (TYPE stripe, api_key ?)", [os.environ["STRIPE_API_KEY"]]) after attaching the connector. Omit unused optional parameters and keep real values out of saved SQL and logs.

## Install the extension

In stock DuckDB:

```sql
SET allow_extension_repositories = 'allowed';

CREATE EXTENSION REPOSITORY IF NOT EXISTS query_farm
    WITH PREFIX 'https://duckdb-extensions.query.farm';

INSTALL vgi FROM query_farm;
LOAD vgi FROM query_farm;
```

In Haybarn:

```sql
INSTALL vgi FROM community;
LOAD vgi;
```

## Attach the connector

The local recipes below pin the catalog release for repeatability. A public demo endpoint follows its deployed release.

### uvx

Attach with uvx

Needs uv. uvx builds the worker from its release tag on first attach and reuses the cached environment after that.

```sql
ATTACH 'proj' AS proj (
  TYPE vgi,
  LOCATION 'uvx --from git+https://github.com/Query-farm/vgi-proj@v0.5.0 vgi-proj-worker'
);
```

### Docker

Attach the signed image

Needs Docker, Podman or another OCI runtime. The extension runs the container and talks to it over stdio.

```sql
ATTACH 'proj' AS proj (
  TYPE vgi,
  LOCATION 'oci://ghcr.io/query-farm/vgi-proj:0.5.0'
);
```

## See what you can query

Service credentials required for this example: not declared by this example; check the connector requirements above.

```sql
WITH eye AS (SELECT proj.main.transform(530600.0, 179700.0, 'EPSG:27700', 'EPSG:4326') AS o), sites(site, easting, northing) AS (VALUES ('Edinburgh Castle', 325160.0, 673490.0), ('Cardiff Castle', 318080.0, 176540.0), ('York Minster', 460350.0, 452230.0)), ll AS (SELECT site, proj.main.transform(easting, northing, 'EPSG:27700', 'EPSG:4326') AS p FROM sites) SELECT site, round(p.x, 4) AS lon, round(p.y, 4) AS lat, round(proj.main.geodesic_distance(o.x, o.y, p.x, p.y) / 1000, 1) AS km_from_london_eye FROM ll CROSS JOIN eye ORDER BY km_from_london_eye
```

- [proj.main.transform — scalar_function](https://query.farm/products/orchard/connectors/proj/objects/scalar_function.bWFpbg.dHJhbnNmb3Jt.md): exact declaration for this example.
- [proj.main.geodesic_distance — scalar_function](https://query.farm/products/orchard/connectors/proj/objects/scalar_function.bWFpbg.Z2VvZGVzaWNfZGlzdGFuY2U.md): exact declaration for this example.

Execution evidence: **captured_result**.

```json
{
  "status": "captured_result",
  "capturedAt": "2026-12-01T06:16:30+00:00",
  "engineVersion": "2.0.1",
  "protocolVersion": "3.4.0",
  "releaseTag": "v0.5.0",
  "sample": {
    "columns": [
      "site",
      "lon",
      "lat",
      "km_from_london_eye"
    ],
    "types": [
      "VARCHAR",
      "DOUBLE",
      "DOUBLE",
      "DOUBLE"
    ],
    "rows": [
      [
        "Cardiff Castle",
        -3.1811,
        51.4819,
        212.6
      ],
      [
        "York Minster",
        -1.0816,
        53.9626,
        281.5
      ],
      [
        "Edinburgh Castle",
        -3.2,
        55.9486,
        535
      ]
    ],
    "more": false
  }
}
```

## Connector reference

### Coordinate Reference System Transforms & Geodesic Distance in SQL

![PROJ logo](https://raw.githubusercontent.com/OSGeo/PROJ/master/docs/images/logo.png)

**Reproject coordinates between any two CRSs and measure accurate ellipsoidal distance and bearing directly in DuckDB SQL** -- EPSG transforms, UTM and Web Mercator projection, and WGS84 geodesic geometry, powered by [PROJ](https://proj.org/) through [pyproj](https://pyproj4.github.io/pyproj/stable/).

The `proj` extension brings industry-standard geospatial coordinate math into your queries, so you never have to export points to a GIS tool or a Python notebook just to change projection or compute a great-circle distance. It is built for analysts, data engineers, and mapping developers who work with longitude/latitude points, EPSG-coded geometries, tile coordinates, or survey data and need correct, repeatable coordinate transformations next to the rest of their SQL. Every transformation is identified by a standard EPSG code or CRS string (for example `EPSG:4326` for WGS84 longitude/latitude and `EPSG:3857` for Web Mercator), so results match what PostGIS, QGIS, and other PROJ-based tools produce.

Under the hood the extension calls [pyproj](https://github.com/pyproj4/pyproj), the Python binding for the [PROJ](https://github.com/OSGeo/PROJ) C library that is the de-facto standard for cartographic projections and datum transformations. The pyproj binary wheel bundles PROJ together with its data grids, so there is no separate native install and no external services or API keys -- the worker is fully offline and hermetic. Building a PROJ transformer is comparatively expensive, so transformers are cached and the common WGS84 <-> Web Mercator pipelines are warmed at startup, keeping per-row transforms fast. All coordinate input and output uses `always_xy` axis order `(x/easting/longitude, y/northing/latitude)` regardless of a CRS's declared native axis order, eliminating the classic lon/lat swap.

## Capabilities

The worker's functions fall into a few capability areas: general CRS-to-CRS reprojection identified by EPSG code; convenience conversions to and from the Web Mercator tile projection and into a point's automatically selected UTM zone; accurate WGS84-ellipsoid geodesic distance and initial bearing between two longitude/latitude points; and lookups of a CRS's human-readable name and axis units alongside the bundled PROJ library version. Reprojection results come back as typed `STRUCT` coordinates, while the geodesic and metadata functions return plain metres, degrees, or strings. Because every CRS is named by its standard EPSG code and all transforms share the same `always_xy` axis convention, results line up with what PostGIS, QGIS, and other PROJ-based tools produce.

NULL or non-finite (and, where applicable, out-of-range) coordinates yield NULL, while an unknown CRS raises a clear query error.

## Find the exact SQL object

[Browse 8 object declarations](https://query.farm/products/orchard/api/v1/connectors/proj/objects.json) or [search within this connector](https://query.farm/products/orchard/api/v1/search.json?kind=object&connector=proj&q=proj).

Follow one format of each needed object for complete argument types, defaults, named flags, return columns and examples. Existing links above can replace another search. For questions about hosting, credentials or supported operations, stop once the documentation answers the question; SQL and unrelated object lookups are unnecessary.

## Verification and interpretation

- Missing, null, or undeclared metadata means unknown; do not invent defaults, credential scope, platform support or endpoint URLs.
- Search is keyword retrieval, not proof of a capability. Read the exact object declaration before generating SQL.
- A table and a table function can have the same name. Preserve parentheses and use the matching overload and schema.
- Service credentials, external data availability and deployment authentication are separate requirements.
- Catalog verification records the harvest environment. It is not proof that every query or current live API call succeeds. Only an example with captured_result has a saved result for that exact SQL.

```json
{
  "generatedAt": "2026-12-01T18:22:16+00:00",
  "repository": "https://github.com/Query-farm/vgi-proj",
  "harvest": {
    "status": "ok",
    "method": "subprocess",
    "error": null,
    "vgi_version": "9773130dde"
  },
  "catalogVerification": {
    "verified": true,
    "status": "passed",
    "total": 10,
    "passed": 10,
    "failed": 0,
    "needs_credentials": 0,
    "location": "uvx --from git+https://github.com/Query-farm/vgi-proj@v0.5.0 vgi-proj-worker",
    "transport": "subprocess",
    "environment": {
      "vgi_extension_version": "9773130dde",
      "haybarn_version": "2.0.1rc3",
      "engine_version": "v2.0.1",
      "python": "3.12.4",
      "platform": "darwin_arm64",
      "protocol_version": "3.4.0"
    },
    "checked_at": "2026-12-01T06:16:15+00:00"
  },
  "interpretation": "Catalog verification records the harvest environment. It is not proof that every query or current live API call succeeds. Only an example with captured_result has a saved result for that exact SQL."
}
```
