How add shapefiles to PostGIS database from QGIS?
For adding shape files to postGIS database this simple steps should be followed-
- A. Inside Database menu go to Spit option
- B. Click on Import Shapefiles to PostgreSQL.. A popup window titled SPIT-Shapefiles to PostGIS Omport Tools will open.
- A. In SPIT window click on New for making new PostgresSQL connection.
- B. A new window titled Create a New PostGIS connection will open.
- C. Give the connection name in the Name field. Here you can type any name e.g. myconnection or MyPGconnection etc.
- D. Leave Service filed blank
- E. In Host field enter localhost
- F. Enter Port being used by Postgres default port is 5432. But it’s better to confirm the port in pgAdmin III.
- G. In Database field Give the name of Postgres database
- H. Provide username and Password used for connecting to Postgres database in PgAdmin.
- I. Click on Test Connection button to test the connection. If connection is not successful then check the values entered in the above fields (E to H). If connection is successful then click OK button.
- J. The name of new connection will appear in SPIT window in PostgresSQL connections
- A .Select the new connection name and press Conncet button.
- B .In Geometry column name give any name like geom or use default the_geom.
- C .In SRID filed provide the correct SRID of the database (e.g. 4326 etc.)
- D .In Primary key column name type gid
- E .In Global Schema field use default value
- F .Click on Add button and navigate to the target folder and select the shapefile and clock on Open button.
- G. The name of shapefile will be displayed in SPIT window under File Name. Here provide the table name (to be created in Postgres) in DB Relation Name option.
- H. The Feature Class filed should contain single part features. (Shapefiles containing Multipolygon / Multiline features should be converted into Polygon/Polyline features by using Multipart to Single Part Tool located in QGIS toolbox)
- By pressing Add button more files can be added. After adding files press OK button in SPIT window. Check the database from PgAdmin .