turf.transformScale
What is turf.transformScale?
turf.transformScale scales any GeoJSON Feature by a factor around an origin. Factor 2 doubles the size, 0.5 halves it, 1 returns unchanged. The operation is geodesic — each vertex is projected along its bearing from the origin at a scaled distance.
turf.transformScale(geojson, factor, options?) → Feature<Geometry>Options include:
origin—Pointor corner string ('sw','nw','ne','se','center','centroid'); default'centroid'mutate—boolean(defaultfalse); whentrue, mutates the input in place
When would you use turf.transformScale?
Use turf.transformScale to grow or shrink a shape around an anchor — scaling a geofence for a larger event area, creating nested radius polygons from a footprint, or resizing a drawn selection proportionally. Combined with turf.transformRotate and turf.transformTranslate it handles the full affine family.
In a Node.js build step, turf.transformScale can generate progressively smaller/larger variants of a template polygon for a scenario-analysis tool or for generating "hit zones" around a primary footprint.
undefinedFAQs
What happens at factor = 0?
Every vertex collapses to the origin. Practically, this produces a degenerate feature — avoid or clamp to a small positive value.
What origin options are available?
A GeoJSON Point or a corner keyword: 'sw', 'nw', 'ne', 'se', 'center' (of bbox), or 'centroid' (of vertices). Default is 'centroid'.
How do I install just transformScale?
npm install @turf/transform-scale. Its dependencies include @turf/center, @turf/bbox, @turf/centroid, @turf/rhumb-bearing, @turf/rhumb-destination, and @turf/meta.
Is the scaling uniform in geographic distance?
Yes — turf.transformScale computes distances geodetically and scales each vertex by the requested factor along its rhumb bearing from the origin. This avoids the distortion you would get from scaling raw degrees.