PostGIS has many packaged installations, but if you are more adventurous and want to compile your own, refer to our source download and compilation instructions:
Binary distributions of PostGIS are available for various operating systems.
rpm -e postgresql-server.
yum install postgis2.
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; -- Enable Topology CREATE EXTENSION postgis_topology; -- fuzzy matching needed for Tiger CREATE EXTENSION fuzzystrmatch; -- Enable US Tiger Geocoder CREATE EXTENSION postgis_tiger_geocoder;
See the documentation for more guidance.
-- Create table with spatial column CREATE TABLE mytable ( id SERIAL PRIMARY KEY, geom GEOMETRY(Point, 26910), name VARCHAR(128) ); -- Add a spatial index CREATE INDEX mytable_gix ON mytable USING GIST (geom); -- Add a point INSERT INTO mytable (geom) VALUES ( ST_GeomFromText('POINT(0 0)', 26910) ); -- Query for nearby points SELECT id, name FROM mytable WHERE ST_DWithin( geom, ST_GeomFromText('POINT(0 0)', 26910), 1000 );