1.3.0 • Published 9 years ago

geo-xform v1.3.0

Weekly downloads
5
License
Apache-2.0
Repository
github
Last release
9 years ago

GeoXForm

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

npm travis

Example

  • Get GeoJSON from the web -> transform into csv -> write to disk
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

  • With Homebrew on OSX: brew install gdal
  • On Ubuntu: sudo apt-get install gdal-bin

Install node dependencies

  • (sudo) npm install

Development

Transpile to ES5

  • npm run compile

Test

  • npm test

API

createStream(format, options)

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

  • Format: the requested output format e.g. csv, zip (shapefile), kml
  • Options:
{
      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

  • Input: A stream of individual GeoJSON features as strings or objects
  • Options:
{
    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

  • Options:
{
    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

  • Format: the requested output format e.g. csv, zip (shapefile), kml
  • Options:
{
      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)
}
1.3.0

9 years ago

1.2.4

9 years ago

1.2.3

9 years ago

1.2.2

9 years ago

1.2.1

9 years ago

1.2.0

9 years ago

1.1.5

9 years ago

1.1.4

9 years ago

1.1.3

9 years ago

1.1.2

9 years ago

1.1.1

9 years ago

1.1.0

9 years ago

1.0.15

10 years ago

1.0.14

10 years ago

1.0.13

10 years ago

1.0.12

10 years ago

1.0.11

10 years ago

1.0.10

10 years ago

1.0.9

10 years ago

1.0.8

10 years ago

1.0.7

10 years ago

1.0.6

10 years ago

1.0.5

10 years ago

1.0.4

10 years ago

1.0.2

10 years ago

1.0.1

10 years ago

1.0.0

10 years ago