赞
踩
CREATE DATABASE gisdbname;
CREATE EXTENSION postgis;
CREATE EXTENSION postgis_topology;
CREATE EXTENSION fuzzystrmatch;
CREATE EXTENSION postgis_tiger_geocoder;
CREATE EXTENSION address_standardizer;
注意:postGIS导入shp数据路径不能含有中文,如果含有中文会报错,而且自己要知道自己的数据的坐标系
弹出如下图:
create extension postgis
insert into test(id,shape) values(1,point(12.32232442,43.2324535)::geometry);
insert into test(id,shape) values(1,point(12.32232442,43.2324535)::geometry);
-- Enable PostGIS (includes raster) CREATE EXTENSION postgis; -- Enable Topology CREATE EXTENSION postgis_topology; -- Enable PostGIS Advanced 3D -- and other geoprocessing algorithms -- sfcgal not available with all distributions CREATE EXTENSION postgis_sfcgal; -- fuzzy matching needed for Tiger CREATE EXTENSION fuzzystrmatch; -- rule based standardizer CREATE EXTENSION address_standardizer; -- example rule data set CREATE EXTENSION address_standardizer_data_us; -- Enable US Tiger Geocoder CREATE EXTENSION postgis_tiger_geocoder;
--添加空间字段 SELECT AddGeometryColumn ('GIS', '四至', 4326, 'POLYGON', 2); --根据其他字段更新空间字段数据 update "GIS" b set "四至"=ST_GeomFromText ('POLYGON((' || to_char(a."东经起",'999.9999') || to_char(a."北纬起",'999.9999') || ',' || to_char(a."东经止",'999.9999') || to_char(a."北纬起",'999.9999') || ',' || to_char(a."东经止",'999.9999') || to_char(a."北纬止",'999.9999') ||',' || to_char(a."东经起",'999.9999') || to_char(a."北纬止",'999.9999') || ',' || to_char(a."东经起",'999.9999') || to_char(a."北纬起",'999.9999') || '))',4326) from "GIS" a where b."ID"=a."ID" --创建索引 CREATE INDEX shape_index_sz1 ON "GIS" USING gist (四至); --查询与指定范围相交的多边形 SELECT * FROM "GIS" where ST_Intersects( ST_GeomFromText('POLYGON((86 44.1667,87.3333 44.1667,87.3333 45.1667,86 45.1667,86 44.1667))'), ST_GeomFromText(ST_AsText("四至")))
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。