Compiling from Source
PostGIS has many packaged installations, but if you are more adventurous
and want to compile your own, refer to our source download and compilation
Binary distributions of PostGIS are available for various operating systems.
- More details about getting up and running with windows can be found on Windows Downloads page.
- The most reliable way to get PostGIS on OSX is to download and install Postgres.app. Great for development and testing. Do not mix with other installations.
- The builds from KingChaos are sometimes more up-to-date. Read the instructions carefully. Do not mix with other installations.
- The OSX PostgreSQL/Stackbuilder combination from EnterpriseDB has had mixed reliability. Avoid.
- Instructions for MacPorts and HomeBrew would be welcome contributions.
Red Hat / Centos / Scientific Linux
- The best place to get the latest binaries for both PostgreSQL and PostGIS is the PostgreSQL Yum repository
- Choose the correct “repository RPM” for your distribution, download and install it.
- Edit the yum configuration to exclude the base system PostgreSQL packages from yum (see the “Important note” section).
- Remove any existing PostgreSQL server packages from your system, with
rpm -e postgresql-server.
- Install PostGIS and dependencies by running
yum install postgis2.
Ubuntu / Debian
- The PostgreSQL build team is working on an APT repository for PostgreSQL builds. They may include PostGIS builds in the future.
- The DebianGIS project has built PostGIS in the past, but is currently not very up-to-date.
These instructions are for PostgreSQL 9.1 and higher, PostGIS 2.0 and higher.
PostGIS is an optional extension that must be enabled in your database before you can use it. Installing the software is just the first step.
Connect to your database with
psql or PgAdmin. Run the following SQL:
-- Enable PostGIS (includes raster)
CREATE EXTENSION postgis;
See the documentation for more guidance.
-- Create table with spatial column
CREATE TABLE mytable (
id SERIAL PRIMARY KEY,
geom GEOMETRY(Point, 26910),
-- Add a spatial index
CREATE INDEX mytable_gix
USING GIST (geom);
-- Add a point
INSERT INTO mytable (geom) VALUES (
ST_GeomFromText('POINT(0 0)', 26910)
-- Query for nearby points
SELECT id, name
ST_GeomFromText('POINT(0 0)', 26910),