Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1664
  • Last Modified:

How to configure POSTGIS?

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.

Thanks,
dAshish
0
dashish
Asked:
dashish
  • 3
  • 2
1 Solution
 
ivanovnCommented:
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

0
 
dashishAuthor Commented:
I run this table script on PostGre window it gives me following error.

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

Thanks
dAshish
0
 
ivanovnCommented:
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:
<PGHOME>\share\contrib\lwpostgis.sql
<PGHOME>\share\contrib\spatial_ref_sys.sql

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.
0
 
dashishAuthor Commented:
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
<PGHOME>\share\contrib\lwpostgis.sql
<PGHOME>\share\contrib\spatial_ref_sys.sql
It gives me error "Could not save history to file "hare": Permission denied"

Thanks,
dAshish
0
 
ivanovnCommented:
Sounds like you don't have a permission for all the files in postgresql installation. Did you ensure you follow all the instructions at: http://postgis.refractions.net/documentation/manual-1.3/ch02.html

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
0

Featured Post

Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now