Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Having a generic GEOGRAPHY column with PostGIS

In PostgreSQL 9 + PostGIS 1.5, is there a way to create a "generic" GEOGRAPHY column? By that I mean a column that would accept POINTs as well as POLYGONs, LINESTRINGs, etc. Until now, I've only seen columns like GEOGRAPHY(POINT,4326) on the Internet.

If that is not possible, then how would you design (from a DB point of view) an entity that is linked to a random geographical object (point, polygon, whatever)? Should I create 3, 4, 5 different tables for each type of geographical object I'd like to support? (1 table for POINT objets, 1 table for POLYGON objects and so on)?

Thanks in advance.

Romain

like image 205
Romain Avatar asked Dec 29 '22 05:12

Romain


1 Answers

Yes, just don't specify a type constraint in the CREATE TABLE statement.

CREATE TABLE mytable ( geog GEOGRAPHY, id SERIAL PRIMARY KEY );
like image 195
Paul Ramsey Avatar answered Jan 10 '23 07:01

Paul Ramsey