turf.propEach
What is turf.propEach?
turf.propEach iterates over each Feature's properties object in a GeoJSON input and calls a callback with that properties bag. Geometry is not available inside the callback — only the attributes.
turf.propEach(geojson, callback) → voidThe callback receives (currentProperties, featureIndex).
When would you use turf.propEach?
Use turf.propEach for attribute-only operations — stamping timestamps on every Feature, normalising casing on a text property, or stripping PII before export. It makes the intent clear (you are not touching geometry) and runs slightly faster than featureEach because the callback receives the bare properties object.
1turf.propEach(fc, (props, i) => {
2 props.id = props.id ?? `fallback-${i}`;
3 props.updatedAt = Date.now();
4});FAQs
How do I install Turf.js to use this function?
Install npm install @turf/meta and import import { propEach } from '@turf/meta', or use turf.propEach via the @turf/turf bundle.
Are mutations to the properties object persisted?
Yes. The callback receives the actual properties object on each Feature, so assignments persist on the original GeoJSON. Clone first if you need an untouched copy.
What if a Feature has no properties field?
A Feature without properties is still visited — the callback receives null. Defensive callbacks should check for that before assigning keys.
When should I use propEach vs featureEach?
Use propEach when you only need attributes and want the intent to read clearly. Use featureEach when you also need geometry access or any whole-feature context.