Skip to main content
replaced http://gis.stackexchange.com/ with https://gis.stackexchange.com/
Source Link

There are multiple answers on this site dealing with the installation of PostGIS. Here's oneHere's one, and Nick Gauthier's solution is also excellent. To reiterate the ample advice therein...

Installation of PostGIS has gotten a lot easier in Ubuntu 12.04 and later. There are generally two ways to go about it: installation from a PPA and building from source. What follows are general shell scripts I use for each case.

Installing from a PPA... I use the ubuntugis-unstable PPA.

# Add Ubuntu GIS PPA and update, upgrade
sudo add-apt-repository ppa:ubuntugis/ubuntugis-unstable -y && sudo apt-get update && sudo apt-get upgrade

# Install PostGIS
sudo apt-get install postgis

# Recommends: sudo apt-get install postgresql-9.1-postgis-2.0

# Configure template database
POSTGIS_TEMPLATE=postgis-2.0.1
POSTGRESQL_VER=9.1
sudo su -c "createdb $POSTGIS_TEMPLATE" - postgres 
sudo -u postgres psql -d postgres -c "UPDATE pg_database SET datistemplate='true' WHERE datname='$POSTGIS_TEMPLATE';" 
sudo -u postgres psql -d $POSTGIS_TEMPLATE -f /usr/share/postgresql/$POSTGRESQL_VER/contrib/postgis-2.0/postgis.sql
sudo -u postgres psql -d $POSTGIS_TEMPLATE -c "GRANT ALL ON geometry_columns TO PUBLIC;"
sudo -u postgres psql -d $POSTGIS_TEMPLATE -c "GRANT SELECT ON spatial_ref_sys TO PUBLIC;"

Building from source... This assumes PostGIS 2.1 and PostgreSQL 9.1 but could be any recent version of both; change as necessary.

cd /usr/local/ && sudo mkdir postgis && sudo chown [username] postgis && cd postgis
wget http://download.osgeo.org/postgis/source/postgis-2.1.0.tar.gz
tar -xzvf postgis-2.1.0.tar.gz && rm postgis-2.1.0.tar.gz && cd postgis-2.1.0
sudo ./configure --with-projdir=/usr/local/proj/v4.7.0/
make
sudo make install

# Configure template database
POSTGIS_TEMPLATE=postgis-2.1.0
POSTGRESQL_VER=9.1
sudo su -c "createdb $POSTGIS_TEMPLATE" - postgres 
sudo -u postgres psql -d postgres -c "UPDATE pg_database SET datistemplate='true' WHERE datname='$POSTGIS_TEMPLATE';" 
sudo -u postgres psql -d $POSTGIS_TEMPLATE -f /usr/share/postgresql/$POSTGRESQL_VER/contrib/postgis-2.0/postgis.sql
sudo -u postgres psql -d $POSTGIS_TEMPLATE -c "GRANT ALL ON geometry_columns TO PUBLIC;"
sudo -u postgres psql -d $POSTGIS_TEMPLATE -c "GRANT SELECT ON spatial_ref_sys TO PUBLIC;"

You'll notice a theme between the two; it is still necessary to create a template database and populate the spatial_ref_sys table.

As for getting set up with TIGER, follow the instructions for loading TIGER data in the PostGIS 2.x documentation, Chapter 2.

There are multiple answers on this site dealing with the installation of PostGIS. Here's one, and Nick Gauthier's solution is also excellent. To reiterate the ample advice therein...

Installation of PostGIS has gotten a lot easier in Ubuntu 12.04 and later. There are generally two ways to go about it: installation from a PPA and building from source. What follows are general shell scripts I use for each case.

Installing from a PPA... I use the ubuntugis-unstable PPA.

# Add Ubuntu GIS PPA and update, upgrade
sudo add-apt-repository ppa:ubuntugis/ubuntugis-unstable -y && sudo apt-get update && sudo apt-get upgrade

# Install PostGIS
sudo apt-get install postgis

# Recommends: sudo apt-get install postgresql-9.1-postgis-2.0

