PostGIS介绍

 一、相关缩写

OGC—— Open Geospatial Consortium(开放地理空间联盟),负责制订GIS领域的标准

二、PostGIS的扩展
PostGIS是利用Postgresql的扩展机制,在Postgresql的基础上增加了表达地理信息的空间数据类型和操作这些类型的函数。

三、PostGIS支持的数据类型
1、OpenGIS Consortium (OGC)定义了两种标准方式来表达空间对象,分别是WKT( Well-Known Text)和WKB(Well-Known Binary)。WKT其实等价于编程语言中的类型的字面量,而WKB是空间对象在数据库中的存储格式。常用数据类型如下:
•  POINT(0 0)
•  LINESTRING(0 0,1 1,1 2)
•  POLYGON((0 0,4 0,4 4,0 4,0 0),(1 1, 2 1, 2 2, 1 2,1 1))
•  MULTIPOINT(0 0,1 2)
•  MULTILINESTRING((0 0,1 1,1 2),(2 3,3 2,5 4))
•  MULTIPOLYGON(((0 0,4 0,4 4,0 4,0 0),(1 1,2 1,2 2,1 2,1 1)), ((-1 -1,-1 -2,-2 -2,-2 -1,-1 -1)))
•  GEOMETRYCOLLECTION(POINT(2 3),LINESTRING(2 3,3 4))
2、OGC定义的空间对象只是2D(二维)的,这在实际使用中,并不足够。PostGIS在此基础上,定义了EWKT(Extended Well-Known Tex)和EWKB(Extended Well-Known Binary),以此来支持3dm、3dz和4d 等坐标类型并支持嵌入 SRID 信息。例子如下:
•  POINT(0 0 0) -- XYZ
•  SRID=32632;POINT(0 0) -- XY with SRID
•  POINTM(0 0 0) -- XYM
•  POINT(0 0 0 0) -- XYZM
•  SRID=4326;MULTIPOINTM(0 0 0,1 2 1) -- XYM with SRID
•  MULTILINESTRING((0 0 0,1 1 0,1 2 1),(2 3 1,3 2 1,5 4 1))
•  POLYGON((0 0 0,4 0 0,4 4 0,0 4 0,0 0 0),(1 1 0,2 1 0,2 2 0,1 2 0,1 1 0))
•  MULTIPOLYGON(((0 0 0,4 0 0,4 4 0,0 4 0,0 0 0),(1 1 0,2 1 0,2 2 0,1 2 0,1 1 0)),((-1 -1 0,-1 -2 0,-2 -2 0,-2 -1 0,-1 -1 0)))
•  GEOMETRYCOLLECTIONM(POINTM(2 3 9), LINESTRINGM(2 3 4, 3 4 5))
3、为了配合SQL进行简单查询(类似select * from table),还有一种canonical格式,这个格式其实是WKB的16进制表示。这个格式其实也可以用在Insert和Update语句中。
4、geometry(几何)和geography(地理)
geometry是所有几何体的父类(记住,Postgresql是一个对象数据库),简单的说,geometry是基于欧几里得几何进行计算(欧几里得几何的典型特点是是两点间最短路径是一条直线),而geography是为了基于球面几何(典型特点是,两点间最短路径是一条圆弧)执行一些更复杂的操作而创建的。
使用AddGeometryColumn函数来添加geometry类型,而geography类型需要特别的语法,如下:
CREATE  TABLE  testgeog(gid  serial  PRIMARY  KEY,  the_geog  geography(POINT,4326)  );--定义一个2D的点
CREATE  TABLE  testgeog(gid  serial  PRIMARY  KEY,  the_geog  geography(POINTZ,4326)  ); --定义一个3D的点
标准的geometry类型,如果SRID设置为4326,将被自动转化为为geography类型。
一般情况,寻找一个合适的投影坐标系,比如google map使用的3857,然后使用geometry类型就够了,这样可以获得最高的性能


本文主要参考Postgis文档,下载地址:http://postgis.refractions.net/documentation/manual-1.5/

 

转载于:https://www.cnblogs.com/fre2technic/archive/2011/05/09/2041500.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Create and manage spatial data with PostGIS Key Features Import and export geographic data from the PostGIS database using the available tools Maintain, optimize, and fine-tune spatial data for long-term viability Utilize the parallel support functionality that was introduced in PostgreSQL 9.6 Book Description PostGIS is a spatial database that integrates the advanced storage and analysis of vector and raster data, and is remarkably flexible and powerful. PostGIS provides support for geographic objects to the PostgreSQL object-relational database and is currently the most popular open source spatial databases. If you want to explore the complete range of PostGIS techniques and expose related extensions, then this book is for you. This book is a comprehensive guide to PostGIS tools and concepts which are required to manage, manipulate, and analyze spatial data in PostGIS. It covers key spatial data manipulation tasks, explaining not only how each task is performed, but also why. It provides practical guidance allowing you to safely take advantage of the advanced technology in PostGIS in order to simplify your spatial database administration tasks. Furthermore, you will learn to take advantage of basic and advanced vector, raster, and routing approaches along with the concepts of data maintenance, optimization, and performance, and will help you to integrate these into a large ecosystem of desktop and web tools. By the end, you will be armed with all the tools and instructions you need to both manage the spatial database system and make better decisions as your project's requirements evolve. What you will learn Import and export geographic data from the PostGIS database using the available tools Structure spatial data using the functionality provided by a combination of PostgreSQL and PostGIS Work with a set of PostGIS functions to perform basic and advanced vector analyses Connect PostGIS with Python Learn to use programming frameworks around PostGIS Maintain, optimize, and fine-tune spatial data for long-term viability Explore the 3D capabilities of PostGIS, including LiDAR point clouds and point clouds derived from Structure from Motion (SfM) techniques Distribute 3D models through the Web using the X3D standard Use PostGIS to develop powerful GIS web applications using Open Geospatial Consortium web standards Master PostGIS Raster Who This Book Is For This book is for developers who need some quick solutions for PostGIS. Prior knowledge of PostgreSQL and spatial concepts would be an added advantage. Table of Contents Chapter 1. MOVING DATA IN AND OUT OF POSTGIS Chapter 2. STRUCTURES THAT WORK Chapter 3. WORKING WITH VECTOR DATA THE BASICS Chapter 4. WORKING WITH VECTOR DATA ADVANCED RECIPES Chapter 5. WORKING WITH RASTER DATA Chapter 6. WORKING WITH PGROUTING Chapter 7. Into the Nth Dimension Chapter 8. POSTGIS PROGRAMMING Chapter 9. POSTGIS AND THE WEB Chapter 10. MAINTENANCE OPTIMIZATION AND PERFORMANCE TUNING Chapter 11. USING DESKTOP CLIENTS Chapter 12. Introduction to Location Privacy Protection Mechanisms
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值