GDALRaster Processing

gdaltransform

What is gdaltransform?

gdaltransform reads coordinates and transforms them — between CRSes, from pixel coordinates to georeferenced coordinates of a raster (or vice versa), or through a GCP-derived model. It is the command-line counterpart to PROJ's cs2cs, with the added ability to use a GDAL dataset's geotransform or GCPs as the transformation model, which is invaluable when working with unreferenced or semi-referenced imagery.

Shell
gdaltransform [options] [<srcfile> [<dstfile>]]

Commonly used options:

  • -s_srs <CRS> — source CRS
  • -t_srs <CRS> — target CRS
  • -to "<NAME>=<VALUE>" — transformer option (repeatable, e.g. METHOD=GCP_POLYNOMIAL)
  • -order <n> — polynomial order when using GCPs (1, 2, or 3)
  • -tps — use a thin-plate-spline transformer on GCPs
  • -rpc — use Rational Polynomial Coefficients (RPCs)
  • -geoloc — use geolocation arrays
  • -i — inverse transformation
  • -output_xy — emit only x/y columns (no z)
  • -coord_epoch <epoch> — coordinate epoch for dynamic CRS

Reads coordinates from stdin if no <srcfile>, one x y [z] per line.

When would you use gdaltransform?

Use gdaltransform for one-off or scripted coordinate transformations, especially when a GDAL dataset is the transformation source. Typical jobs: converting a few control-point coordinates between projections without loading a GIS (echo "12.5 41.9" | gdaltransform -s_srs EPSG:4326 -t_srs EPSG:32633), turning pixel coordinates in an unreferenced image into world coordinates using the image's embedded GCPs (gdaltransform -order 2 scan.tif), or validating that a CRS definition behaves as expected at a known point.

For anything requiring RPC-based satellite image georeferencing (Maxar, Pleiades, SuperView), -rpc is the option that lifts those coefficients into the transformation. For pipelines with thousands of coordinates, stdin streaming is the correct pattern — the transformation model is built once and reused per line.

FAQs

How does gdaltransform differ from cs2cs?

PROJ's cs2cs purely transforms between CRSes using PROJ definitions. gdaltransform can do that but also supports using a GDAL dataset's geotransform, GCPs, RPCs, or geolocation arrays as the transformation source — which is essential when the transformation is defined by an image rather than a pair of CRS codes. For pure CRS-to-CRS work, either tool is fine; for image-derived transformation, gdaltransform is the right choice.

What's the difference between -order, -tps, and -rpc?

-order N fits an Nth-order polynomial to the dataset's GCPs (order 1 is a simple affine, 3 is the maximum). -tps fits a thin-plate-spline — exact at control points, smooth between them — better when GCPs are irregularly distributed. -rpc uses the rational-polynomial model embedded in satellite imagery metadata for sensor-accurate georeferencing. Choose based on what the source dataset supplies.

Why do I need axis-order awareness?

Modern PROJ honours CRS-declared axis order: EPSG:4326 is latitude-longitude, not longitude-latitude. Without compensation, your inputs may be swapped. Set -to "AXIS_MAPPING_STRATEGY=TRADITIONAL_GIS_ORDER" to force the familiar longitude-latitude convention, or rely on GDAL 3.x defaults which use the authority-declared order.

Can I batch-transform a CSV?

Yes — pipe it in: awk -F, '{print $1,$2}' pts.csv | gdaltransform -s_srs EPSG:4326 -t_srs EPSG:3857 > out.txt. The tool preserves one output line per input line, making it easy to paste back with the original attributes.