pg_ctl -D D:\ProgramFile\postgresql\15\data start 其中-D后面的路径是postgresql的安装路径下的data文件夹;
-- Enable PostGIS (as of 3.0 contains just geometry/geography) CREATE EXTENSION postgis; -- enable raster support (for 3+) CREATE EXTENSION postgis_raster; -- 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;
如果想可视化postGIS中的数据,可以使用QGIS查看,QGIS下载地址。
提供一下这里的数据表:
-- 三维点数据 CREATE TABLE points ( id SERIAL PRIMARY KEY, name TEXT, location geometry(PointZ, 4326) ); INSERT INTO points (name, location) VALUES ('point1', ST_GeomFromText('POINTZ(0 0 1)', 4326)); INSERT INTO points (name, location) VALUES ('point2', ST_GeomFromText('POINTZ(1 1 2)', 4326)); -- 三维线数据 CREATE TABLE lines ( id SERIAL PRIMARY KEY, name TEXT, geom geometry(MultiLineStringZ, 4326) ); INSERT INTO lines (name, geom) VALUES ('line1', ST_GeomFromText('MULTILINESTRINGZ((0 0 0, 0 1 0, 1 1 0), (2 2 1, 3 3 2))', 4326)); INSERT INTO lines (name, geom) VALUES ('line2', ST_GeomFromText('MULTILINESTRINGZ((0 0 0, 0 1 1, 1 1 1))', 4326)); -- 三维面数据 CREATE TABLE polygons ( id SERIAL PRIMARY KEY, name TEXT, geom geometry(PolygonZ, 4326) ); INSERT INTO polygons (name, geom) VALUES ('polygon1', ST_GeomFromText('POLYGON Z((0 0 0, 0 1 0, 1 1 0, 0 0 0))', 4326)); INSERT INTO polygons (name, geom) VALUES ('polygon2', ST_GeomFromText('POLYGON Z((0 0 0, 0 1 1, 1 1 1, 0 0 0))', 4326));