How to configure POSTGIS?

Posted on 2008-10-07
Last Modified: 2013-11-05
I want to use POSTGIS database to use the GEOMETRY data type column.

I installed PostGre database, Installed PostGis database.

I want to know how to configure PostGis database, help is provided but I did not understand from it.

Thanks in advance.

Question by:dashish
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
LVL 10

Expert Comment

ID: 22663284
What do you mean by configure?

Postgis installation provides you a set of functions and types you can use to store spatial data. There is no configuration necessary. All you need to do is use the functions and types to process and store your data.

So once you have a spatially enabled database (aka database that contains all the objects added by postgis), which you can create by using postgis template database, you can create tables as shown below.

As you can see I have a geometry column (geom_col) and several check constraints that ensure correct geometry is stored. These check constraints use some of the postgis functions (ndims, geometrytype, srid).

CREATE TABLE spatial_test
  id integer,
  geom_col geometry,
  CONSTRAINT enforce_dims_geom_col CHECK (ndims(geom_col)=2),
  CONSTRAINT enforce_geotype_geom_col CHECK (geometrytype(geom_col)='POINT'::text OR geom_col IS NULL),
  CONSTRAINT enforce_srid_geom_col CHECK (srid(geom_col)=26918)

Open in new window


Author Comment

ID: 22666389
I run this table script on PostGre window it gives me following error.

ERROR:  type "geometry" does not exist
LINE 4:   geom_col geometry,

LVL 10

Expert Comment

ID: 22669113
Ok, so that means that the database you are trying to create the table in is not spatially enabled.

Make sure the database is either created from the postgis template, or alternatively you could run the following scripts to generate all necessary functions and types:

If the database is spatially enabled, you should see spatial_ref_sys and geometry_columns tables in your public schema. You should also have a few hundred functions having to do with geometries.

Author Comment

ID: 22686504
I have installed PostGre on linux machine, and working on the same machine

Now could you please advice me how to make the database spatiall enabled.

I tried to run this
It gives me error "Could not save history to file "hare": Permission denied"

LVL 10

Accepted Solution

ivanovn earned 125 total points
ID: 22686797
Sounds like you don't have a permission for all the files in postgresql installation. Did you ensure you follow all the instructions at:

You may want to try just creating a spatially enabled database out of the template. As per above link, you could just execute the following and see if it works:

CREATE DATABASE my_spatial_db TEMPLATE=template_postgis

Featured Post

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Best database to use for Maps is PostgreSQL. This is an open source database. Comes as a package with most Linux OS. For more info visit the following site: ( This requires some add-o…
Many developers have database experience, but are new to PostgreSQL. It has some truly inspiring capabilities. I have several years' experience with Microsoft's SQL Server. When I began working with MySQL, I wanted a quick-reference to MySQL (htt…
Steps to create a PostgreSQL RDS instance in the Amazon cloud. We will cover some of the default settings and show how to connect to the instance once it is up and running.
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…

626 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question