https://github.com/jdesboeufs/geojson2shp
Convert GeoJSON into Shapefile in pure JavaScript
https://github.com/jdesboeufs/geojson2shp
converter geojson gis shapefile
Last synced: 5 months ago
JSON representation
Convert GeoJSON into Shapefile in pure JavaScript
- Host: GitHub
- URL: https://github.com/jdesboeufs/geojson2shp
- Owner: jdesboeufs
- License: mit
- Created: 2018-05-03T21:13:08.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2022-02-07T21:01:46.000Z (over 3 years ago)
- Last Synced: 2024-12-27T17:06:17.277Z (6 months ago)
- Topics: converter, geojson, gis, shapefile
- Language: JavaScript
- Size: 208 KB
- Stars: 49
- Watchers: 0
- Forks: 16
- Open Issues: 9
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# geojson2shp
Convert GeoJSON into Shapefile in pure JavaScript## Prerequisites
* [Node.js](https://nodejs.org/en/download/package-manager/) 12+
## Usage (CLI)
### With global installation
```bash
# Installation
npm install geojson2shp -g# Conversion
cat my.geojson | geojson2shp > my-shp.zip
```### With npx (included in Node.js installation)
```bash
# Conversion
cat my.geojson | npx geojson2shp > my-shp.zip
```## Usage (Node.js)
### Basic
```js
const {convert} = require('geojson2shp')const options = {
layer: 'my-layer',
targetCrs: 2154
}// Paths
await convert('/path/to/source.geojson', '/path/to/dest-shp.zip', options)// Streams
await convert(inputGeoJSONStream, outputZippedShapefileStream, options)// FeatureCollection as input
const featureCollection = {type: 'FeatureCollection', features: [/* */]}
await convert(featureCollection, '/path/to/dest-shp.zip', options)// Features as input
const features = [
{type: 'Feature', geometry: {/* */}, properties: {}},
{type: 'Feature', geometry: {/* */}, properties: {}}
]
await convert(features, '/path/to/dest-shp.zip', options)// Or mix them ;)
```### Custom stream
```js
const fs = require('fs')
const {createConvertStream} = require('geojson2shp')myGeoJSONStream
.pipe(createConvertStream({
targetCrs: 2154,
layer: 'my-layer'
}))
.pipe(fs.writeWriteStream('/path/to/my-shapefile.zip'))
```## License
MIT