Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/haoliangyu/gtran-shapefile
convert geojson to shapefile and backwards
https://github.com/haoliangyu/gtran-shapefile
conversion geojson shapefile
Last synced: about 1 month ago
JSON representation
convert geojson to shapefile and backwards
- Host: GitHub
- URL: https://github.com/haoliangyu/gtran-shapefile
- Owner: haoliangyu
- License: mit
- Created: 2015-11-13T03:41:11.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2023-08-24T13:30:17.000Z (about 1 year ago)
- Last Synced: 2024-09-20T00:49:47.661Z (about 2 months ago)
- Topics: conversion, geojson, shapefile
- Language: JavaScript
- Size: 166 KB
- Stars: 8
- Watchers: 2
- Forks: 5
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# gtran-shapefile
[![NPM Version](https://img.shields.io/npm/v/gtran-shapefile.svg)](https://www.npmjs.com/package/gtran-shapefile) [![Build Status](https://travis-ci.org/haoliangyu/gtran-shapefile.svg?branch=master)](https://travis-ci.org/haoliangyu/gtran-shapefile)
convert geojson to shapefile and backwards
## Installation
```javascript
npm install gtran-shapefile
```## Functions
* **setPromiseLib(object)**
Specify the promise library. If not, the library will use the native Promise.
* **fromGeoJson(geojson, fileName, options)**
Save the geojson into the given file name.
Options:
* **esriWKT**: ESRI WTK string that specifies the shapefile's spatial reference and generates .prj file. It could be found at [SpatialReference.org](http://spatialreference.org/).
* **toGeoJson(fileName)**
Read the given file and convert it into geojson.
## Use Example
```javascript
var shp = require('gtran-shapefile');// if specific promise library is needed
shp.setPromiseLib(require('bluebird'));// Read shapefile
shp.toGeoJson('source.shp')
.then(function(object) {
var geojson = object;
});// Save geojson into shapefile
shp.fromGeoJson(geojson, 'point.shp', {
// ESRI WKT string of WGS84
esriWKT: 'GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137,298.257223563]],PRIMEM["Greenwich",0],UNIT["Degree",0.017453292519943295]]'
})
.then(function(fileNames) {
console.log('files have been saved at:' + fileNames);
});```