diadia

興味があることをやってみる。自分のメモを残しておきます。

postgis環境構築について

windowsで環境構築に詰まって、macでも詰まってしまった。どうすればよいのやら... 結局詰まっている場所は同じ場所だ。 CREATE EXTENSION postgis; を入力すると、windows,mac両者ともエラーが出てしまう。 windowsの場合はまずpostgresqlインストーラpostgresqlをインストールする。終わりがけにスタッグビルダが起動するので、そこでpostgisをインストールする流れを踏む。そして新たにデータベースを作成する。これは、SQLとしてCREATE DATABASE hoge;としても良いし、createdb -U postgres hogeでも良い。そのあと作成したデータベースに接続してCREATE EXTENSION postgis;と入力すればよいはずである。しかし、それに関わるファイルがないとエラーが出る。実際にそのファイルが有るにも関わらず。macもCREATE EXTENSION postgis;で詰まってしまっている。

ERROR:  could not load library "/Library/PostgreSQL/11/lib/postgresql/rtpostgis-2.5.so": dlopen(/Library/PostgreSQL/11/lib/postgresql/rtpostgis-2.5.so, 10): Library not loaded: @loader_path/../../lib/libssl.1.0.0.dylib
  Referenced from: /Library/PostgreSQL/11/lib/postgresql/libgdal.20.dylib
  Reason: image not found

上記のエラーが出てしまっている。魔境。。。

 

postgis2.5の利用要件

https://postgis.net/docs/manual-2.5/postgis_installation.html#install_requirements

postgreSQLを9.4以上を使っていること。postgispostgresqlの対応状況はこちらを確認すること。 https://trac.osgeo.org/postgis/wiki/UsersWikiPostgreSQLPostGIS

createlangコマンドについて

createlangはcreatedbコマンドの後に実行するとドキュメントに書いてある。

createdb yourdatabase
createlang plpgsql yourdatabase
psql -d yourdatabase -f postgis.sql
psql -d yourdatabase -f postgis_comments.sql
psql -d yourdatabase -f spatial_ref_sys.sql
psql -d yourdatabase -f topology.sql
psql -d yourdatabase -f topology_comments.sql

-- only if you compiled with raster (GDAL)
psql -d yourdatabase -f rtpostgis.sql
psql -d yourdatabase -f raster_comments.sql

--if you built with sfcgal support --
psql -d yourdatabase -f sfcgal.sql
psql -d yourdatabase -f sfcgal_comments.sql

しかしwindowsにインストールしたpostgresqlにはなかった。これについてはどうドキュメントに以下のように書いてある。

https://postgis.net/docs/manual-2.5/postgis_installation.html#create_new_db

Many of the PostGIS functions are written in the PL/pgSQL procedural language. As such, the next step to create a PostGIS database is to enable the PL/pgSQL language in your new database. This is accomplish by the command below command. For PostgreSQL 8.4+, this is generally already installed

要するに8.4以上のバージョンにはすでにインストールされているらしい。11を使っているのでcreatelangは使わないってことでオッケイなんだよね?