5

How do I put many shapefiles into one table?

The PostGIS plug-in shapefile uploader makes one separate table each time it uploads a shapefile.

1

3 Answers 3

3

This may be a newer feature, but you can change from the default behavior of create to append.

In the shapefile uploader dialog change the table name to your existing one then just click on "Create" and a dropdown should appear with the available options.

enter image description here

2

There's a tool called pgShapeLoader, which allows you to specify the table to which you want the shape loaded. I downloaded OpenGeo 2.0.1, and it came with it. I'm not sure if you can get it anywhere else, but if you can lay your hands on OpenGeo Suite, the tool is bundled in it.

Have a look at this link: http://postgis.net/workshops/postgis-intro/loading_data.html. It shows a screenshot of the tool. And, if you can follow the workshop tutorials, you'll probably get a link somewhere to download it.

You can also use Quantum GIS' SPIT tool (accessible via Database - Spit menu). After adding a shape file to load into PostGIS, you have an option to specify DB Relation Name, which can be the same as what you had used before. Of course with the assumption that you are using PostGIS.

1

you can achive this with some batch scripting:

for %i in (*.shp) do 
shp2pgsql -W Latin5 -s 4326 -I -S -D %i %~.shp myTableName | psql
          -U postgres -h localhost -d myDatabase

i hope it helps you...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.