PostgreSQL MySQL 兼容性之 - Gis类型

本文涉及的产品
云原生数据库 PolarDB MySQL 版,Serverless 5000PCU 100GB
云原生数据库 PolarDB 分布式版,标准版 2核8GB
云数据库 RDS MySQL Serverless,0.5-2RCU 50GB
简介: PostGIS的GIS功能相比MySQL强大太多,本文仅仅列举了MySQL支持的部分。欲了解PostGIS请参考:http://postgis.net/docs/manual-2.2/reference.htmlPostGIS有几百个操作函数, 对GIS支持强大。 POINT MySQL

PostGIS的GIS功能相比MySQL强大太多,本文仅仅列举了MySQL支持的部分。
欲了解PostGIS请参考:
http://postgis.net/docs/manual-2.2/reference.html
PostGIS有几百个操作函数, 对GIS支持强大。

POINT

MySQL

  POINT
    PointFromText('POINT(10 10)')
    PointFromWKB(AsWKB(PointFromText('POINT(10 20)'))

PostgreSQL

  # PostgreSQL
  point
    point( x , y )
  # PostGIS
  point

LINESTRING

MySQL

  LINESTRING

  CREATE TABLE gis_line  (g LINESTRING);
  SHOW FIELDS FROM gis_line;
  INSERT INTO gis_line VALUES
    (LineFromText('LINESTRING(0 0,0 10,10 0)')),
    (LineStringFromText('LINESTRING(10 10,20 10,20 20,10 20,10 10)')),
    (LineStringFromWKB(AsWKB(LineString(Point(10, 10), Point(40, 10)))));

  GLENGTH
    Length of a LineString value
  ST_ENDPOINT
    Returns the endpoint of a LineString
  ST_NUMPOINTS
    Returns the number of Point objects in a LineString
  ST_POINTN
    Returns the N-th Point in the LineString
  ST_STARTPOINT
    Returns the start point of a LineString

PostgreSQL

  # PostGIS
  LINESTRING

  ST_Length — Returns the 2D length of the geometry if it is a LineString or MultiLineString. geometry are in units of spatial reference and geography are in meters (default spheroid)
  ST_Length2D — Returns the 2-dimensional length of the geometry if it is a linestring or multi-linestring. This is an alias for ST_Length
  ST_3DLength — Returns the 3-dimensional or 2-dimensional length of the geometry if it is a linestring or multi-linestring.
  ST_LengthSpheroid — Calculates the 2D or 3D length of a linestring/multilinestring on an ellipsoid. This is useful if the coordinates of the geometry are in longitude/latitude and a length is desired without reprojection.
  ST_Length2D_Spheroid — Calculates the 2D length of a linestring/multilinestring on an ellipsoid. This is useful if the coordinates of the geometry are in longitude/latitude and a length is desired without reprojection.

  ST_EndPoint — Returns the last point of a LINESTRING or CIRCULARLINESTRING geometry as a POINT.

  ST_NumPoints — Return the number of points in an ST_LineString or ST_CircularString value.

  ST_PointN — Return the Nth point in the first linestring or circular linestring in the geometry. Return NULL if there is no linestring in the geometry.

  ST_StartPoint — Returns the first point of a LINESTRING geometry as a POINT.

  http://postgis.net/docs/manual-2.2/reference.html
  PostGIS有几百个操作函数, 对GIS支持强大。

POLYGON

MySQL

  Polygon properties

  ST_AREA
    Area of a Polygon
  ST_ExteriorRing
    Returns the exterior ring of a Polygon as a LineString
  ST_InteriorRingN
    Returns the N-th interior ring for a Polygon
  ST_NUMINTERIORRINGS
    Number of interior rings in a Polygon

PostgreSQL

  # PostGIS

  ST_Area — Returns the area of the surface if it is a Polygon or MultiPolygon. For geometry, a 2D Cartesian area is determined with units specified by the SRID. For geography, area is determined on a curved surface with units in square meters.
  ST_ExteriorRing — Returns a line string representing the exterior ring of the POLYGON geometry. Return NULL if the geometry is not a polygon. Will not work with MULTIPOLYGON
  ST_InteriorRingN — Return the Nth interior linestring ring of the polygon geometry. Return NULL if the geometry is not a polygon or the given N is out of range.
  ST_NumInteriorRings — Return the number of interior rings of the a polygon in the geometry. This will work with POLYGON and return NULL for a MULTIPOLYGON type or any other type

  ST_GeometryN — Return the 1-based Nth geometry if the geometry is a GEOMETRYCOLLECTION, (MULTI)POINT, (MULTI)LINESTRING, MULTICURVE or (MULTI)POLYGON, POLYHEDRALSURFACE Otherwise, return NULL.
  ST_IsEmpty — Returns true if this Geometry is an empty geometrycollection, polygon, point etc.
  ST_NRings — If the geometry is a polygon or multi-polygon returns the number of rings.
  ST_ForceRHR — Forces the orientation of the vertices in a polygon to follow the Right-Hand-Rule.
  ST_3DIntersects — Returns TRUE if the Geometries "spatially intersect" in 3d - only for points, linestrings, polygons, polyhedral surface (area). With SFCGAL backend enabled also supports TINS
  ST_Perimeter — Return the length measurement of the boundary of an ST_Surface or ST_MultiSurface geometry or geography. (Polygon, MultiPolygon). geometry measurement is in units of spatial reference and geography is in meters.
  ST_Perimeter2D — Returns the 2-dimensional perimeter of the geometry, if it is a polygon or multi-polygon. This is currently an alias for ST_Perimeter.
  ST_3DPerimeter — Returns the 3-dimensional perimeter of the geometry, if it is a polygon or multi-polygon.
  ST_CurveToLine — Converts a CIRCULARSTRING/CURVEPOLYGON to a LINESTRING/POLYGON
  ST_DumpRings — Returns a set of geometry_dump rows, representing the exterior and interior rings of a polygon.
  ST_LineToCurve — Converts a LINESTRING/POLYGON to a CIRCULARSTRING, CURVEPOLYGON
  ST_MinimumBoundingCircle — Returns the smallest circle polygon that can fully contain a geometry. Default uses 48 segments per quarter circle.
  ST_Polygonize — Aggregate. Creates a GeometryCollection containing possible polygons formed from the constituent linework of a set of geometries.
  ST_SimplifyPreserveTopology — Returns a "simplified" version of the given geometry using the Douglas-Peucker algorithm. Will avoid creating derived geometries (polygons in particular) that are invalid.
  ST_LocateAlong — Return a derived geometry collection value with elements that match the specified measure. Polygonal elements are not supported.
  ST_LocateBetween — Return a derived geometry collection value with elements that match the specified range of measures inclusively. Polygonal elements are not supported.

  http://postgis.net/docs/manual-2.2/reference.html
  PostGIS有几百个操作函数, 对GIS支持强大。

MultiPoint

MySQL

  MultiPoint(pt1,pt2,...)

PostgreSQL

  # PostGIS
  MultiPoint

MultiPolygon

MySQL

  MultiPolygon(poly1,poly2,...)
  

PostgreSQL

  # PostGIS
  MultiPolygon

ST_BUFFER

MySQL

  ST_BUFFER(g1,r),  BUFFER(g1,r)
  Returns a geometry that represents all points whose distance from geometry g1 is less than or equal to distance, or radius

PostgreSQL

  # PostGIS
  ST_Buffer — (T) Returns a geometry covering all points within a given distance from the input geometry.

ST_ConvexHull

MySQL

  ST_ConvexHull (g), ConvexHull(g)
  Given a geometry, returns a geometry that is the minimum convex geometry enclosing all geometries within the set. Returns NULL if the geometry value is NULL or an empty value.

PostgreSQL

  # PostGIS
  ST_ConvexHull — The convex hull of a geometry represents the minimum convex geometry that encloses all geometries within the set.

ST_INTERSECTION

MySQL

  ST_INTERSECTION(g1,g2)
  Returns a geometry that is the intersection, or shared portion, of geometry g1 and geometry g2.

PostgreSQL

  # PostGIS
  ST_Intersection — (T) Returns a geometry that represents the shared portion of geomA and geomB.
  ST_Difference — Returns a geometry that represents that part of geometry A that does not intersect with geometry B.

ST_PointOnSurface

MySQL

  ST_PointOnSurface (g), PointOnSurface(g)
  Given a geometry, returns a POINT guaranteed to intersect a surface.

PostgreSQL

  # PostGIS
  ST_PointOnSurface — Returns a POINT guaranteed to lie on the surface.

ST_SYMDIFFERENCE

MySQL

  ST_SYMDIFFERENCE(g1,g2)
  Returns a geometry that represents the portions of geometry g1 and geometry g2 that don't intersect.

PostgreSQL

  # PostGIS
  ST_Difference — Returns a geometry that represents that part of geometry A that does not intersect with geometry B
  ST_SymDifference — Returns a geometry that represents the portions of A and B that do not intersect. It is called a symmetric difference because ST_SymDifference(A,B) = ST_SymDifference(B,A).

ST_UNION

MySQL

  ST_UNION(g1,g2)
  Returns a geometry that is the union of the geometry g1 and geometry g2.

PostgreSQL

  # PostGIS
  ST_Union — Returns a geometry that represents the point set union of the Geometries.
  ST_UnaryUnion — Like ST_Union, but working at the geometry component level.

PostGIS reference

http://postgis.net/docs/manual-2.2/reference.html
PostGIS有几百个操作函数, 对GIS支持强大。
相关实践学习
基于CentOS快速搭建LAMP环境
本教程介绍如何搭建LAMP环境,其中LAMP分别代表Linux、Apache、MySQL和PHP。
全面了解阿里云能为你做什么
阿里云在全球各地部署高效节能的绿色数据中心,利用清洁计算为万物互联的新世界提供源源不断的能源动力,目前开服的区域包括中国(华北、华东、华南、香港)、新加坡、美国(美东、美西)、欧洲、中东、澳大利亚、日本。目前阿里云的产品涵盖弹性计算、数据库、存储与CDN、分析与搜索、云通信、网络、管理与监控、应用服务、互联网中间件、移动服务、视频服务等。通过本课程,来了解阿里云能够为你的业务带来哪些帮助     相关的阿里云产品:云服务器ECS 云服务器 ECS(Elastic Compute Service)是一种弹性可伸缩的计算服务,助您降低 IT 成本,提升运维效率,使您更专注于核心业务创新。产品详情: https://www.aliyun.com/product/ecs
相关文章
|
1月前
|
关系型数据库 MySQL
Mysql基础第十九天,使用不同类型的链接
Mysql基础第十九天,使用不同类型的链接
25 0
Mysql基础第十九天,使用不同类型的链接
|
2月前
|
关系型数据库 MySQL Docker
MySQL 5.7 timestamp类型设置default value为'0000-00-00 00:00:00'报错的解决方法
MySQL 5.7 timestamp类型设置default value为'0000-00-00 00:00:00'报错的解决方法
|
2月前
|
SQL NoSQL 关系型数据库
关系型数据库管理系统Mysql
关系型数据库管理系统Mysql
|
1月前
|
弹性计算 安全 关系型数据库
rds网络类型选取
云数据库RDS的网络类型选择包括经典网络、专有网络(VPC)、公共网络和私有网络。推荐使用VPC以实现高安全隔离,私有网络增加安全性且节省公网费用。根据业务需求和安全策略选择,如需内部访问选择同一VPC,外部访问则需公网并配以严格安全措施。最新阿里云RDS建议使用VPC并结合安全组、网络ACL和白名单保障安全,通过CEN实现跨地域通信。
17 7
|
1月前
|
数据可视化 关系型数据库 MySQL
PolarDB常见问题之无法创建mysql的连接池如何解决
PolarDB是阿里云推出的下一代关系型数据库,具有高性能、高可用性和弹性伸缩能力,适用于大规模数据处理场景。本汇总囊括了PolarDB使用中用户可能遭遇的一系列常见问题及解答,旨在为数据库管理员和开发者提供全面的问题指导,确保数据库平稳运行和优化使用体验。
|
1月前
|
存储 关系型数据库 MySQL
TiDB与MySQL、PostgreSQL等数据库的比较分析
【2月更文挑战第25天】本文将对TiDB、MySQL和PostgreSQL等数据库进行详细的比较分析,探讨它们各自的优势和劣势。TiDB作为一款分布式关系型数据库,在扩展性、并发性能等方面表现突出;MySQL以其易用性和成熟性受到广泛应用;PostgreSQL则在数据完整性、扩展性等方面具有优势。通过对比这些数据库的特点和适用场景,帮助企业更好地选择适合自己业务需求的数据库系统。
|
1月前
|
关系型数据库 Serverless 分布式数据库
PolarDB的Serverless能力与同类型产品的对比
【2月更文挑战第21天】PolarDB的Serverless能力与同类型产品的对比
20 2
|
1月前
|
存储 关系型数据库 MySQL
MySQL中常见的存储引擎类型
【2月更文挑战第18天】
49 7
|
1月前
|
关系型数据库 MySQL 分布式数据库
PolarDB for MySQL数据库外网连接解析失败的原因可能有以下几点
【2月更文挑战第16天】PolarDB for MySQL数据库外网连接解析失败的原因可能有以下几点
24 1
|
1月前
|
关系型数据库 MySQL 测试技术
数据库专家带你体验PolarDB MySQL版 Serverless的极致弹性特性!
本次基于阿里云瑶池数据库解决方案体验馆,带你体验PolarDB MySQL Serverless形态下的性能压测环境,基于可选择的标准压测工具进行压测,构造弹性场景进行压测,实时动态展示弹性能力、价格和性价比结果,压测环境可开放定制修改、可重复验证。参与活动即有机会获得鼠标、小米打印机、卫衣等精美礼品。
数据库专家带你体验PolarDB MySQL版 Serverless的极致弹性特性!

相关产品

  • 云数据库 RDS MySQL 版
  • 云原生数据库 PolarDB