mmomtchev / node-gdal-async

Node.js bindings for GDAL (Geospatial Data Abstraction Library) with full async support
https://mmomtchev.github.io/node-gdal-async/
Apache License 2.0
133 stars 26 forks source link

Unable to find driver PostgreSQL #64

Closed bertday closed 1 year ago

bertday commented 1 year ago

Hello! 👋

I'm trying to use vectorTranslate to copy a file from GeoJSON to Postgres (thank you again @mmomtchev for pointing me to that function). My code looks like:

import gdal from 'gdal-async';

const datasetIn = gdal.open('/path/to/some.geojson');

// this works!
// const datasetOut = gdal.vectorTranslate(
//   'test.csv',
//   datasetIn,
// );

// this does not work
const datasetOut = gdal.vectorTranslate(
  'PG:dbname=my_db',
  datasetIn,
  [
    '-f', 'PostgreSQL',
  ],
);

datasetOut.close();

I get an error:

Uncaught Error Error: Unable to find driver `PostgreSQL'.

I'm in a brand-new project with "gdal-async": "^3.6.2" and Node 18.13.0. Would greatly appreciate any guidance if I'm not calling this properly.

mmomtchev commented 1 year ago

The prebuilt binaries of gdal-async are fully self-contained which limits the number of external libraries that I can use. In order to support PosgreSQL, the npm distribution must contain PostgreSQL. You can rebuild it against your system installed GDAL when installing, in this case it will support everything your GDAL supports.

npm install gdal-async --build-from-source --shared_gdal