# Configure template database
POSTGIS_TEMPLATE=postgis-2.0.1
POSTGRESQL_VER=9.1
sudo su -c "createdb $POSTGIS_TEMPLATE" - postgres 
sudo -u postgres psql -d postgres -c "UPDATE pg_database SET datistemplate='true' WHERE datname='$POSTGIS_TEMPLATE';" 
sudo -u postgres psql -d $POSTGIS_TEMPLATE -f /usr/share/postgresql/$POSTGRESQL_VER/contrib/postgis-2.0/postgis.sql
sudo -u postgres psql -d $POSTGIS_TEMPLATE -c "GRANT ALL ON geometry_columns TO PUBLIC;"
sudo -u postgres psql -d $POSTGIS_TEMPLATE -c "GRANT SELECT ON spatial_ref_sys TO PUBLIC;"

Building from source... This assumes PostGIS 2.1 and PostgreSQL 9.1 but could be any recent version of both; change as necessary.

cd /usr/local/ && sudo mkdir postgis && sudo chown [username] postgis && cd postgis
wget http://download.osgeo.org/postgis/source/postgis-2.1.0.tar.gz
tar -xzvf postgis-2.1.0.tar.gz && rm postgis-2.1.0.tar.gz && cd postgis-2.1.0
sudo ./configure --with-projdir=/usr/local/proj/v4.7.0/
make
sudo make install

# Configure template database
POSTGIS_TEMPLATE=postgis-2.1.0
POSTGRESQL_VER=9.1
sudo su -c "createdb $POSTGIS_TEMPLATE" - postgres 
sudo -u postgres psql -d postgres -c "UPDATE pg_database SET datistemplate='true' WHERE datname='$POSTGIS_TEMPLATE';" 
sudo -u postgres psql -d $POSTGIS_TEMPLATE -f /usr/share/postgresql/$POSTGRESQL_VER/contrib/postgis-2.0/postgis.sql
sudo -u postgres psql -d $POSTGIS_TEMPLATE -c "GRANT ALL ON geometry_columns TO PUBLIC;"
sudo -u postgres psql -d $POSTGIS_TEMPLATE -c "GRANT SELECT ON spatial_ref_sys TO PUBLIC;"

You'll notice a theme between the two; it is still necessary to create a template database and populate the spatial_ref_sys table.

As for getting set up with TIGER, follow the instructions for loading TIGER data in the PostGIS 2.x documentation, Chapter 2.

There are multiple answers on this site dealing with the installation of PostGIS. Here's one, and Nick Gauthier's solution is also excellent. To reiterate the ample advice therein...

Installation of PostGIS has gotten a lot easier in Ubuntu 12.04 and later. There are generally two ways to go about it: installation from a PPA and building from source. What follows are general shell scripts I use for each case.

Installing from a PPA... I use the ubuntugis-unstable PPA.

# Add Ubuntu GIS PPA and update, upgrade
sudo add-apt-repository ppa:ubuntugis/ubuntugis-unstable -y && sudo apt-get update && sudo apt-get upgrade

# Install PostGIS
sudo apt-get install postgis

# Recommends: sudo apt-get install postgresql-9.1-postgis-2.0

# Configure template database
POSTGIS_TEMPLATE=postgis-2.0.1
POSTGRESQL_VER=9.1
sudo su -c "createdb $POSTGIS_TEMPLATE" - postgres 
sudo -u postgres psql -d postgres -c "UPDATE pg_database SET datistemplate='true' WHERE datname='$POSTGIS_TEMPLATE';" 
sudo -u postgres psql -d $POSTGIS_TEMPLATE -f /usr/share/postgresql/$POSTGRESQL_VER/contrib/postgis-2.0/postgis.sql
sudo -u postgres psql -d $POSTGIS_TEMPLATE -c "GRANT ALL ON geometry_columns TO PUBLIC;"
sudo -u postgres psql -d $POSTGIS_TEMPLATE -c "GRANT SELECT ON spatial_ref_sys TO PUBLIC;"

Building from source... This assumes PostGIS 2.1 and PostgreSQL 9.1 but could be any recent version of both; change as necessary.

cd /usr/local/ && sudo mkdir postgis && sudo chown [username] postgis && cd postgis
wget http://download.osgeo.org/postgis/source/postgis-2.1.0.tar.gz
tar -xzvf postgis-2.1.0.tar.gz && rm postgis-2.1.0.tar.gz && cd postgis-2.1.0
sudo ./configure --with-projdir=/usr/local/proj/v4.7.0/
make
sudo make install

