Creating Database and Importing Shape file in PostGis

Postgis is the next generation database. The popularity increase rate of postgis is very sharp. I first used the postgis when it is an university project. Now it become very stable. In this article i will describe the procedure of importing ESRI Shape file into the PostGIS.

At first we need to create an database with spatial support. To do than, open pgAdmin III and login the PostGreSql. Now right click in the Database and select new database. Create a new database name testgis with postgis templete.

Then create new schema(table) named roads in public domain.

Now we import the shape file into the testgis. PostGreSql have an utility known as shp2pgsql. we need to convert shape file to spitial sql using that tools.

Follow below step to do that,
1. open command promt
2. # cd C:\Program Files\PostgreSQL\8.4\bin
3. # shp2pgsql c:\roads.shp public.roads > roads.sql

Finally import the dump to postgis database,
# psql -d testgis -U postgres -f roads.sql

Now shape file in imported. We can test the map using qgis.
GIS Programmer, CEGIS

5 thoughts on “Creating Database and Importing Shape file in PostGis

  1. Hello,
    I am trying to import the ESRI shapefiles to postgis using the shp2pgsql utilty on ubuntu 9.04.But the command to import the dump into sql format gives an error.Can anyone help me??

  2. first you have to describe your OS, if you are using MS-window then it’s very easy to take backup as well as restore. as you seeing in above article. follow these option and enjoy… then also if you are unable to do then you may contect or 91-9818701920

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s