[Gfoss] Export da postgis a shapefile

Rocco Pispico r.pispico a gmail.com
Ven 11 Apr 2014 16:32:10 CEST


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.

2) 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.

3) 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:

<OGRVRTDataSource>
    <OGRVRTLayer name="remapped_layer">
        <SrcDataSource>PG:"dbname='mydb' host='localhost' port='5432'
user='myuser' password='mypassword'</SrcDataSource>
        <SrcSQL>SELECT field1 as alias1, the_geom FROM mytable</SrcSQL>
    </OGRVRTLayer>
</OGRVRTDataSource>

anche questo non testato ma affascinante.

Grazie dell'aiuto.
Rocco
-------------- parte successiva --------------
Un allegato HTML ? stato rimosso...
URL: <http://lists.gfoss.it/pipermail/gfoss/attachments/20140411/2bc2acd8/attachment.html>


Maggiori informazioni sulla lista Gfoss