Wednesday, July 8, 2015

PostGIS Installation

PostGIS is free software that adds support for geographic objects to PostgreSQL. I am going to need a PostGIS database for the Photovoltaic Viability Map server, so today I'll start learning PostgreSQL server administration.

My first step, as I've been doing repeatedly for the wide range of technologies I'm learning this Summer, is to setup a VirtualBox VM.  I've already documented that process in a previous post, so here I'll only note that I added PostgreSQL database in the Software selection screen during installation:
 Once I connected to the new VM from a terminal window using ssh, I checked to see what debian packages are in the standard Ubuntu repositories for PostGIS:
$ apt-cache search postgis
imposm - importer for OpenStreetMap data
liblwgeom-2.1.2 - PostGIS "Lightweight Geometry" library
liblwgeom-dev - PostGIS "Lightweight Geometry" library - Development files
libpostgis-java - Geographic objects support for PostgreSQL -- JDBC support
mapnik-vector-tile - Vector tiles integration with mapnik - development files
osm2pgsql - OpenStreetMap data to PostgreSQL converter
postgis - Geographic objects support for PostgreSQL
postgis-doc - Geographic objects support for PostgreSQL -- documentation
postgresql-9.3-postgis-2.1 - Geographic objects support for PostgreSQL 9.3
postgresql-9.3-postgis-2.1-scripts - PostGIS for PostgreSQL 9.3 -- scripts -- dummy package
postgresql-9.3-postgis-scripts - Geographic objects support for PostgreSQL 9.3 -- scripts
python-imposm - importer for OpenStreetMap data - Python module
qgis - Geographic Information System (GIS)
$
I looks like there is a package, postgis, that might have what I need.  Let me see:
$ apt-cache show postgis
Package: postgis
Priority: optional
Section: universe/misc
Installed-Size: 886
Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com>
Original-Maintainer: Debian GIS Project <pkg-grass-devel@lists.alioth.debian.org>
Architecture: amd64
Version: 2.1.2+dfsg-2ubuntu0.1
Depends: libc6 (>= 2.14), libgdal1h (>= 1.9.0), libgeos-c1 (>= 3.4.2), libglib2.0-0 (>= 2.12.0), libgtk2.0-0 (>= 2.14.0), liblwgeom-2.1.2 (>= 2.0.0), libpq5
Suggests: postgresql-9.3-postgis-2.1, postgis-doc
Filename: pool/universe/p/postgis/postgis_2.1.2+dfsg-2ubuntu0.1_amd64.deb
Size: 156234
MD5sum: 0cb613a28ff7c0cc3534ed38d5e4a5ff
SHA1: bd38017300d570834784c2810704d6d55a72f90c
SHA256: c7d88af4872e96628b18e24ef5966203c7fa809e41f753c1f516f9cbc9c7c68f
Description-en: Geographic objects support for PostgreSQL
 PostGIS adds support for geographic objects to the PostgreSQL
 object-relational database. In effect, PostGIS "spatially enables"
 the PostgreSQL server, allowing it to be used as a backend spatial
 database for geographic information systems (GIS), much like ESRI's
 SDE or Oracle's Spatial extension. PostGIS follows the OpenGIS
 "Simple Features Specification for SQL".
 .
 This package contains the PostGIS userland binaries, common files.
Description-md5: 71b1ab6dbb24f361235106dc71acd572
Homepage: http://postgis.refractions.net/
Bugs: https://bugs.launchpad.net/ubuntu/+filebug
Origin: Ubuntu
Looks like what I need. I'll install it:
$ sudo aptitude install postgis
[sudo] password for [username]:
The following NEW packages will be installed:
  fontconfig{a} fontconfig-config{a} fonts-dejavu-core{a}
  hicolor-icon-theme{a} libarmadillo4{a} libarpack2{a} libatk1.0-0{a}
  libatk1.0-data{a} libavahi-client3{a} libavahi-common-data{a}
  libavahi-common3{a} libblas3{a} libcairo2{a} libcups2{a} libdap11{a}
  libdapclient3{a} libdatrie1{a} libepsilon1{a} libfontconfig1{a}
  libfreexl1{a} libgdal1h{a} libgdk-pixbuf2.0-0{a}
  libgdk-pixbuf2.0-common{a} libgeos-3.4.2{a} libgeos-c1{a} libgfortran3{a}
  libgif4{a} libgraphite2-3{a} libgtk2.0-0{a} libgtk2.0-bin{a}
  libgtk2.0-common{a} libharfbuzz0b{a} libhdf4-0-alt{a} libhdf5-7{a}
  libjasper1{a} libjbig0{a} libjpeg-turbo8{a} libjpeg8{a} libkml0{a}
  liblapack3{a} liblcms2-2{a} libltdl7{a} liblwgeom-2.1.2{a}
  libmysqlclient18{a} libnetcdfc7{a} libodbc1{a} libogdi3.2{a}
  libpango-1.0-0{a} libpangocairo-1.0-0{a} libpangoft2-1.0-0{a}
  libpixman-1-0{a} libpoppler44{a} libproj0{a} libquadmath0{a}
  libspatialite5{a} libthai-data{a} libthai0{a} libtiff5{a}
  liburiparser1{a} libwebp5{a} libxcb-render0{a} libxcb-shm0{a}
  libxcomposite1{a} libxcursor1{a} libxdamage1{a} libxerces-c3.1{a}
  libxfixes3{a} libxi6{a} libxinerama1{a} libxrandr2{a} libxrender1{a}
  mysql-common{a} odbcinst{a} odbcinst1debian2{a} postgis proj-bin{a}
  proj-data{a}
0 packages upgraded, 77 newly installed, 0 to remove and 0 not upgraded.
Need to get 21.0 MB of archives. After unpacking 80.6 MB will be used.
Do you want to continue? [Y/n/?] Y
Lots of dependencies, many of which appear to be for rendering fonts and graphics, but the postgresql-9.3-postgis-2.1 is not among them.  I see in the package details for postgis that it recommends postgresql-9.3-postgis-2.1, so I'll install that as well:
$ sudo aptitude install postgresql-9.3-postgis-2.1
[sudo] password for [username]:
The following NEW packages will be installed:
  postgresql-9.3-postgis-2.1 postgresql-9.3-postgis-scripts{a}
0 packages upgraded, 2 newly installed, 0 to remove and 0 not upgraded.
Need to get 729 kB of archives. After unpacking 15.6 MB will be used.
Do you want to continue? [Y/n/?] Y
I now have a PostGIS server successfully installed on a VirtualBox VM.  I'll document learning how to use it in a separate post.

No comments:

Post a Comment