PostGIS导入shapefile


1. 创建数据库

a . 在pgAdmin中创建空间数据库,使用模板创建


使用模板创建数据库

b. 在sql sell中使用命令创建


CTEATE DATABASE MY_DB_NAEM; //创建数据库
\c MY_DB_NAEM; //连接之前创建的数据库
CREATE EXTENSION postgis;  //Enable PostGIS (includes raster)
CREATE EXTENSION pgrouting;  //
CREATE EXTENSION postgis_topology; //Enable Topology 
CREATE EXTENSION fuzzystrmatch;  //fuzzy matching needed for Tiger
CREATE EXTENSION postgis_tiger_geocoder; 
CREATE EXTENSION address_standardizer;

'Sql Shell;
对比之前建立的数据库,可以发现多了多了几个扩展和架构
在这里插入图片描述

2. 导入数据

** 工具:PostGIS 2.0 Shapefile and DBF Loader Exporter**

1. 连接数据库

username:数据库用户名,默认的是postgres
password:安装的时候设置的密码
Server host:服务地址,默认即可
Database:要导入的数据库
连接成功:Connecting:  host=localhost port=5432 user=postgres password='*************' 		dbname=db client_encoding=UTF8   Connection succeeded.

在这里插入图片描述

2. 选项Option

  • DBF file character encoding: dbf文件的字符编码方式,默认UTF-8
  • Preserve case of column names: 保持列名大小写
  • Do not create ‘bigint’ columns: 不要创建 bigint 类型(int占用4个字节bigint占用8个字节)
  • Create spatial index automatically after load:加载后自动创建空间索引
  • Load only using COPY rather than INSERT:通过复制而不是插入的方式加载数据
  • load into GEOGRAPHY column:加载到GEOGRAPHY列
  • Generate simple geometries instead of MULTI geomries:生成简单几何代替MULTI几何
  • 使用默认选项即可: 路劲中不要中文,路径不要太长
    在这里插入图片描述在这里插入图片描述

    • Schema:导入那个模式
    • Table:导入的表名
    • Geo_Column:空间信息的列名
    • SRID:空间参考信息,需要在spatial_ref_sys(该表记录着postGIS提供的空间参考信息)表中查看对应的值

3. 数据库中查看

在这里插入图片描述

转载自:https://blog.csdn.net/weixin_43980677/article/details/85037110

You may also like...