Package detail

@mapbox/geojson-extent

mapbox790.5kISC1.0.1

compute the bounding box of geojson features

geojson, extent, browser, geo

readme

geojson-extent

Compute an extent given a GeoJSON object.

install

npm install --save @mapbox/geojson-extent

example

Live example with Mapbox Static Map API

var geojsonExtent = require('geojson-extent');

geojsonExtent({ type: 'Point', coordinates: [0, 0] }); // returns 0,0,0,0 extent

bin

Provides a binary that takes GeoJSON as stdin and returns a JSON stringified array of extent data.

$ npm install -g geojson-extent
$ geojson-extent < file.geojson

Given an argument of leaflet, this will return Leaflet-formatted data instead.

$ geojson-extent leaflet < file.geojson

api

extent(geojson)

Given any valid GeoJSON object, return bounds in the form [WSEN]. Invalid objects will return null.

extent.polygon(geojson)

Given any valid GeoJSON object, return bounds in the form of a GeoJSON polygon object. Invalid objects will return null.

extent.bboxify(geojson)

Add bounding boxes to all appropriate GeoJSON objects - Feature, FeatureCollection, and Geometry.

changelog

1.0.0

  • First major version release (same as 0.4.0)

0.4.0

  • Confirm type is a valid geojson type before finding extent #5
  • Update dependencies to address security concerns #13

0.3.2

  • update uglifyjs #4

0.3.1

0.3.0

0.2.0

0.1.1

  • Update uglify-js version

0.1.0

  • Added .polygon() for polygon instead of array extent.