Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/mborne/node-ogr2pg

[DATA] Helper to load spatial files with multiple formats into postgis
https://github.com/mborne/node-ogr2pg

geojson loader nodejs postgis shapefile

Last synced: 26 days ago
JSON representation

[DATA] Helper to load spatial files with multiple formats into postgis

Awesome Lists containing this project

README

        

# node-ogr2pg

[![Node.js CI](https://github.com/mborne/node-ogr2pg/actions/workflows/node.js.yml/badge.svg)](https://github.com/mborne/node-ogr2pg/actions/workflows/node.js.yml) [![Coverage Status](https://coveralls.io/repos/github/mborne/node-ogr2pg/badge.svg?branch=master)](https://coveralls.io/github/mborne/node-ogr2pg?branch=master)

## Description

Provides an helper to invoke [ogr2ogr](https://www.gdal.org/ogr2ogr.html) and [psql](https://www.postgresql.org/docs/current/static/app-psql.html) to import spatial file into [PostGIS](https://postgis.net/).

## Usage

```js
const ogr2pg = require('@mborne/ogr2pg');

const result = await ogr2pg({
'inputPath': 'place.shp',
'tableName': 'place'
});

console.log(result.status);
console.log(result.message);
console.log(result.command);
```

## Options

| Name | Required? | Description | Default |
| ---------------- | :-------: | ---------------------------------------------------------------- | -------- |
| `inputPath` | YES | Input file path (.shp, .geojson, etc.) | |
| `encoding` | NO | Input encoding (UTF-8, LATIN1,...) | `UTF-8` |
| `tableName` | YES | Output table name | |
| `createTable` | NO | Automatically create table (drop table if exists) | `false` |
| `schemaName` | NO | Output schema name | `public` |
| `createSchema` | NO | Automatically create schema if not exists | `false` |
| `promoteToMulti` | NO | Promote geometry to multi (ex : MultiPolygon instead of Polygon) | `false` |
| `skipFailures` | NO | skip failures when importing data | `false` |

## License

[MIT](LICENSE)