geojson-helpers

Helps read & write GeoJSON files based on RFC 7946 GeoJSON

Usage no npm install needed!

<script type="module">
  import geojsonHelpers from 'https://cdn.skypack.dev/geojson-helpers';
</script>

README

Build Status Coverage Status npm version MIT licensed

GeoJSON Helpers

Helps read & write GeoJSON files based on RFC 7946 GeoJSON.

Install

$ npm install --save geojson-helpers

Quickstart

import geojson from 'geojson-helpers'

const featureCollection = geojson.readFileSync('places.geojson')
// <--Data processing-->
geojson.writeFileSync('new-places.geojson', featureCollection)

Features

  • Reads GeoJSON files
  • Writes GeoJSON files
  • Compact indentation, 1 line per feature (smallest file size possible)
  • Limits coordinates decimals to a maximum of 6
  • Does not include CRS

writeFileSync

Writes GeoJSON file

Parameters

  • path string
  • geojson FeatureCollection GeoJSON FeatureCollection
  • properties [Array<(string | number)>] Only include the following properties

readFileSync

Reads GeoJSON file

Parameters

  • path string File must be a GeoJSON FeatureCollection

Changelog

0.1.0 - 2016-11-09

Begining of project geojson-helpers.

  • readFileSync
  • writeFileSync