実行環境
- Windows 7 SP1 64bit
- コマンドプロンプトの代わりにConEmu 151208を使用
(1)バイナリをダウンロードし、必要なファイルを手動でコピー
まず少しスクロールした右側に
ダウンロードした
(2)起動用バッチファイルに環境変数を追加(ラスタ用)
12@echo off set pgdir=./ set ctl=%pgdir%/bin/pg_ctl set dir=%pgdir%/data set pid=%dir%/postmaster.pid :: set environmental variables for PostGIS Raster set GDAL_DATA=../gdal-data set POSTGIS_GDAL_ENABLED_DRIVERS=ENABLE_ALL set POSTGIS_ENABLE_OUTDB_RASTERS=1 if exist "%pid%" ( echo postmaster.pid exists and PostgreSQL have been started possibly. goto ask ) else ( "%ctl%" -D "%dir%" start ) :ask set /p inp="press [R] to restart PostgreSQL, [Q] to quit : " if "%inp%"=="R" ( "%ctl%" -D "%dir%" restart ) else if "%inp%"=="Q" ( "%ctl%" -D "%dir%" stop goto :eof ) goto ask
↓ 起動させた様子。PostGIS
(3)テスト
psql$ psql -U postgres psql (9.5rc1) Type "help" for help. postgres=# create database test_postgis22; CREATE DATABASE postgres=# \c test_postgis22 You are now connected to database "test_postgis22" as user "postg res". # create extension postgis; CREATE EXTENSION # select postgis_full_version(); postgis_full_version ------------------------------------------------------------------ POSTGIS="2.2.0 r14208" GEOS="3.5.0-CAPI-1.9.0 r4090" PROJ="Rel. 4.9.1, 04 March 2015" GDAL="GDAL 2.0.1, released 2015/09/15" LIBX ML="2.7.8" LIBJSON="0.12" RASTER (1 row)
もう一つテスト。GDAL
ST_AsPNG()
select st_asPNG( st_asRaster( st_buffer(st_point(1,5), 10), 150, 150, '8BUI') ); st_aspng ----------------------------------------------------------------- \x89504e470d0a1a0a0000000d4948445200000096000000960800000000196a 2e3e0000000274524e5300007693cd380000023749444154789ced9cdb6ec2301 044d7fdff7f4e5f4a481a5f76ecb53d91e63c54206cf668021502ef260b219db7 8ee0e70bdf3c22d8afe5d9d96dd6a9e5dfd667d6a1856fc1d5d01abd171d34c3c a8cbc412031a4d0d0bbd620317fa951293340cc5b2c42cacc2de62b172565e614 f3148c94327389394a465b79bc9a35e3a5ccda62adaa73ac9a5e8db2b3ac5a5ef 5baf3ac1a5eb5c233a5ccaa6295d2b3ad6a5ee5daf3ad2a5ec5e22bacca5ea5ea 6bac8a5e85f2abac4a5ef9faebac0a5e5981955679af9cc15aabac574661b555c eebe9b0de2ae3f5b341c2c1239b1d613de3fa6fb1c7eae195aa771772f74a957b 6bb979bde125bf33ac7b5ca9707b07172ffe8bb83bac6b5cf469ed0feb12177b5 a0c617de3224f8b23ac332eeeb458c2fac4459d164f587f7191a645aa95ce3f34 1c469b96b41092b1bdb4cc0edab448b512df35343b58d322d54a84d7d0ec204d4 b5a08d242901682b41012e33f79dab4a485202d046921480b419fe511a485202d 046921480b415fbb21906ae90b7004522dfd4286202d04fd848e40aaa55323083 a9184a0d36e083a4989a053ba083a018ef08263fceac568f18a861ad6f623d666 2d75dcd5784ddb246b93296b4b2e6b03336bbb376b733ceb2801d6c10bac632a5 8877a341f1da37b044afbe1014606c6b08ed7611d46e45b021230bac9b9062166 d0957b958fb0b160c8ba16a143d4b09565c247cea16b734c19d087afbe336d9c6 1cffa0f53873f766e993f2a13deb66cb028b073f51856cfe63d436b0b4f1333e2 f7173c9458d5177abfd70000000049454e44ae426082 (1 row)
ところで、マニュアルと同じクエリを実行すると ↓ 自分の環境ではエラーになります。2
select st_asPNG( st_asRaster( st_buffer(st_point(1,5), 10), 150, 150,'2BUI' ) -- '2BUI' is not available ); ERROR: The pixel type of band 1 in the raster is not 8BUI or 16BUI. The PNG format can only be used with 8BUI and 16BUI pixel types.
先ほど書いたバイナリのダウンロード先には、PostGIS