Hello everyone, welcome to GIS Tutorial. Today, I am going to discuss a bit deeper about PostGIS. We will learn how to export shapefile to PostGIS. There are several ways to do this job and also there are software that capable to export gis file to PostGIS. In this article, I am going to show you the following software:
- Global Mapper
Before we can continue with the steps, I assume you already have a working PostGIS server. PostGIS is a spatial extension for
Export Shapefile to PostGIS using Global Mapper
Global Mapper is one of my favorite GIS Software for Windows. It has all capability to open almost any of GIS file formats. It can be used to translate or export shapefile to PostGIS database easily. I have used the following steps to export my spatial dataset to PostGIS.
Steps to export shapefile to PostGIS using Global Mapper
- Open Global Mapper
- Load/Open the shapefile to Global Mapper
- Go to File | Export | Export Vector Spatial Database
- Choose “Select Spatial Database Connection (ArcSDE, PostGIS)” from the list.
- Choose the PostGIS connection or create a new one if you don’t have it yet. Click Open to open the connection
- Give a name for the exported table.
- Click OK
To open the spatial table from PostGIS on other software, you can follow the tutorial below
How to open PostGIS Table on QGIS
How to Export Shapefile to PostGIS using QGIS
QGIS is a popular GIS Software. It supports PostGIS very well. You can open the PostGIS table directly from QGIS. Not only that, we can also export spatial tables to PostGIS using QGIS.
Steps to export shapefile to PostGIS using QGIS
- Open QGIS
- Double-click “Export to PostgreSQL” from the Toolbox
- Browse the layer file to export
- Choose the database connection name
- Click Run
Pretty simple isn’t it?
Export Shapefile to PostGIS using ogr2ogr tool
ogr2ogr is a command line tool that has many capabilities including export shapefile and other GIS formats to PostGIS, MySQL, SQL Server etc. ogr2ogr tool is available from FWTools. You can download it for free. Or, you can also download and install QGIS that includes ogr2ogr tool.
How to use ogr2ogr to export shapefile to PostGIS database
ogr2ogr -f "ESRI Shapefile" C:\Users\dhani\Documents\ArcGIS\Contour_TW.shp PG:"host=192.168.100.14 user=postgres dbname=gis_database password=12345" "test"
The command above will export the Contour_TW.shp file to remote PostGIS database at 192.168.100.14 and save it as table name Test.
So there are many ways to export spatial table to PostGIS database. Thank you for reading this article and I hope you enjoy it. Cheers.