2017-04-20 4 views
0

Salut Je suis très nouveau à PostgreSQL/PostGIS et viens d'apprendre comment convertir des fichiers Shapefiles en fichier SQL et l'importer dans PostGIS en utilisant le shp2pgsql en suivant le tutoriel this. Ce que j'ai remarqué est que chaque fois que je convertis un Shapefile, il génère un fichier SQL qui a une instruction CREATE TABLE. Maintenant, ma question est, y at-il un moyen ou est-il même possible d'insérer un nouveau Shapefile (avec un nouvel ensemble de couches) dans une table existante plutôt que d'en créer une nouvelle?PostgreSQL/PostGIS: shp2pgsql INSERT au lieu de Créer une nouvelle table

J'espère que je l'ai bien expliqué. Merci.

Répondre

2

Vous pouvez utiliser l'option Ajouter dans votre ligne de commande. Comme ceci:

.\shp2pgsql.exe -c -I -g "geom" fistShpFile.shp 
.\shp2pgsql.exe -a -g "geom" nextShpFile.shp 
.\shp2pgsql.exe -a -g "geom" nextShpFile.shp 
... 
(-d|a|c|p) These are mutually exclusive options: 

-d Drops the table, then recreates it and populates it with current shape file data. 
-a Appends shape file into current table, must be exactly the same table schema. 
-c Creates a new table and populates it, default if you do not specify any options. 
-p Prepare mode, only creates the table. 

http://www.bostongis.com/pgsql2shp_shp2pgsql_quickguide.bqg

Ou utiliser shp2pgsql -? pour d'autres options.