[postgis-users] load more than one shape files to one table?

Eric Randall eprand at earthlink.net
Mon Nov 13 15:21:21 PST 2006


Unless I misunderstand (which happens all the time).
Use shp2pgsql to load the 150 routes to tables (with script).
Create a new table into which to insert the route tables
with a field(s) to keep the original route/segment identity.

Something like:


select dropgeometrycolumn('','allroutes','geom');
drop table allroutes;
begin;
create table allroutes (gid serial primary key,
route_gid int4,
segment_id int4,
other_fields );

select addgeometrycolumn('','allroutes','geom','srid','multilinestring',2);

insert into allroutes (route_gid,segment_id,other_fields,geom) select 
route_gid,segment_id,other_fields,geom from route1;
insert into allroutes (route_gid,segment_id,other_fields,geom) select 
route_gid,segment_id,other_fields,geom from route2;
...
...
insert into allroutes (route_gid,segment_id,other_fields,geom) select 
route_gid,segment_id,other_fields,geom from route150;
end;


-Eric



More information about the postgis-users mailing list