PostGISがPostgreSQLのデータベースとやりとりするためにpl/pgsql言語を有効にします
createlang plpgsql mydb # データベースmydbに対して有効
postgis.sqlスクリプトの読み込み
psql -f /usr/local/pgsql/share/contrib/postgis-1.5/postgis.sql -d mydb
spatial_ref_sys.sqlスクリプトの読み込み
postgres$ psql -f /usr/local/pgsql/share/contrib/postgis-1.5/spatial_ref_sys.sql -d mydb
読み込みが成功しているか確認
$ psql mydb
psql (8.4.3)
Type "help" for help.
mydb=# \d
List of relations
Schema | Name | Type | Owner
--------+------------------------+----------+----------
public | account | table | postgres
public | auto_identified | table | postgres
public | auto_identified_id_seq | sequence | postgres
public | geography_columns | view | postgres
public | geometry_columns | table | postgres
public | spatial_ref_sys | table | postgres
(6 rows)
mydb=# \d geometry_columns
Table "public.geometry_columns"
Column | Type | Modifiers
-------------------+------------------------+-----------
f_table_catalog | character varying(256) | not null
f_table_schema | character varying(256) | not null
f_table_name | character varying(256) | not null
f_geometry_column | character varying(256) | not null
coord_dimension | integer | not null
srid | integer | not null
type | character varying(30) | not null
Indexes:
"geometry_columns_pk" PRIMARY KEY, btree (f_table_catalog, f_table_schema, f_table_name, f_geometry_column)
PostGISの関数の確認
mydb=# \df postgis*
List of functions
Schema | Name | Result data type | Argument data types | Type
--------+----------------------------+------------------+-----------------------------------+---------
public | postgis_addbbox | geometry | geometry | normal
public | postgis_cache_bbox | trigger | | trigger
public | postgis_dropbbox | geometry | geometry | normal
public | postgis_full_version | text | | normal
public | postgis_geos_version | text | | normal
public | postgis_getbbox | box2d | geometry | normal
public | postgis_gist_joinsel | double precision | internal, oid, internal, smallint | normal
public | postgis_gist_sel | double precision | internal, oid, internal, integer | normal
public | postgis_hasbbox | boolean | geometry | normal
public | postgis_lib_build_date | text | | normal
public | postgis_lib_version | text | | normal
public | postgis_libxml_version | text | | normal
public | postgis_noop | geometry | geometry | normal
public | postgis_proj_version | text | | normal
public | postgis_scripts_build_date | text | | normal
public | postgis_scripts_installed | text | | normal
public | postgis_scripts_released | text | | normal
public | postgis_transform_geometry | geometry | geometry, text, text, integer | normal
public | postgis_uses_stats | boolean | | normal
public | postgis_version | text | | normal
(20 rows)
PostGISのVersion確認
mydb=# SELECT postgis_version();
postgis_version
---------------------------------------
1.5 USE_GEOS=1 USE_PROJ=1 USE_STATS=1
(1 row)
※PostGISをPostgreSQLで使うためにはココを参照してください。