Developer Notes Import a shape file into PostgreSQL using Shp2pgsql

Source: Internet
Author: User
Tags postgresql postgis

Importing SHP files into PostgreSQL

1, first, you need to make Shp2pgsql command available, Baidu Download, add environment variables can.

: https://download.osgeo.org/postgis/windows/pg96/

  

, open the URL, download the target file, extract the following directory:

Add the directory to the environment variable, and then cmd to run Shp2pgsql.

  

2. The command is as follows:

  

Shp2pgsql-s 3857-a-W GBK file name. shp namespace name. Table Name | Psql-h localhost-u postgres-d database name-P 5432

3, the import failure may occur, because the imported database to increase the space expansion feature:

Create extension postgis;create extension postgis_topology;create extension fuzzystrmatch;create extension postgis_ Tiger_geocoder;

4. Command Prompt to enter password

In order to avoid password entry in the program, we added the pgpass.conf file. This file is available under PostgreSQL's installation directory.

The contents of the file are as follows:

Copy the file to the following directory: C:\Users\ your computer name \appdata\roaming\postgresql

OK, you are done!

5. Precautions

A, table name all lowercase, PostgreSQL cannot recognize capital table name

b, file name path can not be too long, preferably do not include Chinese

C, encoding format using GBK not garbled, if garbled can try UTF-8

Developer Notes Import a shape file into PostgreSQL using Shp2pgsql

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.