16 年 12 月研究 GIS 相关资料用于处理 GIS 相关问题,完成基本 GIS 功能。
最新需要进阶相关内容用于更好的处理相关数据。
特此记录。
本文目录
国内由于特殊的国情,国际标准也要向国家标准靠齐。比如各个不同的坐标系上坐标的换算。
我们都知道一个坐标 (x,y) 可以表示为经纬度,甚至放在坐标系上,我们可以这么运算两点 (x1,y1) , (x2,y2) 之间的距离
# z 表示比例系数
distance = math.sqrt((x1-x2) ** 2 + (y1-y2) ** 2) * z
在近距离的时候的确是可以这么做的比如计算村里小芳和隔壁老王家的距离。当距离过大的时候,比如计算上海 A 区和 B 区的两个写字楼的距离的时候,则有相当大的误差。
那么问题来了:
挖掘技术哪家强
啊不是,是国内有哪些常用坐标标准呢?又是如何计算的呢?
对于小公司而言,我们是没有任何方法来通过 BD-09 以及 GCJ-02 这种坐标系进行运算的:
因为坐标点非线性偏移核心计算方法掌握在 GCJ-02 / BD-09 的公司里面,比如 Google 中国,高德地图,百度地图,腾讯地图。所以,为了研究,则必须要有能够对坐标进行运算的算法, 那这个东西有没有呢?答案是肯定的,因为国外使用的 WGS-84 标准,并且,计算坐标的算法早就开源。
那么,我们的思路就确定下来了。
感谢诸多在 GIS 运算上开源的中国先辈,我们轻而易举的获取到了坐标之间相互转化的方法:
https://github.com/wandergis/coordTransform_py
坐标系,我们可以简单的理解为一个笛卡尔坐标系(虽然这么说很不准确,但已经足够形象了)
于是对于二维的数据,GIS 的分析就可以理解为对于点,线段,多边形自身以及他们之间的关系的分析。
raster 的 digital elevation model(DEM), 即每一个像素值包含一个 elevation value
GDAL/OGR
Point
LineString
Polygon
MultiPoint
MultiLineString
MultiPolygon
ST_AsText(geom) 用于查看 WKT
ST_GeometryType(geometry) returns the type of the geometry
ST_NDims(geometry) returns the number of dimensions of the geometry
ST_SRID(geometry) returns the spatial reference identifier number of the geometry
ST_X(geometry) returns the X ordinate , 如果作用在 Point 上,则返回经度
ST_Y(geometry) returns the Y ordinate , 如果作用在 Point 上,则返回纬度
ST_Length(geometry) returns the length of the linestring
ST_StartPoint(geometry) returns the first coordinate as a point
ST_EndPoint(geometry) returns the last coordinate as a point
ST_NPoints(geometry) returns the number of coordinates in the linestring
ST_Area(geometry) returns the area of the polygons
ST_NRings(geometry) returns the number of rings (usually 1, more of there are holes)
ST_ExteriorRing(geometry) returns the outer ring as a linestring
ST_InteriorRingN(geometry,n) returns a specified interior ring as a linestring
ST_Perimeter(geometry) returns the length of all the rings
ST_NumGeometries(geometry) returns the number of parts in the collection
ST_GeometryN(geometry,n) returns the specified part
ST_Area(geometry) returns the total area of all polygonal parts
ST_Length(geometry) returns the total length of all linear parts
-- 合并多个区域并返回 multipoly
UPDATE areas as A
SET "Boundary" = ST_Multi(st_union(ARRAY(SELECT geom FROM county_boundary_region WHERE gid in ( 'foo_id','bar_id)')
)))
WHERE A."ID" = 'xxxxxx'
ChangeLog: