WKT
WKT(Well-known text)是一种文本标记语言,用于表示矢量几何对象、空间参照系统及空间参照系统之间的转换。它的二进制表示方式,亦即WKB(well-known binary)则胜于在传输和在数据库中存储相同的信息。该格式由开放地理空间联盟(OGC)制定。
WKT可以表示的几何对象包括:点,线,多边形,TIN(不规则三角网)及多面体。可以通过几何集合的方式来表示不同维度的几何对象。
几何物体的坐标可以是2D(x,y),3D(x,y,z),4D(x,y,z,m),加上一个属于线性参照系统的m值。
以下为几何WKT字串样例:
PROJCS["OSGB 1936 / British National Grid",
GEOGCS["OSGB 1936",
DATUM["OSGB_1936",
SPHEROID["Airy 1830",6377563.396,299.3249646,AUTHORITY["EPSG","7001"]],
TOWGS84[375,-111,431,0,0,0,0],
AUTHORITY["EPSG","6277"]],
PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],
UNIT["DMSH",0.0174532925199433,AUTHORITY["EPSG","9108"]],
AXIS["Lat",NORTH],
AXIS["Long",EAST],
AUTHORITY["EPSG","4277"]],
PROJECTION["Transverse_Mercator"],
PARAMETER["latitude_of_origin",49],
PARAMETER["central_meridian",-2],
PARAMETER["scale_factor",0.999601272],
PARAMETER["false_easting",400000],
PARAMETER["false_northing",-100000],
UNIT["metre",1,AUTHORITY["EPSG","9001"]],
AXIS["E",EAST],
AXIS["N",NORTH],
AUTHORITY["EPSG","27700"]],
VERT_CS["Newlyn",
VERT_DATUM["Ordnance Datum Newlyn",2005,AUTHORITY["EPSG","5101"]],
UNIT["metre",1,AUTHORITY["EPSG","9001"]],
AXIS["Up",UP],
AUTHORITY["EPSG","5701"]],
AUTHORITY["EPSG","7405"]
基础知识:坐标参照系有三种最常见的子类:地心坐标系(geocentric cs、GEOCCS),地理坐标系(geographic cs、GEOGCS),和投影坐标系(projected cs、PROJCS)以及相互之间的关系,可以参考《坐标参照系》。投影参数内容:Ellipsoid 、 Datum ;Projection,可以参考《地图投影为什么》。
坐标系的文字描述的扩展BN范式(EBNF)定义如下:
<coordinate system> = <projected cs> | <geographic cs> | <geocentric cs>
<projection> = PROJECTION["<name>"]
<parameter> = PARAMETER["<name>", <value>]
<value> = <number>
<datum> = DATUM["<name>", <spheroid>]
<spheroid> = SPHEROID["<name>", <semi-major axis>, <inverse flattening>]
<semi-major axis> = <number> NOTE: semi-major axis is measured in meters and must be > 0.
<inverse flattening> = <number>
<prime meridian> = PRIMEM["<name>", <longitude>]
<longitude> = <number>
<angular unit> = <unit>
<linear unit> = <unit>
<unit> = UNIT["<name>", <conversion factor>]
<conversion factor> = <number>
以下示例说明,参照上述参数,然后比瓢画葫芦即可自行用WKT创建坐标系。
地理坐标系的格式:<geographic cs> = GEOGCS["<name>", <datum>, <prime meridian>, <angular unit>]
WGS1984的地理坐标系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"]],
AUTHORITY["EPSG", "4326"]]
投影坐标系的格式:<projected cs> = PROJCS["<name>", <geographic cs>, <projection>, {<parameter>,}* <linear unit>]
WGS1984地理坐标,统一横轴墨卡托(UTM)投影,中央经线117E的投影坐标系WKT形式:
PROJCS["WGS 84 / UTM zone 50N",
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"]], AUTHORITY["EPSG", "4326"]],
PROJECTION["Transverse_Mercator"],
PARAMETER["latitude_of_origin", 0],
PARAMETER["central_meridian", 117],
PARAMETER["scale_factor", 0.9996],
PARAMETER["false_easting", 500000],
PARAMETER["false_northing", 0],
UNIT["metre", 1, AUTHORITY["EPSG", "9001"]],
AUTHORITY["EPSG", "32650"]]
地心坐标系格式相似于地理坐标系:<geocentric cs> = GEOCCS["<name>", <datum>, <prime meridian>, <linear unit>]
参数中出现AUTHORITY是EPSG的玩意,在自定义坐标系时可以忽略,我会在后面详细介绍EPSG相关内容。WKT更具体的可参考OGC相关文档:如SFA、《SF for OLE/COM》等。
练习:给出下属投影坐标系参数,请用WKT方式表述。
投影参数:椭球体,Krasovsky_1940;基准面,北京1954;投影:兰勃特双标准纬线,25N,47N;中央经线,117E。
参考答案:
PROJCS["liongg",GEOGCS["GCS_Beijing_1954",
DATUM["D_Beijing_1954",SPHEROID["Krasovsky_1940",6378245.0,298.3]],
PRIMEM["Greenwich",0.0],
UNIT["Degree",0.0174532925199433]],
PROJECTION["Lambert_Conformal_Conic"],
PARAMETER["False_Easting",20500000.0],
PARAMETER["False_Northing",0.0],
PARAMETER["Central_Meridian",0.0],
PARAMETER["Standard_Parallel_1",25.0],
PARAMETER["Standard_Parallel_2",47.0],
PARAMETER["Scale_Factor",1.0],
PARAMETER["Latitude_Of_Origin",0.0],
UNIT["Meter",1.0]]
有个偷懒的方法就是用商业软件譬如ArcGIS按照参数新建投影,然后在.prj文件中提取投影内容并修改。