We want to store data from shape files in PostGIS all in one table.

There will be two columns in the table:

  • boundary - The polygon data (How do we store this?)
  • mongo_id - Links to a mongo database

It seems if we use shp2postgis it creates a whole set of tables for that shapefile. We want to use one table for all boundary data.

What is the best way to do this? (Do we need to use a specific srid?)


I am assuming that by shp2postgis you actually mean shp2pgsql. If so, then the -a option will append your data into an existing table rather than replacing the data.


Probably you are seeing the postgis metadata tables, which contain things such as projection information, and information about any geometry columns in tables, and what projection they are in. If you posted the names of the tables you have that might help. Each shapefile should create one table with a geometry column, with all your other data.

Also bear in mind that PostGIS needs a unique ID column in the table, so you will need more than two columns.

You are free to create as many geometry columns in each table as you like -- for instance you could create the centroid of a polygon object in the same table -- but this must be done using PostGIS functions not using shp2postgis.

  • What I am trying to do is this: 1. Create one table where I can have a polygon and mongo_id 2. The metadata for the shape is stored in mongo but the actual shape is stored in postgres, but the information about the shape is in mongo. The only problem is, if I get shapes that have different srid's will I have problems if I store them in the same table? Mar 26 '12 at 16:15
  • how can it be in a different projection if it's from the same shp file?
    – Stev_k
    Mar 26 '12 at 16:19
  • They are different shape files Mar 26 '12 at 16:22
  • I want to have one table where I can use multiple shape files Mar 26 '12 at 16:22
  • well, that's possible, but don't think you'll be able to use shp2postgis. You'll probably have to load additional shapefiles in manually unless anyone else knows a suitable tool. If you manage that I would probably store all information in the table in one standard projection, then transform individual records on the fly if you need to.
    – Stev_k
    Mar 26 '12 at 16:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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