[postgis-users] Initial SRS and geometry columms table creation

Dylan Keon dbkeon.ml at gmail.com
Tue Dec 13 21:27:48 PST 2005


On 12/13/2005 08:16 PM Ivan Kautter wrote the following:
> Listserv subscribers,
> 
> I am just starting out with PostgreSQL and PostGIS.  It appears that it 
> is necessary to create the SRS and geometry_columns tables before 
> importing ESRI shapefile data.  Is this correct?  One thing that seems 
> odd though is that in order to create the geometry_columns table one 
> would have to know what tables are going to be produced by importing GIS 
> data into the database and the resulting name of the geometry_column.

Yes, that's correct.  From the 1.0.6 README.postgis:

   As postgres run:

     createlang plpgsql yourdatabase
     psql -f lwpostgis.sql -d yourdatabase

This will create the geometry_columns and spatial_ref_sys tables.

> I am also wondering if it is necessary to create a spatial table first 
> for each shapefile that one is adding to the database or if one may 
> merely use the loader to create the feature table then modify it by 
> adding a geometry column to it.

You don't need to create the spatial table first.  The shp2pgsql loader 
takes the table name as an argument and will generate SQL statements 
that create the table, add the geometry column, and populate the table.

If you plan to insert spatial data manually, first create the table then 
add the geometry column in this manner:

   SELECT AddGeometryColumn('wells','the_geom',4326,'POINT',2);

This example will create a column (the_geom) for storing 2D point 
geometries in the "wells" table, using an SRID of 4326.  A corresponding 
entry is added to the geometry_columns table.

--Dylan



More information about the postgis-users mailing list