PROJ coordinate transformation library for PascalAI. Convert coordinates between any of 1000+ CRS — WGS84 GPS to Web Mercator, UTM, NAD83, and more. Compute geodetic distances, azimuths, and destination points on the Earth ellipsoid.
Ubuntu/Debian: sudo apt install libproj-dev proj-data • Fedora: sudo dnf install proj-devel • macOS: brew install proj
uses proj;
{ Convert GPS coordinates to Web Mercator (for map tile display) }
var mercator := WGS84ToWebMercator(-3.70379, 40.41650); { Madrid }
WriteLn('X: ' + FloatToStr(mercator.Lon)); { easting in metres }
WriteLn('Y: ' + FloatToStr(mercator.Lat)); { northing in metres }
{ Convert to UTM for accurate distance calculations }
var utm := WGS84ToUTM(-3.70379, 40.41650, 30, True); { Zone 30N }
WriteLn('Easting: ' + FloatToStr(utm.Lon) + ' m');
WriteLn('Northing: ' + FloatToStr(utm.Lat) + ' m');
uses proj;
{ Distance between two cities (geodetic = on the ellipsoid) }
var dist := GeodeticDistance(-3.70379, 40.41650, { Madrid }
2.34880, 48.85341); { Paris }
WriteLn('Distance: ' + FloatToStr(dist/1000) + ' km');
{ Bearing from Madrid to Paris }
var az := GeodeticAzimuth(-3.70379, 40.41650, 2.34880, 48.85341);
WriteLn('Azimuth: ' + FloatToStr(az) + '°');
{ Where do you end up 500 km north of Madrid? }
var dest := GeodeticDestination(-3.70379, 40.41650, 0.0, 500000);
WriteLn('Dest: ' + FloatToStr(dest.Lat) + '°N');
PROJ uses context objects for thread safety. A default thread-local context is used when none is provided, which is sufficient for most programs.
| Function | Description |
|---|---|
| NewContext() | Create a new PROJ context. Use when managing multiple threads. |
| FreeContext(ctx) | Release a context and all transforms created from it. |
| SetSearchPath(ctx, path) | Override the directory where PROJ looks for datum grid files. |
| PROJVersion() | Returns PROJ library version string. |
Generic pipeline that accepts any source and target CRS by EPSG code or PROJ string. Use this when the shortcut helpers below do not cover your specific CRS pair.
| Function | Description |
|---|---|
| NewTransform(fromCRS, toCRS) | Create a transform from fromCRS to toCRS. Both accept EPSG codes (e.g. 'EPSG:4326') or PROJ strings. |
| NewTransformCtx(ctx, fromCRS, toCRS) | Create transform using an explicit context. |
| TransformPoint(t, lon, lat) | Transform a single (lon, lat) pair. Returns TCoord. |
| TransformPointZ(t, lon, lat, z) | Transform with elevation. Returns TCoord3. |
| TransformPoints(t, coords) | Batch transform an array of TCoord values. Much faster than repeated single calls. |
| InverseTransformPoint(t, x, y) | Apply the inverse direction of the transform. |
| FreeTransform(t) | Release a transform object. |
uses proj;
{ Custom transform: WGS84 geographic to ETRS89 / UTM zone 33N }
var t := NewTransform('EPSG:4326', 'EPSG:25833');
var pt := TransformPoint(t, 13.40493, 52.52003); { Berlin }
WriteLn('Easting: ' + FloatToStr(pt.Lon));
WriteLn('Northing: ' + FloatToStr(pt.Lat));
{ Batch transform many points at once }
var pts: List<TCoord>;
pts.Add(MakeCoord(13.40493, 52.52003));
pts.Add(MakeCoord(2.34880, 48.85341));
pts.Add(MakeCoord(-3.70379, 40.41650));
var results := TransformPoints(t, pts);
FreeTransform(t);
Pre-built functions for the most frequently used CRS conversions. All accept (longitude, latitude) in decimal degrees.
| Function | Description |
|---|---|
| WGS84ToWebMercator(lon, lat) | WGS84 geographic → EPSG:3857 Web Mercator (metres). Used by Google Maps, OpenStreetMap. |
| WebMercatorToWGS84(x, y) | EPSG:3857 metres → WGS84 geographic. |
| WGS84ToUTM(lon, lat, zone, north) | WGS84 → UTM projected. zone 1–60, north=True for northern hemisphere. |
| UTMToWGS84(easting, northing, zone, north) | UTM → WGS84 geographic. |
| WGS84ToNAD83(lon, lat) | WGS84 → NAD83 geographic (EPSG:4269). North America datum. |
| WGS84ToETRS89(lon, lat) | WGS84 → ETRS89 geographic (EPSG:4258). European datum. |
| AutoUTMZone(lon, lat) | Returns the UTM zone number for the given coordinate. |
All computations use the WGS84 ellipsoid. Distances are in metres, angles in decimal degrees.
| Function | Description |
|---|---|
| GeodeticDistance(lon1, lat1, lon2, lat2) | Geodetic (ellipsoidal) distance in metres between two geographic points. |
| GeodeticAzimuth(lon1, lat1, lon2, lat2) | Forward azimuth in degrees from point 1 to point 2 (0° = north, clockwise). |
| GeodeticBackAzimuth(lon1, lat1, lon2, lat2) | Back azimuth (azimuth at the destination looking back toward origin). |
| GeodeticDestination(lon, lat, azimuth, dist) | Returns TCoord reached by travelling dist metres at azimuth degrees from the start point. |
| GeodeticMidpoint(lon1, lat1, lon2, lat2) | Geographic midpoint on the geodesic between two points. |
| PlanarDistance(x1, y1, x2, y2) | Euclidean distance in projected coordinates (metres). |
| Function | Description |
|---|---|
| CRSName(epsgCode) | Human-readable CRS name for an EPSG code. E.g. 4326 → 'WGS 84'. |
| CRSIsGeographic(epsgCode) | True if the CRS uses geographic (lon/lat) coordinates. |
| CRSIsProjected(epsgCode) | True if the CRS uses projected (easting/northing) coordinates. |
| CRSUnits(epsgCode) | Returns unit name: 'degree', 'metre', 'foot', etc. |
| CRSArea(epsgCode) | Returns name of the geographic area of use (e.g. 'World', 'Europe'). |
| CRSToPROJString(epsgCode) | Returns the canonical PROJ pipeline string for a CRS. |
| CRSToWKT(epsgCode) | Returns the Well-Known Text representation of a CRS. |
| EPSG | Name | Use case |
|---|---|---|
| 4326 | WGS 84 | Standard GPS coordinates. Used by Google Maps API, GeoJSON. |
| 3857 | Web Mercator (WGS 84) | Tile-based web maps (Google Maps, OSM, Mapbox display). |
| 4269 | NAD83 | Official datum for North America (US/Canada surveys). |
| 4258 | ETRS89 | Official datum for Europe (EU surveys, Copernicus). |
| 32601–32660 | WGS 84 / UTM Zone N (northern) | Zones 1N–60N. Add 32700 for southern hemisphere. |
| 32701–32760 | WGS 84 / UTM Zone S (southern) | Zones 1S–60S. Accurate metric distances and areas. |
| 25833 | ETRS89 / UTM Zone 33N | Germany, Austria, Scandinavia — official engineering datum. |
| 27700 | British National Grid | Ordnance Survey. Official UK projected CRS. |
| 2154 | RGF93 / Lambert-93 | Official French national projected CRS. |
| 5070 | NAD83 / Conus Albers | Equal-area projection covering the contiguous US. |
A Coordinate Reference System (CRS) defines how coordinates map to locations on Earth. EPSG codes are standardised numeric identifiers for CRSs maintained by the EPSG registry (epsg.io).
Geographic CRS (e.g. WGS84) uses longitude/latitude in degrees. Projected CRS (e.g. UTM, Web Mercator) uses easting/northing in metres or feet on a flat plane, enabling Euclidean distance calculations.
Different CRSs may use different ellipsoids and datum origins. Converting between them (e.g. NAD27 → WGS84) requires datum shift grids. Install proj-data for accurate datum transformations.
Use GeodeticDistance for accurate great-circle distances on the Earth's surface (metres). Use PlanarDistance only on projected coordinates where the projection preserves local distances.
PROJ 6+ uses (longitude, latitude) order consistently, matching GeoJSON convention. This wrapper follows the same convention. Some older PROJ versions used (lat, lon) — always verify when migrating existing code.