PostGIS--介绍


1、什么是PostGIS?

PostGIS通过增加对空间类型空间索引空间函数三个功能的支持,将PostgreSQL数据库管理系统转变为空间数据库。

2、数据

2.1 对象

2.1.1 读取几何元数据信息函数

  • ST_GeometryType(geometry) 返回几何图形的类型
  • ST_NDims(geometry) 返回几何图形的维数
  • ST_SRID(geometry) 返回几何体的空间参考标识符编号

2.1.2 处理点的函数

  • ST_X(geometry) 返回 X 纵坐标
  • ST_Y(geometry) 返回 Y 纵坐标

2.1.3 处理线的函数

  • ST_Length(geometry) 返回线串的长度
  • ST_StartPoint(geometry) 返回第一个坐标作为点
  • ST_EndPoint(geometry) 返回最后一个坐标作为点
  • ST_NPoints(geometry) 返回线串中的坐标数

2.1.4 处理面的函数

  • ST_Area(geometry) 返回多边形的面积
  • ST_NRings(geometry) 返回环数(通常为 1,如果有孔则更多)
  • ST_ExteriorRing(geometry) 以线串形式返回外环
  • ST_InteriorRingN(geometry,n) 以线串的形式返回指定的内环
  • ST_Perimeter(geometry) 返回所有环的长度

2.1.5 集合

  • MultiPoint,点的集合
  • MultiLineString,线串的集合
  • MultiPolygon,多边形的集合
  • GeometryCollection,任何几何图形(包括其他集合)的异构集合

用于处理集合的一些特定空间功能包括:

  • ST_NumGeometries(geometry) 返回集合中的零件数
  • ST_GeometryN(geometry,n) 返回指定的零件
  • ST_Area(geometry) 返回所有多边形零件的总面积
  • ST_Length(geometry) 返回所有线性零件的总长度

2.2 集合输入和输出

在数据库中,几何图形以仅供PostGIS程序使用的格式存储在磁盘上。为了让外部程序插入和检索有用的几何图形,需要将它们转换为其他应用程序可以理解的格式。幸运的是,PostGIS 支持以多种格式发射和使用几何图形:

  • 众所周知的文本(WKT)
    • ST_GeomFromText(text, srid) 返回geometry
    • ST_AsText(几何图形)返回text
    • ST_AsEWKT(geometry) 返回text
  • 众所周知的二进制文件(WKB)
    • ST_GeomFromWKB(bytea)返回geometry
    • ST_AsBinary(几何)返回bytea
    • ST_AsEWKB(几何图形)返回bytea
  • 地理标记语言 (GML))
    • ST_GeomFromGML(text) 返回geometry
    • ST_AsGML(几何图形)返回text
  • 锁孔标记语言 (KML))
    • ST_GeomFromKML(text) 返回geometry
    • ST_AsKML(geometry) 返回text
  • GeoJSON的
    • ST_AsGeoJSON(geometry) 返回text
  • 可缩放矢量图形 (SVG)
    • ST_AsSVG(geometry) 返回text

2.3 shapefile文件

Shapefile是一种空间数据文件格式,用于存储地理空间数据。一个Shapefile由一个主文件(.shp)和至少一个索引文件(.shx)以及一个 dBASE 表 (.dbf) 组成。可以包含其他辅助文件

  • .shp:包含地理空间数据的主体内容,使用特定的格式存储几何形状(点、线、多边形)。
  • .shx:索引信息
  • .dbf:包含与几何形状相关联的属性数据。
    在这里插入图片描述

总结

本文介绍了PostGIS,它通过支持空间类型、空间索引和空间函数,将PostgreSQL转变为空间数据库。文章详细列出了处理几何元数据、点、线和面的函数,包括获取几何类型、维数、坐标、长度、面积等功能。此外,介绍了几何集合的处理及其相关函数,如MultiPoint、MultiLineString和MultiPolygon等。

后续我会继续更新详细的PostGIS相关知识,包括不限于:空间、投影、地理、有效性等
大家也可以通过PostGIS官网学习:PostGIS官网

PS:

感谢您的阅读!如果您觉得本篇文章对您有所帮助,请给予博主一个赞喔~

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、付费专栏及课程。

余额充值