# Configure template database
POSTGIS_TEMPLATE=postgis-2.1.0
POSTGRESQL_VER=9.1
sudo su -c "createdb $POSTGIS_TEMPLATE" - postgres 
sudo -u postgres psql -d postgres -c "UPDATE pg_database SET datistemplate='true' WHERE datname='$POSTGIS_TEMPLATE';" 
sudo -u postgres psql -d $POSTGIS_TEMPLATE -f /usr/share/postgresql/$POSTGRESQL_VER/contrib/postgis-2.0/postgis.sql
sudo -u postgres psql -d $POSTGIS_TEMPLATE -c "GRANT ALL ON geometry_columns TO PUBLIC;"
sudo -u postgres psql -d $POSTGIS_TEMPLATE -c "GRANT SELECT ON spatial_ref_sys TO PUBLIC;"

You'll notice a theme between the two; it is still necessary to create a template database and populate the spatial_ref_sys table.

As for getting set up with TIGER, follow the instructions for loading TIGER data in the PostGIS 2.x documentation, Chapter 2.

Source Link
Arthur
  • 2.3k
  • 1
  • 18
  • 28

There are multiple answers on this site dealing with the installation of PostGIS. Here's one, and Nick Gauthier's solution is also excellent. To reiterate the ample advice therein...

Installation of PostGIS has gotten a lot easier in Ubuntu 12.04 and later. There are generally two ways to go about it: installation from a PPA and building from source. What follows are general shell scripts I use for each case.

Installing from a PPA... I use the ubuntugis-unstable PPA.

# Add Ubuntu GIS PPA and update, upgrade
sudo add-apt-repository ppa:ubuntugis/ubuntugis-unstable -y && sudo apt-get update && sudo apt-get upgrade

# Install PostGIS
sudo apt-get install postgis

# Recommends: sudo apt-get install postgresql-9.1-postgis-2.0

# Configure template database
POSTGIS_TEMPLATE=postgis-2.0.1
POSTGRESQL_VER=9.1
sudo su -c "createdb $POSTGIS_TEMPLATE" - postgres 
sudo -u postgres psql -d postgres -c "UPDATE pg_database SET datistemplate='true' WHERE datname='$POSTGIS_TEMPLATE';" 
sudo -u postgres psql -d $POSTGIS_TEMPLATE -f /usr/share/postgresql/$POSTGRESQL_VER/contrib/postgis-2.0/postgis.sql
sudo -u postgres psql -d $POSTGIS_TEMPLATE -c "GRANT ALL ON geometry_columns TO PUBLIC;"
sudo -u postgres psql -d $POSTGIS_TEMPLATE -c "GRANT SELECT ON spatial_ref_sys TO PUBLIC;"

Building from source... This assumes PostGIS 2.1 and PostgreSQL 9.1 but could be any recent version of both; change as necessary.

cd /usr/local/ && sudo mkdir postgis && sudo chown [username] postgis && cd postgis
wget http://download.osgeo.org/postgis/source/postgis-2.1.0.tar.gz
tar -xzvf postgis-2.1.0.tar.gz && rm postgis-2.1.0.tar.gz && cd postgis-2.1.0
sudo ./configure --with-projdir=/usr/local/proj/v4.7.0/
make
sudo make install

# Configure template database
POSTGIS_TEMPLATE=postgis-2.1.0
POSTGRESQL_VER=9.1
sudo su -c "createdb $POSTGIS_TEMPLATE" - postgres 
sudo -u postgres psql -d postgres -c "UPDATE pg_database SET datistemplate='true' WHERE datname='$POSTGIS_TEMPLATE';" 
sudo -u postgres psql -d $POSTGIS_TEMPLATE -f /usr/share/postgresql/$POSTGRESQL_VER/contrib/postgis-2.0/postgis.sql
sudo -u postgres psql -d $POSTGIS_TEMPLATE -c "GRANT ALL ON geometry_columns TO PUBLIC;"
sudo -u postgres psql -d $POSTGIS_TEMPLATE -c "GRANT SELECT ON spatial_ref_sys TO PUBLIC;"

You'll notice a theme between the two; it is still necessary to create a template database and populate the spatial_ref_sys table.

As for getting set up with TIGER, follow the instructions for loading TIGER data in the PostGIS 2.x documentation, Chapter 2.