PostGIS Tutorial


Creating a PostGIS database

  • This step is already done on n3.
  • We have 2 databases group1_postgis and group2_postgis, created with the right privileges

Additional information about the template

  • Creating a database the template creates two tables named spatial_ref_sys and geometry columns
  • The table definitions for these metadata tables are as follows (both these tables are already created)

and

Using PostGIS

Creating a table that GIS Objects

  • Create a regular table

  • Add a GIS column named geometry of type polygon

  • Syntax of AddGeometryColumn: AddGeometryColumn(<schema_name>, <table_name>, <column_name>, <srid>, <type>, <dimension>)
  • Why use the AddGeometryColumn() function and all the other OpenGIS functions?
    • In addition to creating a new column, using AddGeometryColumn also adds metadata that a simple create statement wont add. E.g. the metadata in geometry_columns added by AddGeometryColumn is used by Mapservers to ensure correct map projections.

Delete a GIS object column

Inserting data into that postGIS Table

Perform spatial query

  • E.g. Find all objects with 100 meters of POINT(-128 49.948 49.948)

References