为了能够正确地描述要素的位置和形状,需要引入一个用于定义位置的框架,也就是空间参考。空间参考用于存储各类要素坐标属性的坐标系系统,借此描述一个要素的真实位置。主要包括两大部分:坐标系统 和 坐标域。
坐标系统
坐标系统是一个二维或者三维的参照系,用于定位坐标点,通过坐标系统可以确定要素在地球上的真实位置。常用的坐标系主要是以下两种:大地坐标系和投影坐标系。
坐标域
坐标域是一个要素中坐标的允许取值范围。
gma 中空间参考功能位于 gma.algorithm.core.spat,用以初始化各种坐标系/投影,以方便检索和使用参数和查询相关信息,这是基础的空间参考;基于此构建的扩展(增强)空间参考功能整合在地图工具 gma.map.rcs 中 SpatRef 类中 。gma 库(1.1.5)及其空间参考功能分布如下:
格式 | 示例 (以 WGS 84 为例) |
---|---|
EPSG | 4326 (或 'EPSG:4326' ) |
MICoordSys | 'Earth Projection 1, 104' |
PCI | ['LONG/LAT D000', 'DEGREE', (0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0)] |
PROJJSON | '{\n "$schema": "https://proj.org/schemas/v0.4/projjson.schema.json",\n "type": "GeographicCRS",\n "name": "WGS 84",\n "datum": {\n "type": "GeodeticReferenceFrame",\n "name": "World Geodetic System 1984",\n "ellipsoid": {\n "name": "WGS 84",\n "semi_major_axis": 6378137,\n "inverse_flattening": 298.257223563\n }\n },\n "coordinate_system": {\n "subtype": "ellipsoidal",\n "axis": [\n {\n "name": "Geodetic latitude",\n "abbreviation": "Lat",\n "direction": "north",\n "unit": "degree"\n },\n {\n "name": "Geodetic longitude",\n "abbreviation": "Lon",\n "direction": "east",\n "unit": "degree"\n }\n ]\n },\n "id": {\n "authority": "EPSG",\n "code": 4326\n }\n}' |
PrettyWkt | 'GEOGCS["WGS 84",\n DATUM["WGS_1984",\n SPHEROID["WGS 84",6378137,298.257223563,\n AUTHORITY["EPSG","7030"]],\n AUTHORITY["EPSG","6326"]],\n PRIMEM["Greenwich",0,\n AUTHORITY["EPSG","8901"]],\n UNIT["degree",0.0174532925199433,\n AUTHORITY["EPSG","9122"]],\n AXIS["Latitude",NORTH],\n AXIS["Longitude",EAST],\n AUTHORITY["EPSG","4326"]]' |
Proj4 | '+proj=longlat +datum=WGS84 +no_defs' |
USGS | [0, 0, (0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0), 12] |
Wkt | 'GEOGCS["WGS 84",DATUM["WGS_1984",SPHEROID["WGS 84",6378137,298.257223563,AUTHORITY["EPSG","7030"]],AUTHORITY["EPSG","6326"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.0174532925199433,AUTHORITY["EPSG","9122"]],AXIS["Latitude",NORTH],AXIS["Longitude",EAST],AUTHORITY["EPSG","4326"]]' |
XML | ' |
部分主要坐标系名称 | WGS84 |
from gma.map import rcs
SR = rcs.SpatRef('WGS84')
类型 | 名称 | 描述 | 使用 | 结果 |
---|---|---|---|---|
属性 | AeraOfUse | 坐标系使用的经纬度范围。无法识别范围的坐标系则根据中央经线自动生成最大范围 (gma 对全球范围的坐标系进行了修改,其最东端与最西端永远相差0.02° ) | SR.AeraOfUse |
[-179.99, -89.99, 179.99, 89.99] |
属性 | AngularUnits | 角度单位值 | SR.AngularUnits |
0.017453292519943295 |
属性 | AngularUnitsName | 角度单位名称 | SR.AngularUnitsName |
‘degree’ |
属性 | EPSG | 坐标系 EPSG 编码。没有 EPSG 编码的坐标系则值为 0 | SR.EPSG |
4326 |
方法 | Export | 导出坐标系。支持 MICoordSys,PCI,PROJJSON,PrettyWkt,Proj4,USGS,Wkt,XML 格式 | SR.Export(Format = 'Proj4') |
‘+proj=longlat +datum=WGS84 +no_defs’ |
方法 | GetProjParms | 获取坐标系的投影参数 | SR.GetProjParms() |
{} |
方法 | GetUseFeature | 获取坐标系的使用区域 Feature | SR.GetUseFeature() |
|
方法 | GetUseFeatureInWGS84 | 获取坐标系的使用区域 Feature(WGS84) | SR.GetUseFeatureInWGS84() |
|
属性 | InvFlattening | 椭球体反扁率 | SR.InvFlattening |
298.257223563 |
属性 | LinearUnits | 线形单位值 | SR.LinearUnits |
1.0 |
属性 | LinearUnitsName | 线形单位名称 | SR.LinearUnitsName |
‘Meter’ |
属性 | Name | 坐标系名称 | SR.Name |
‘WGS 84’ |
属性 | PRIMEM | 坐标系的本初子午线 | SR.PRIMEM |
{‘Greenwich’: 0.0} |
属性 | Proj | WKT 格式的坐标系 | SR.Proj |
‘GEOGCS[“WGS 84”,DATUM[“WGS_1984”,SPHEROID[“WGS 84”,6378137,298.257223563,AUTHORITY[“EPSG”,“7030”]],AUTHORITY[“EPSG”,“6326”]],PRIMEM[“Greenwich”,0,AUTHORITY[“EPSG”,“8901”]],UNIT[“degree”,0.0174532925199433,AUTHORITY[“EPSG”,“9122”]],AXIS[“Latitude”,NORTH],AXIS[“Longitude”,EAST],AUTHORITY[“EPSG”,“4326”]]’ |
属性 | SemiMajor | 椭球体长半轴 | SR.SemiMajor |
6378137.0 |
属性 | SemiMinor | 椭球体短半轴 | SR.SemiMinor |
6356752.314245179 |
属性 | Type | 坐标系类型 | SR.Type |
‘Geographic’ |
结合 gma 绘图工具和 GetUseFeatureInWGS84 方法,可以很容易的查看某个坐标系使用区域在地图上的位置。本文以 :
- EPSG:4326( WGS84)
- EPSG:4490(China Geodetic Coordinate System 2000)
- EPSG:2163(NAD27 / US National Atlas Equal Area)
- EPSG:32650(WGS 84 / UTM zone 50N)
四个坐标系为例进行展示。
from gma.map import plot, rcs
WorldDS = plot.GetWorldDataSource()
WorldLayer = WorldDS.GetLayer(0)
MapF = plot.MapFrame()
MapL1 = MapF.AddLayer(WorldLayer, FaceColor = 'none', EdgeColor = 'black', LineWidth = 0.1, Zorder = 1)
# 绘制坐标系范围
Spat = rcs.SpatRef('WGS84')
UseFeature = Spat.GetUseFeatureInWGS84()
MapF.AddFeature(UseFeature)
MapF = plot.MapFrame()
MapL1 = MapF.AddLayer(WorldLayer, FaceColor = 'none', EdgeColor = 'black', LineWidth = 0.1, Zorder = 1)
# 绘制坐标系范围
Spat = rcs.SpatRef(4490)
UseFeature = Spat.GetUseFeatureInWGS84()
MapF.AddFeature(UseFeature)
MapF = plot.MapFrame()
MapL1 = MapF.AddLayer(WorldLayer, FaceColor = 'none', EdgeColor = 'black', LineWidth = 0.1, Zorder = 1)
# 绘制坐标系范围
Spat = rcs.SpatRef(2163)
UseFeature = Spat.GetUseFeatureInWGS84()
MapF.AddFeature(UseFeature)
MapF = plot.MapFrame()
MapL1 = MapF.AddLayer(WorldLayer, FaceColor = 'none', EdgeColor = 'black', LineWidth = 0.1, Zorder = 1)
# 绘制坐标系范围
Spat = rcs.SpatRef(32650)
UseFeature = Spat.GetUseFeatureInWGS84()
MapF.AddFeature(UseFeature)
MapF = plot.MapFrame(BaseMapProj = 6931)
MapL1 = MapF.AddLayer(WorldLayer, FaceColor = 'none', EdgeColor = 'black', LineWidth = 0.1, Zorder = 1)
# 绘制坐标系范围
Spat = rcs.SpatRef(32650)
UseFeature = Spat.GetUseFeatureInWGS84()
MapF.AddFeature(UseFeature)