[postgis-users] Loading multiple shapefiles with different schemas into the same PostGIS layer
tfagin at coordinatesolutions.com
Fri Oct 17 14:38:56 PDT 2008
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,
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.
Coordinate Solutions, Inc.
2804 NW 18th St.
Oklahoma City, OK 73107
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the postgis-users