3

I currently have some scripts that use OGR2OGR to translate data form various source formats like ESRI Shapefile, GML etc to other file formats but especially to my PostGIS database.

My normal command would be:

ogr2ogr -f PostgreSQL PG:"pg conn settings" shapefile.shp

I now need to do this in a Node script so have installed the node gdal module (https://github.com/naturalatlas/node-gdal) which seems to have a lot of functionality of the GDAL library.

So I tried to use the example here to a least connect to my PostGIS database.

var connString = "PG: host=%s dbname=%s user=%s password=%s" %(databaseServer,databaseName,databaseUser,databasePW)

var conn = gdal.open(connString)

However, I receive an error saying gdal.open expects a path.

Has anyone got examples of using Node GDAL for ogr2ogr translations or loading to PostGIS.

2

Are you sure that the driver is implemented? I have no experience with node-gdal myself, but I don't see it in the list of bundled drivers. There is also an open issue concerning PostgreSQL support.

Otherwise you might want to add a driver to the gdal.open() method, but as I said, I couldn't find it in the bundled drivers. I looked for the PG: string which indicates the PostgreSQL driver.

  • yes you are correct. Strange thing is that it is operating system specific. If i install it on OSX it is there as a driver. – tjmgis Jan 28 '16 at 17:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.