Just a quick overview of how to build & install the great raster features of PostGIS 2.0 svn. I am aiming at using this data type in my current work of dem interpolation & raster derivatives based on Victorial Island in Canada’s Arctic.
As always please let me know what you think.
Build targets Fedora 16 & Postgresql 9.1 on a 32 bit machine. I am running this as a virtual machine using Virtualbox. I am using a virtual machine for the features it offers of cloning & snap shoting.
Assumptions:
- localhost connection desired for database work
- fresh install Fedora 16 with no spatial packages installed
We will be using YUM to supply all spatial components. This might not be ideal for the latest packages but will serve to build a functional postgis 2.0 with Raster support.
- Open terminal & su root
- install spatial components
- QGIS will install many of the spatial dependencies & will be used to review rasters from postgis2.0
- yum install qgis.i686 qgis-python.i686 qgis-devel.i686
- yum install proj-devel.i686 geos-devel.i686 gdal-devel.i686 libxml2.i686 libxml2-devel.i686 dblatex.noarch ImageMagick.i686 ImageMagick-devel.i686
- QGIS will install many of the spatial dependencies & will be used to review rasters from postgis2.0
- install postgresql database
- yum install postgresql.i686 postgresql-server.i686 postgresql-libs.i686 postgresql-contrib.i686 postgresql-devel.i686 pgadmin3
- setup database
- postgresql-setup initdb
- start postgresql
- service postgresql start
- enable service to start when machine starts
- systemctl enable postgresql.service
- su postgres -c psql
- ALTER USER postgres WITH PASSWORD ‘your password for postgres‘;
- \q
- edit pg_hba.conf file for localhost connections
- leafpad /var/lib/pgsql/data/pg_hba.conf
- change “method” column values to “md5” & save
- service postgresql restart
- leafpad /var/lib/pgsql/data/pg_hba.conf
- open pgAdmin 3
- File – Add Server
- name = test
- host = localhost
- username = postgres
- password = what was set in step 7.1
- Right click Login Roles – New Login Role ( create another user to connect to database)
- Properties Tab: role name = enter a name
- Definition Tab: password = enter password
- Role Privileges Tab: click Superuser
- File – Add Server
- create database to install postgis onto. (-U = user to connect to database. Use name from step 9.2)
- createdb -U richard test_postgis
- cd into directory to download PostGIS2.0svn in & extract
- wget http://postgis.refractions.net/download/postgis-2.0.0SVN.tar.gz
- tar -zxvf downloaded file from above
- cd into extracted directory
- ./configure –with-raster
- check for warnings with ./configure –with-raster | grep -i warnings
- install any dependencies that are required. Often the development packages are required.
- Make
- ensure this is output at end “PostGIS was built successfully. Ready to install.”
- make install
- enable postgis onto created database from step 10
- psql -d test_postgis -U richard -f /usr/share/pgsql/contrib/postgis-2.0/postgis.sql
- psql -d test_postgis -U richard -f /usr/share/pgsql/contrib/postgis-2.0/spatial_ref_sys.sql
- psql -d test_postgis -U richard -f /usr/share/pgsql/contrib/postgis-2.0/rtpostgis.sql
The spatial database has been created with the PostGIS 2.0svn Raster support. Please refer to the following documentation on the functions present for the raster type:
- PostGIS
- PostGIS 2.0svn manual
- PostGIS Wiki – lots of great material
In a follow up article I will be talking about loading raster data into the postgis database using the GDAL toolkit.