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