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

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, which we call "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 a 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 a 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 a 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 the database(RDBMS)?

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


  2. Install PostGIS 

  3. Set Environment variables for shp2pgsql.exe
    MyComputer --> Properties --> Advanced --> select Environment Variables 
    Set Path variable as an above screen.

Convert Shape file to PostgreSQL/POSTGIS


Run SQL Converted SQL file

Run the above  Query 
Result of the converted table below screen:- 
We can see the geometry column added in the table on the above screen.