Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to export postegresql table to .shp using org2org? #92

Closed
DanielleRS opened this issue Dec 14, 2022 · 3 comments
Closed

How to export postegresql table to .shp using org2org? #92

DanielleRS opened this issue Dec 14, 2022 · 3 comments
Labels

Comments

@DanielleRS
Copy link

Hi,

I'm trying to export a postgresql database view to shapefile using org2org but I'm not succeeding.

I did the following:

`const ogr2ogr = require('ogr2ogr').default;
var shapefile = ogr2ogr('PG:dbname=postgres host=localhost port=5432 user=postgres password=xxx',
{
format: 'ESRI Shapefile',
options: ['-sql', 'SELECT * FROM ViewTest'],
project: 'ESPG:4326',
destination: 'C:\Users\Danielle\output.shp'
});

console.log(shapefile);`

Can you help me?

@wavded
Copy link
Owner

wavded commented Dec 15, 2022

It looks like you aren't awaiting the promise. You probably want to catch any errors as well.

const ogr2ogr = require('ogr2ogr').default;

(async() {
  try {
    let shapefile = await ogr2ogr(
      'PG:dbname=postgres host=localhost port=5432 user=postgres password=xxx', {
        format: 'ESRI Shapefile',
        options: ['-sql', 'SELECT * FROM ViewTest'],
        project: 'ESPG:4326',
        destination: 'C:\Users\Danielle\output.shp'
    });
    console.log("shapefile", shapefile);
  } catch (err) {
    console.error("error", err);
  }
})()

See https://github.com/wavded/ogr2ogr#usage for more examples.

@github-actions
Copy link

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.

@github-actions github-actions bot added the stale label Jan 15, 2023
@github-actions
Copy link

This issue was closed because it has been stalled for 5 days with no activity.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants