# geojson-writer

> Reads & writes GeoJSON files based on RFC 7946 GeoJSON

Latest version **0.3.6** (published 2017-01-28) · MIT license · 0 weekly downloads

## Install

```sh
npm install geojson-writer
pnpm add geojson-writer
yarn add geojson-writer
bun add geojson-writer
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.3.6 |
| Published | 2017-01-28 |
| First published | 2017-01-09 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 3 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 6 |
| Author | Denis Carriere |
| Maintainers | deniscarriere |
| Keywords | gis, geo, geojs, geospatial, geography, geojson |

## Links

- npm: https://www.npmjs.com/package/geojson-writer
- Repository: https://github.com/DenisCarriere/geojson-helpers
- Homepage: https://github.com/DenisCarriere/geojson-helpers#readme
- Issues: https://github.com/DenisCarriere/geojson-helpers/issues
- npm.io page: https://npm.io/package/geojson-writer

## Dependencies (3)

- [deep-slice](https://npm.io/package/deep-slice.md) ^1.0.0
- [@types/node](https://npm.io/package/@types/node.md) ^7.0.1
- [@types/geojson](https://npm.io/package/@types/geojson.md) 0.0.32

## Alternatives

- [@mapbox/jsonlint-lines-primitives](https://npm.io/package/@mapbox/jsonlint-lines-primitives.md) — 5.3M weekly downloads
- [reftools](https://npm.io/package/reftools.md) — 3.5M weekly downloads
- [@hey-api/openapi-ts](https://npm.io/package/@hey-api/openapi-ts.md) — 3.5M weekly downloads
- [@mapbox/geojson-rewind](https://npm.io/package/@mapbox/geojson-rewind.md) — 2.4M weekly downloads
- [turbo-stream](https://npm.io/package/turbo-stream.md) — 1.7M weekly downloads

## Recent versions

- 0.3.6 (latest) — 2017-01-28
- 0.3.5 — 2017-01-28
- 0.3.4 — 2017-01-22
- 0.3.3 — 2017-01-22
- 0.3.2 — 2017-01-22
- 0.3.1 — 2017-01-09
- 0.3.0 — 2017-01-09

## README

# [GeoJSON Writer](https://www.npmjs.com/package/geojson-writer)

[![Build Status](https://travis-ci.org/DenisCarriere/geojson-writer.svg?branch=master)](https://travis-ci.org/DenisCarriere/geojson-writer)
[![Circle CI](https://circleci.com/gh/DenisCarriere/geojson-writer.svg?style=svg)](https://circleci.com/gh/DenisCarriere/geojson-writer)
[![Coverage Status](https://coveralls.io/repos/github/DenisCarriere/geojson-writer/badge.svg?branch=master)](https://coveralls.io/github/DenisCarriere/geojson-writer?branch=master)
[![npm version](https://badge.fury.io/js/geojson-writer.svg)](https://badge.fury.io/js/geojson-writer)
[![Known Vulnerabilities](https://snyk.io/test/github/deniscarriere/geojson-writer/badge.svg)](https://snyk.io/test/github/deniscarriere/geojson-writer)
[![MIT licensed](https://img.shields.io/badge/license-MIT-blue.svg)](https://raw.githubusercontent.com/DenisCarriere/geojson-writer/master/LICENSE)

Reads & writes GeoJSON files based on [RFC 7946 GeoJSON](http://www.macwright.org/2016/11/07/the-geojson-ietf-standard.html).

## Install

```bash
$ npm install --save geojson-writer
```

## Quickstart

```javascript
import {writer, reader} from 'geojson-writer'

const data = reader('places.geojson')
// <--Data processing-->
writer('places-processed.geojson', data)
```

## 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

## API

### writer

Writes GeoJSON file

**Parameters**

-   `path` **[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** File path
-   `geojson` **Features** GeoJSON FeatureCollection
-   `options` **\[Options](default {})** Options
    -   `options.properties` **\[[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)&lt;[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)>]** List of properties to include in GeoJSON
    -   `options.precision` **\[[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)]** Reduce coordinate precision (optional, default `6`)
    -   `options.boolean` **\[[boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)]** Drop Z coordinates (optional, default `false`)
    -   `options.properties` **\[[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)&lt;([string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String) \| [number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number))>]** Only include the following properties

Returns **void** 

### removeEmptyProperties

Remove Empty values

**Parameters**

-   `feature` **Feature** 

### reader

Reads GeoJSON file

**Parameters**

-   `path` **[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** File must be a GeoJSON FeatureCollection

Returns **Features** GeoJSON FeatureCollection

### toFix

Reduce coordinate precision

**Parameters**

-   `array`  
-   `precision`   (optional, default `6`)

### writeFeature

Write Feature

**Parameters**

-   `stream`  
-   `feature`  
-   `index`  
-   `array`

---
_Source: https://npm.io/package/geojson-writer · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
