views:

40

answers:

3

The usual way to create a geometry column is AddGeometryColumn, however I have to work with pre-existing columns, so I can't use that function (as far as I know).

Thanks to the PostGIS docs, I can already register the column in the "geometry_columns" table, however AddGeometryColumn seems to do more than create a column and add a row in geometry_columns, for example it adds checks on the column.


So my question is what: what do I need to do to register the column manually, besides adding a row in *geometry_columns* ?

(for example, is there a modified version AddGeometryColumn that works with an existing column ?)

A: 

Given the function is in PGSQL, maybe I can create a copy of the AddGeometryColumn function and remove the parts that creates a column, but I doubt that would be a future-proof idea and I also doubt I'm the first one to notice the documentation is incomplete.

wildpeaks
+1  A: 

The easiest way of doing it on existing columns is using the function Populate_Geometry_Columns:
http://postgis.org/documentation/manual-1.5/Populate_Geometry_Columns.html

In other words: The function you are asking for is already there :-)

HTH Nicklas

Nicklas Avén
Good suggestion, however I wish it would apply itself only to a specific column instead of a whole table. But it's definitely safer in regards to upgrades than making a modified version of AddGeometryColumn, thanks.
wildpeaks
It is a plpgsql function so maybe you can modify it in an easy way.
Nicklas Avén
A: 

As you said, AddGeometryColumn is only a handy shortcut for creating not only the column but adding cechks and indexes. Of course, you can add these by hand to an existing column. You simply need to do the same things that the AddGeometryColumn does for you in a single command.

If you need to transfer one "regular" column to a "gis" column, why not use SELECT INTO for transfering the data?

DrColossos