node package manager
Love JavaScript? Your insights can make it even better. Take the 2017 JavaScript Ecosystem Survey »


gj2pg Build Status

Streams GeoJSON data to a PostGIS configured PostgreSQL database.

Note: Casts all geometry using ST_Multi, let me know if this is a problem

To get started, install gj2pg, via npm install --save gj2pg.


var GJ2PG = require('gj2pg'),
  config = require('./config'),
gj2pg = new GJ2PG({
  config: config,
  inputFilePath: 'data.json',
  tableName: 'countries',
  propertiesMap: ['ObjID:id', 'Country_Name:name'],
  geometryColumnName: 'geom'

The config format is JSON in the following format:

  "user": "test",
  "password": "password",
  "database": "myDb"

Command Line

npm install -g gj2pg
gj2pg -f data.json -t providers -m 'OBJECTID:id, ProvName:name' -g geom

See help, via gj2pg -h for more information and available options.


  • Figure out a more clear way to map properties/geometry property
  • Up for suggestions..

Special Thanks

To Calvin Metcalf, who wrote most of the original code.