postgis的geography_columns和geometry_columns有什么区别

1、先说说Sql Server中geometry和geography的区别:

        geometry:planar    平面坐标系【supported by SQL Server conforms to the Open Geospatial Consortium (OGC) Simple Features for SQL Specification version 1.1.0.】

        geography: terrestrial   地理坐标系【stores ellipsoidal (round-earth) data, such as GPS latitude and longitude coordinates.】

        如果要计算两个lat/lon点之间的实际距离就需要将geometry类型转成geography类型,不然结果肯定不正确。

2、geometry转geography的方法:

       geography::STGeomFromText(boundary.ToString(), 4326)

       boundary是geometry类型的,4326是坐标系的参数,4326代表GCS-WGS-1984坐标系,是系统默认的坐标系。

       可以通过这个sql获得系统的坐标系(Sql server中):Select * from sys.spatial_reference_systems where authorized_spatial_reference_id=4326

3、STDistance的用法:

       https://msdn.microsoft.com/zh-cn/library/bb933952(v=sql.110).aspx

       按照里面的例子能够计算出距离,但是如果输入的是经纬度的值,得出的结果总是觉得不对,值比较小,实际上需要按照第二步转化为geography类型再计算就可以了,4326坐标系默认返回距离的单位【unit】是米【meter】。

       STDistance也可以计算点到面的最短距离。   

posted on 2020-08-12 09:19  小甜瓜安东泥  阅读(708)  评论(0编辑  收藏  举报