Turf.jsTransformation

turf.transformTranslate

What is turf.transformTranslate?

turf.transformTranslate moves a GeoJSON Feature by a specified distance and direction, optionally also shifting the Z value. Translation is applied as a rhumb-line (constant-heading) shift so the output retains its shape faithfully.

JavaScript
turf.transformTranslate(geojson, distance, direction, options?) → Feature<Geometry>

Options include:

  • units'kilometers' (default), 'meters', 'miles', 'nauticalmiles', 'radians', 'degrees'
  • zTranslation — vertical translation in metres (default 0)
  • mutateboolean (default false); when true, mutates the input in place

When would you use turf.transformTranslate?

Use turf.transformTranslate to move a whole geometry — relocating a building footprint, offsetting an overlay for comparison, or drag-translating a user drawing on a MapLibre map. Combined with turf.transformRotate and turf.transformScale it gives you the full affine toolbox without leaving GeoJSON.

In Node.js it is useful for building testing fixtures (generate a known feature then translate it to various locations), for moving templates into place during ETL, or for simulating synthetic GPS tracks offset from a base route.

Code
undefined

FAQs

Is the translation rhumb or great-circle?

Rhumb-line — a constant heading. This keeps the feature's shape and orientation intact relative to its original framing.

Does zTranslation affect all vertices?

Yes — when supplied, every coordinate's third element is shifted by zTranslation metres. Coordinates without a Z value gain one.

How do I install just transformTranslate?

npm install @turf/transform-translate. It depends on @turf/rhumb-destination, @turf/helpers, @turf/invariant, and @turf/meta.

Can I translate a FeatureCollection in one call?

Yes — turf.transformTranslate accepts any GeoJSON input and walks every coordinate, so a FeatureCollection is translated in place.