[postgis-users] Loading multiple shapefiles with different schemas into the same PostGIS layer

Todd Fagin tfagin at coordinatesolutions.com
Fri Oct 17 14:38:56 PDT 2008


Greetings PostGIS-ers,

 

I have another newbie question for you.

 

I have multiple shapefiles I want to load into PostGIS as a single layer.
However, these shapefiles have different schemas.  I know that shp2pgsql has
the -a option for appending  However, the tables must have the same schema,
right?  

 

I have come up with a convoluted way to do this and it works.  However, I
have feeling that someone much smarter than I has already found a more
elegant solution to this.

 

Here is what I have done:

 

1. Convert each shapefile to SQL using shp2pgsql; this is especially
important since it creates the the_geom field

2. Run the SQL script for the shapefile that has the schema I will use

3. Edit the remaining .sql files generated for each shapefile by shp2pgsql,
removing everything but the INSERT statements and editing the fields to map
to the appropriate fields in the existing table (this is the part that could
be cumbersome, hence looking for a more elegant solution).

4. Run the edited SQL scripts for each of the remaining shapefiles.

 

Thanks,

 

Todd

 

Todd Fagin

 

Coordinate Solutions, Inc.

2804 NW 18th St.

Oklahoma City, OK 73107

405.740.4324 (voice)

904.471.5548 (fax)

www.coordinatesolutions.com

 

 

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20081017/5bcd16d3/attachment.html>


More information about the postgis-users mailing list