Importing Data into PostgreSQL
Da Wikipedia, l'enciclopedia libera.
Il testo inglese è tratto dal
sito ufficiale.
Come collaborare alla traduzione
I dati possono essere importati in PostgreSQL usando diversi metodi. PostGIS è dotato di un programma di utilità denominato shp2pgsql che può essere usato per importare i file shape in un database di PostGIS. Per esempio, per importare un file shape chiamato lakes in un database PostgreSQL chiamato gis_data, bisogna usare il comando seguente:
shp2pgsql -s 2964 lakes.shp lakes_new | psql gis_data
Questo crea un nuovo livello chiamato lakes_new nel database gis_data. Il nuovo livello avrà un spatial reference identifier (SRID) di 2964. Vedi Capitolo 6 per ulteriori informazioni su spatial reference identifier e proiezioni.
QGIS presenta un plugin chiamato SPIT (Shapefile to PostGIS Import Tool). Lo SPIT può essere usato per caricare gli shapefiles multipli contemporaneamente ed include il sostegno per gli schemi. Per usare lo SPIT, aprite il Plugin Manager dal menu degli Strumenti e caricate il plugin, scegliete la finestra di dialogo vicino allo SPIT plugin ed fare click su Ok. L'icona dello SPIT sarà aggiunta plugin della barra degli strumenti.
Per importare uno shapefile, fare click sullo strumento dello SPIT nella barra degli strumenti in modo aprire la finestra di dialogo. Potete aggiungere uno o più file alla coda facendo click sul tasto Importa. Il progresso dell'importazione come pure eventuali errori/avvertenze vengono visualizzati quando ciascuno shapefile viene elaborato.
shp2pgsql -s 2964 lakes.shp lakes_new | psql gis_data
This creates a new layer named lakes_new in the the gis_data database. The new layer will have a spatial reference identifier (SRID) of 2964. See Chapter [*] for more information on spatial reference systems and projections.
QGIS comes with a plugin named SPIT (Shapefile to PostGIS Import Tool). SPIT can be used to load multiple shapefiles at one time and includes support for schemas. To use SPIT, open the Plugin Manager from the Tools menu and load the plugin by checking the box next to the SPIT plugin and click Ok. The SPIT icon will be added to the plugin toolbar.
To import a shapefile, click on the SPIT tool in the toolbar to open the dialog. You can add one or more files to the queue by clicking on the Add button. To process the files, click on the Import button. The progress of the import as well as any errors/warnings will be displayed as each shapefile is processed.

