SIGN UP MEMBER LOGIN:    
ARTICLE

How to Store Spatial Data or Shape Files into RDBMS(PostgreSQL/POSTGIS)

Posted by Venkat Rao Articles | ADO.NET in C# February 12, 2010
I this article we will see how to store spatial data or shape files into RDBMS.
Reader Level:

What is Spatial data?

Spatial data is  Also known as Spatial data or geographic information it is the data or information that identifies the geographic location of features and boundaries on Earth, such as natural or constructed features, oceans, and more. Spatial data is usually stored as coordinates and topology, and  those are representing as  Point, Line, Polygon and Raster. Spatial data is often accessed, manipulated or analyzed using Technology called GIS(Geographic Information Systems )

Where Spatial data will store?

The Spatial data is commonly storing in different file formats,that we call as "Geo-database".

What is Shape file?

The shape file is coined by ESRI(Environmental System Research Institute).The shape file stores individual data type(Polygon or line or Point).The shape file is combination of different files (that is from 4 to 5 files combination)
  1. .shp
  2. .shx
  3. .dbf
  4. .xml
  5. .prj
Why Spatial data should store in RDBMS?

The shape files are combination of files,if one file is missed ,the shape file will not work. Those are  just  static files , these files suppose to store in local disc, single user access and the file sometimes can be corrupted or misplaced. So that the data will be lost. The data should store in the database.

How to store shape file into database(RDBMS) ?

There are different steps involved ... that is 
  1. Install PostrgreSQL (Open source) 

    Referred url are 
    http://pginstaller.projects.postgresql.org/
    or
    http://askoh.net/misc/visualworks/installPostgreSQL/

  2. Install PostGIS 
    http://www.gpsfiledepot.com/tutorials/installing-and-setting-up-postgresql-with-postgis/

  3. Set Environment variables for shp2pgsql.exe

    MyComputer --> Properties --> Advanced --> select Environment Variables 

    1.gif

    Set Path variable as above screen.
Convert Shape file to PostgreSQL/POSTGIS :-

2.gif

Run Sql Converted SQL file

3.gif
  
Run the above  Query 

Result of the converted table below screen  :- 

4.gif

We can see the geometry column added in the table in above screen.

Login to add your contents and source code to this article
share this article :
post comment
 

Good article. 

Last year I had a need to do this through a web application  and came across some pretty unique issues. Here's how I solved them
http://codemagician.wordpress.com/2010/04/24/importing-shapefile-into-postgresql-aspnet

Posted by vadmal Apr 25, 2010
Team Foundation Server Hosting
Become a Sponsor
PREMIUM SPONSORS
  • Get 2 Months Free of ASP.NET Hosting for Only $4.95/month! Receive FREE MS SQL and MySQL Databases Including ASP.NET 4/3.5, MVC 3.0, Silverlight 4, Windows 2008/IIS 7.0 Plus FREE IIS 7 Modules. Host UNLIMITED ASP.NET Web Sites - Click Here!
    ceTE software specializes in components for dynamic PDF generation and manipulation. The DynamicPDF™ product line allows you to dynamically generate PDF documents, merge PDF documents and new content to existing PDF documents from within your applications. Visit DynamicPDF here
Become a Sponsor