node package manager


A simple feature model for working with geospatial data

Simple Features

A simple feature model for working with geospatial data in JavaScript.

Note that this doesn't strictly follow the OGC Simple Features spec(s). Instead, see GeoJSON for inspiration.


Typically, you'll add simple-features as a dependency of another package.

npm install simple-features --save

(Exclude the --save option if you are installing locally just to try it out.)

Simple Example

Create a new feature with one string property and one geometry.

var assert = require('assert');
var simple = require('simple-features');
var feature = new simple.Feature({
  name: 'Bozeman',
  loc: new simple.Point([-111.04, 45.68])

Features can have arbitrary properties. To access a property value, use the get method.

var value = feature.get('name');
assert.strictEqual(value, 'Bozeman');

Features typically have a single geometry, but they can have more. In cases where a feature has more than one geometry, the first one is considered the "default" geometry. The default geometry can be accessed by using the get method with the property name or with the getGeometry method.

var loc = feature.get('loc');
var geom = feature.getGeometry();
assert.strictEqual(loc, geom);

Geometries have multi-dimensional coordinate arrays of the same form as GeoJSON.

var coords = feature.getGeometry().coordinates;
assert.deepEqual(coordinates, [-111.04, 45.68]);

Until there are more docs here, see the tests for more detail.


Current Status

Run tests with the test script:

npm test

You can also set up a watcher to run tests continuously during development.

npm run watch