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 starting my first PostGIS project, and in various books and tutorials I've seen the geometry column labelled either 'geom' or 'the_geom'. Is one more conventional than the other?

Furthermore, is there a good reason to use 'geom'/'the_geom' instead of a more descriptive name for the geometry column? (E.g. 'centre_point' for the central point of a feature.) We don't label conventional db columns 'the_int' or 'the_string', so why label geometry columns this way?

share|improve this question
add comment

3 Answers 3

up vote 10 down vote accepted

As of PostGIS version 2.0, "geom" is the common column name. (At least I see it documentation, etc.) Prior to that it was "the_geom", and I can only speculate as to why.

You may safely use either, but I am happily using "geom" in PostGIS and SpatiaLite.

Edit: Because I completely missed the second part of the question.
In general, a common name is convenient because it is common for GIS software to require that geometries in a table be constrained to a single specific type, SRID, etc. Therefore, table names tend to be more descriptive than the geometry column name. For example, you would expect to find tables named "school_zone_polygons", "school_zone_centroids" each with a "geom" column; not a "school_zones" table with "geom_polygon", "geom_centroid" columns.

Having a common name means you don't have to check the schema every time you want to reference a geometry column.

share|improve this answer
2  
It's common in object-oriented programming to name top-level objects by prepending an article. This distinguishes 'the_chair' from any later instances of type 'chair'. But PostGIS doesn't really work that way, and switching to just plain 'geom' probably made cross-platform implementation easier. –  L_Holcombe Jan 29 '13 at 23:44
    
Yeah, I always guessed that it was to prevent a (possible future) collision with a reserved word. Nobody likes typing double quotes. –  Scro Jan 30 '13 at 2:49
    
Thanks Scro for clarifying. Though in the instance where you have multiple geometry columns in a table (not that I'm planning to), your counterexample would seem an ideal convention. I.e. table "school_zones" with "geom_polygon", "geom_centroid" etc. –  Nick Jan 31 '13 at 2:51
add comment

One potential reason that "geom" or "the_geom" was chosen as the generic name for the "shape" field was because you can actually store multiple geometry types (point, line, poly, etc) in the one "geom" field in the same table. You can even look back to 2005 when this was discussed on the PostGIS email list.

For example, you could store all of your houses, streets, and county boundaries in the same "geom" field of your single table. There are obviously reasons why you may choose to do otherwise, but this could represent the reason why a generic "geom" column name was used.

Hopefully some long-time PostGIS users will chime in with more details on why "geom" was actually chosen.

share|improve this answer
add comment

When using Geoserver REST api in publishing existing PostGis tables, the REST command will fail if the geometry column is not named "geom".

share|improve this answer
2  
I'm pretty sure that this behavior is a bug with Geoserver, and once it is solved, it should no longer be a point of consideration –  Devdatta Tengshe Aug 1 '13 at 3:33
add comment

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.