Home

Awesome

GeoXForm

A library for transforming large streams of geojson into csv, kml, shapefile and other formats

npm travis

Example

const GeoXForm = require('geo-xform')
const request = require('request')
const fs = require('fs')
const id = '593b88391b614123890f54a1db8fbf55_0'
request.get(`http://opendata.arcgis.com/datasets/${id}.geojson`)
.pipe(GeoXForm.createStream('csv'))
.pipe(fs.createWriteStream('./trees.csv'))
.on('finish', () => console.log('File written to trees.csv'))

Set up

Install GDAL

Install node dependencies

Development

Transpile to ES5

Test

API

createStream(format, options)

Create a stream that takes in geojson of arbitrary size and returns data in the selected format

{
      path: string // disk location to write temp files (optional)
      name: string // sets the name file parts (shapefile only)
      metadata: string // and xml string to write to file (shapefile only)
      srs: string // the spatial reference system for projecting transformed data (shapefile only)
}

GeoJSON.createStream(options)

Create a stream that takes in individual features and returns a feature collection

{
    json: boolean // flags whether the input is JSON or string
}

VRT.createStream(options)

Create a steam that takes in geojson and outputs an OGR Virtual Layer

{
    size: integer // number of features to write into each GeoJSON part, defaults to 5000
    path: string // output path to write the VRT XML and GeoJSON parts
}

OGR.createStream(format, options)

Create a stream that takes in a layer and outputs transformed data

{
      geometry: string // on of ['point', 'line', 'polygon']
      fields: array // the names of fields in a given dataset (csv only)
      name: string // sets the name file parts (shapefile only)
      metadata: string // and xml string to write to file (shapefile only)
      srs: string // the spatial reference system for projecting transformed data (shapefile only)
}