Databases 4 min read

How to Create a PostGIS Spatial Database and Import Shapefile Data

After installing PostgreSQL on Windows, this guide shows how to add the PostGIS extension via pgAdmin, create a new spatial database, verify the installation, and then use the PostGIS Shapefile and DBF Loader Exporter to import a shapefile (with accompanying DBF), handling encoding and path issues, and finally view the imported data.

The Dominant Programmer
The Dominant Programmer
The Dominant Programmer
How to Create a PostGIS Spatial Database and Import Shapefile Data

After installing PostgreSQL on Windows (see the linked tutorial), you can optionally install the PostGIS extension to enable spatial features.

Creating a spatial database

Open pgAdmin, connect with your password, then navigate to Databases → New → Database . Name the database (e.g., demo) and open the Query Tool on that database.

Run the following command to enable PostGIS: CREATE EXTENSION postgis; Click the run button (the triangle icon). After execution, the extension appears in the list. Verify the installation with: SELECT postgis_full_version(); The result confirms that PostGIS is active.

Importing shapefile data

Install the "PostGIS Shapefile and DBF Loader Exporter" tool. You need a .shp file and its accompanying .dbf file; a sample Chinese provincial map is provided in the article.

Ensure that the shapefile name and its directory path contain no Chinese characters.

Launch the loader, click View connection details , and enter the PostgreSQL username, password, host IP, port, and the target database.

After a successful connection, go to Options → Import Options and set the encoding to GBK to handle Chinese characters correctly.

Click the Import button, select the .shp file (and ensure the matching .dbf file is present), then start the import. A success message appears when the operation completes.

To view the imported data, expand the public schema in pgAdmin, locate the new tables, right‑click → View/Edit Data → First 100 rows . The spatial attributes and attribute columns from the shapefile are displayed.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

PostgreSQLPostGISpgAdminGIS importspatial database
The Dominant Programmer
Written by

The Dominant Programmer

Resources and tutorials for programmers' advanced learning journey. Advanced tracks in Java, Python, and C#. Blog: https://blog.csdn.net/badao_liumang_qizhi

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.