Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I'm currently using PostGIS 1.5.3, but I will be upgrading to 2.0 soon. So please note any differences between the two versions that are relevant to the following questions.

  • Is it possible to create a column of the PostGIS geometry type that allows insertion of polygons and multipolygons but restricts insertion of other geometry types without manually modifying the constraint PostGIS generates when calling AddGeometryColumn?
  • Are there reasons not to do this? In particular, does PostGIS store any metadata that manually modifying the constraint might negatively impact? (I'm very new to PostGIS, so forgive me if the idea of PostGIS storing metadata is absurd.)
  • How significant is any overhead incurred by using multipolygons for everything?

I'm already aware of using ST_Multi to convert polygons into multipolygons before insertion, so if it's not possible or not a good idea, I'll do that.

share|improve this question

1 Answer 1

up vote 3 down vote accepted

For each of your questions...

  1. Not without manually modifying the constraint.

  2. There is some metadata stored in the PostGIS geometry. Technically, there is no reason not to do this. If you want a column to hold polygon or multipolygon, that is up to you. The general reason for sticking with one geometry type per column is simplicity as the table grows and/or if the table is massive.

  3. A multipolygon comprised of only one polygon will be larger than just the polygon, but not significantly. The speed of spatially querying (with the appropriate index) the multipolygon with one polygon vs just one polygon would be the same though.

For my data, if the column is to contain polygons, I have the column be a multipolygon as it allows for the eventuality that a multipolygon will be inserted in the column. Just run ST_Multi as you're inserting.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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