Skip to content

haoliangyu/gtran-csv

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

gtran-csv

convert geojson to csv file and backwards

This is a sub-project of gtran.

Installation

npm install gtran-csv

Functions

  • setPromiseLib(object)

    Specify the promise library. If not, the library will use the native Promise.

  • fromGeoJson(geojson, fileName)

    Save the geojson into the given file name.

  • toGeoJson(fileName, options)

    Read the given file into geojson.

    options:

    • mapping - Map csv columns to geojson attributes. Specifically, geographic coordinates are required:
    {
        x: 'x_column_name',
        y: 'y_column_name'
    }

Use Example

var csv = require('gtran-csv');

// if specific promise library is needed
csv.setPromiseLib(require('bluebird'));

// Read CSV file
csv.toGeoJson('source.csv')
.then(function(object) {
    var geojson = object;
});

// Save geojson into CSV file
csv.fromGeoJson(geojson, 'point.csv', {
    mapping: { x: 'longitude', y: 'latitude'}
})
.then(function(fileName) {
    console.log('CSV file has been saved at:' + fileName);
});

About

convert geojson to csv file and backwards

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published