Filed under: Postgis | Tags: esri shape to postgis, import shape file in database, import shape file in postgis, postgis shape file
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.
Khayer
GIS Programmer, CEGIS
Bangladesh
khayer.wordpress.com
5 Comments so far
Leave a comment
Hello,
Comment by Pradnya Nandre January 29, 2010 @ 9:59 amI 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??
@Pradnya Nandre,
Comment by khayer February 2, 2010 @ 2:44 pmWhat is the error?
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 vinay.nic@gmail.com or 91-9818701920
Comment by vinay sharma April 1, 2010 @ 1:20 pmHere’s a way to import the data via an asp.net app:
Comment by Code Magician April 25, 2010 @ 11:17 amhttp://codemagician.wordpress.com/2010/04/24/importing-shapefile-into-postgresql-aspnet/
xJK1ze http://djb3jDdmjckow30cnjcmd61l0dy.com
Comment by samanta August 31, 2010 @ 12:28 am