gtran
Geospatial data I/O package making data conversion simple and manageable.
Installation
npm install gtran
Features
-
Multi-format support - Just one package.
-
Simple functions - Consistent functions for different formats, just from() and to().
-
Promised - Powered by native Promise and it is happy working with your choice of promise library (Q, bluebird, and promise).
-
GeoJson input/output - Get GeoJson from your file and save it into whatever you want.
Supported Formats
-
CSV (point data only)
-
KML
-
KMZ (write only)
-
Shapefile
-
TopoJson (write only)
Functions
gtran provides two of functions: from[format name]() and to[format name]() for each support format.
-
from[format name](fileName [, options])
Read the geospatial data file and return a GeoJson object.
-
to[format name](geojson, fileName [,options])
Write the GeoJson object into a file with given name and format. If the file name is not given, the function returns a data object that could be written into file.
A full list of available functions:
-
setPromiseLib(object)
Specify the promise library. If not, the library will use the native Promise.
-
.fromCSV(fileName, options)
options:
- projection - Geographic coordinate columns, necessary parameter. Please check the use example.
-
.toCSV(geojson, fileName)
-
.fromKml(fileName)
-
.toKml(geojson, fileName, options)
options:
-
name - Name property of feature.
-
symbol - Symbol of saved features. Detail about supported style options.
-
-
.toKmz(geojson, fileName)
-
.fromShp(fileName)
-
.toShp(geojson, fileName, options)
options:
- esriWKT - ESRI WTK string that specifies the shapefile's spatial reference and generates .prj file. The ESRI WKT string could be found at SpatialReference.org.
-
.toTopo(geojson)
Use Example
var gtran = ;# Specify the promise library if necessarygtran;# Read shapefilegtran;# Save geojson into shapefilegtran;# Read csv file# If the testcsv has two columns: latitude and longitudegtran;# Save geojson into a csv filegtran;