PostgreSQL: stores SHP in the database and performs projection conversion.

Source: Internet
Author: User

1. First, convert the SHP file into an SQL statement: (indicating the original projection of data)

Shp2pgsql-w gbk-s 4610-G _ GEO sample. SHP tb_sample> sample. SQL

2. Execute the SQL file generated in the previous step and import the data to the database:

Psql-D dbname-F sample. SQL-u Postgres

3. perform projection conversion:

-- Select * From geometry_columns; -- view the projection information recorded in the geometry_columns table.
Alter table tb_sample add column _ geo1 geometry; -- add a field to store the projected information.
Update tb_sample SET _ geo1 = st_transform (_ GEO, 900913); -- perform projection conversion and set the 4610 (original projection) of the input data to 90013 (target projection)
Update geometry_columns set SRID = 900913 where f_table_name = 'tb _ sample \ '; -- Update information in the system table
Alter table tb_sample drop column _ GEO; -- delete the original field
Alter table tb_sample rename _ geo1 to _ GEO; -- update the field name

Since then, projection has been completed, done ....

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.