wiki:UsersWikiPostgisOnUbuntu

Version 6 (modified by stelmo, 15 years ago) ( diff )

--

How To Install PostGIS on Ubuntu (draft)

Installation

From Packages (aka, the easy way):

PostGIS and Postgresql are available as packages for Ubuntu 6.10 and greater. To install, use either:

apt-get install postgresql-8.3-postgis postgis

Try to download the DEB package here:

http://trac.osgeo.org/postgis/attachment/wiki/UsersWikiPostgisOnUbuntu/postgis_1.4.1-1_i386.deb Install it by double click, first you have to install PostgreSQL.

OR

Use adept or synaptic and select packages:

postgresql-8.3-postgis

postgis

NOTE: The "Universe" repository must be enabled.

NOTE: postgresql-8.3 is current as of 1/2009. You should, of course, use the current version.

From Source (aka, the hard way):

  1. Install Postgresql, Libgeos, Proj. packages. Easiest way is to use Synaptic (be sure to include Universe in your respositories). Also be sure to install the "-dev" packages (postgresql-server-dev-8.0). Under Breezy, latest postgresql version is 8.0 (adjust following paths to reflect the version you have installed).
  1. Download postgis.tgz and place in /usr/share/postgresql/8.0/contrib
  1. Extract the via Nautilus or cd to the directory and then use tar -zvxf postgis-x.x.x
  1. Now cd to the postgis directory.
  1. Now configure. Try:
  > sudo ./configure --prefix=/usr  --with-pgconfig=/usr/bin/pg_config
    --with-geos=/usr/bin/geos-config  --with-proj=/usr

  1. Check to see that you have no errors. You may need to install other packages (like flex and byacc).
  1. Now type > sudo make
  1. type > sudo make install

That should do it.


Using PostGIS

  1. Create a database. You must be the postgres superuser to do this: = From the shell:

$ createdb mytestdb

TIP: if you get permission errors, try:

$ sudo su postgres $ createdb mytestdb

REMEMBER: type 'exit' when you're done with these postgres commands to return to your normal user.

  1. Set up the postgis libs:

$ createlang plpgsql mytestdb

2a. If you installed from packages:

$ psql -d mytestdb -f /usr/share/postgresql-8.3-postgis/lwpostgis.sql

if there were no errors (if the last line of output is COMMIT), then

$ psql -d mytestdb -f /usr/share/postgresql-8.3-postgis/spatial_ref_sys.sql

NOTE: Fedora 7 installed from package path is /usr/share/pgsql/contrib/

2b. If you installed from source:

NOTE: this looks old...

$ psql -d mytestdb -f /usr/share/postgresql/8.0/contrib/postgis-1.1.1/lwpostgis.sql

$ psql -d mytestdb -f /usr/share/postgresql/8.0/contrib/postgis-1.1.1/spatial_ref_sys.sql

  1. Make sure that your DB user has GRANT ALL on the "geometry_columns" table and GRANT SELECT on "spatial_ref_sys".

Now import a shp file:

$ shp2pgsql -D myshape.shp mytable mytestdb | psql mytestdb

This will take the input file "myshape.shp" and create a new table, "mytable" in the database "mytestdb."

To see if your shape file is there:

$ psql mytestdb mytestdb=# SELECT * from mytable;

Attachments (1)

Download all attachments as: .zip

Note: See TracWiki for help on using the wiki.