[postgis-users] loading many similar shapefiles

P Kishor punk.kish at gmail.com
Mon Nov 23 20:27:31 PST 2009


I have many shapefiles that are conceptually identical in structure,
except a couple of columns in each file are named differently. These
columns are unimportant.

How can I load all these files in the same table without the offending columns?

# generate the create table and insert commands
shp2pgsql -s 4269 -c file1 table > load.sql

# generate the insert commands for subsequent files
shp2pgsql -s 4269 -a file2 table >> load.sql
shp2pgsql -s 4269 -a file3 table >> load.sql
..

The above commands generate INSERT statements like so --

INSERT INTO "table" (
  "area",
  "perimeter",
  "file1_",
  "file1_i",
   the_geom
) VALUES (
  '2.29080994500086E-04',
  '6.34477469815224E-02',
 '0106000020AD100000010000000103000020AD100000010000000D000000A4552DE928EA55C0C6F99B5088443E404582A966D6E955C050C8CEDBD8443E40187D0569C6E955C02B508BC1C3443E403DEFC682C2E955C0BB4560AC6F443E40EB8D5A61FAE955C0A6D24F38BB413E402907B30930EA55C0503750E09D403E40C28A53AD85EA55C0A8716F7EC3403E403D997FF44DEB55C058FFE7305F423E402C4833164DEB55C00F4240BE84423E40DAAD65321CEB55C0AFCF9CF529433E40D48041D2A7EA55C046274BADF7433E40FB58C16F43EA55C045F295404A443E40A4552DE928EA55C0C6F99B5088443E40'
);


I don't want file1_ and file1_i and their corresponding values. Is
there a way to specify which columns to load?



-- 
Puneet Kishor



More information about the postgis-users mailing list