
Security News
Socket Security Analysis Is Now One Click Away on npm
npm now links to Socket's security analysis on every package page. Here's what you'll find when you click through.
@terrestris/geojson-walk
Advanced tools
A tiny library to apply a function to a GeoJSON. In case of a
FeatureCollection, the function will also be applied to the single Features.
This can be used to eg. gather statistics about the GeoJSON (spatial extent, attributes, …) or to change / clean it. Have a look at the examples below to get an idea of what is possible.
npm i @terrestris/geojson-walk
This module exposes one function walk:
objectWalk the GeoJSON and apply the provided function to it or its features (in
case of a FeatureCollection). If you expect your function to change the
passed GeoJSON Feature Collection, then pass the third parameter as true.
In that case the return value of the function determines what ends up in the
returned GeoJSON. If you return something truthy, the return value will be
used, otherwise the Feature will not be in the returned collection.
Kind: global function
Returns: object - The (possibly changed) GeoJSON.
| Param | Type | Description |
|---|---|---|
| o | object | The GeoJSON we will walk. We do not check whether this is actually a fully valid GeoJSON. |
| fn | function | The function we will call. Will receive the GeoJSON or each feature of the collection. |
| doExpectChange | boolean | Whether you expect your function might change the GeoJSON. |
Simple usage example:
import walk from '@terrestris/geojson-walk';
const filterForProp = (f) => {
if (f.properties.humpty === 'dumpty') {
return f;
} else {
return null;
}
};
const featureCollection = {
type: 'FeatureCollection',
features: [
{
type: 'Feature',
properties: {
humpty: 'dumpty'
},
geometry: {
type: 'Point',
coordinates: [
0,
1
]
}
},
{
type: 'Feature',
properties: {
humpty: 'trumpty'
},
geometry: {
type: 'Point',
coordinates: [
2,
3
]
}
}
]
};
const cleanCollection = walk(featureCollection, filterForProp, true);
FAQs
Validate and clean GeoJSON
We found that @terrestris/geojson-walk demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 17 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
npm now links to Socket's security analysis on every package page. Here's what you'll find when you click through.

Security News
A compromised npm publish token was used to push a malicious postinstall script in cline@2.3.0, affecting the popular AI coding agent CLI with 90k weekly downloads.

Product
Socket is now scanning AI agent skills across multiple languages and ecosystems, detecting malicious behavior before developers install, starting with skills.sh's 60,000+ skills.