[Gfoss] Export da postgis a shapefile

Ciao
come sempre la lista va più veloce dei miei test.
Grazie a Paolo, Gino e Diego per i suggerimenti che convergono su:

  1. ogr2ogr -f “ESRI Shapefile” output.shp PG:“host=xxxx port=xxxx dbname=xxxx user=xxxx password=xxxx” nomelayerpostgis -sql “SELECT campotroppolungo1 AS C1, campotroppolungo2 AS C2 from nomelayerpostgis”

Testato, funzionante e veloce.

  1. pgsql2shp -f “/path/to/shape” -h localhost -u myuser -P mypasswrord mydb
    “SELECT field1 as alias1, the_geom FROM mytable’”

Non testato ma immagino funzioni.

  1. meglio ancora, definirti un OGR virtual format che puoi riusare anche
    successivamente o per vedere direttamente su QGIS la tabella PostGIS
    con gli stessi nomi che avresti sullo shapefile (pur rimanendo
    invariati sul db), e quindi esportarli con tali alias:
PG:"dbname='mydb' host='localhost' port='5432' user='myuser' password='mypassword' SELECT field1 as alias1, the_geom FROM mytable

anche questo non testato ma affascinante.

Grazie dell’aiuto.
Rocco