转换(英国)军械测量国家网格和经纬度坐标的库
OSGridConverter的Python项目详细描述
说明
这个软件包允许用户操作地球表面的坐标。 在两个主要坐标系中:纬度/经度以度为单位, 以及制图系统,以东距和北距测量, 基于地球大地水准面的局部椭球近似。
特别是,它提供了处理coordinates的工具 (形式为ab 12345 12345)基于National Grid,定义 英国军械调查局。有关详细信息,请参阅军械测量局的 国家电网FAQ page。
包提供了基本的函数来转换 纬度/经度到国家网格和反之亦然。然而, 下面是一个全面的系统,用于在 不同的co-ordinate systems,包括英国,爱尔兰共和国, 法国、北美和日本。
简单转换
OSGridConverter。latlong2grid(latitude,longitude,tag='wgs84')
Converts from latitude / longitude to an OS Grid Reference.
latitude: The latitude of the point, expressed in decimal degrees North longitude: The longitude of the point, expressed in decimal degrees East tag: The name of the datum used in the conversion; default is WGS84, referring to the standard datum used by Ordnance Survey 返回值是一个osgridreference对象。为了简单起见 重要的是,g的转换就是这样一个对象,然后g.e和 g.n分别表示其东距和北距,单位为米,以及 str(g)返回格式化的国家网格引用。
示例:
>>> from OSGridConverter import latlong2grid >>> g=latlong2grid(52.657977,1.716038) >>> (g.E,g.N) (651408, 313177) >>> str(g) 'TG 51408 13177'
OSGridConverter。grid2latlong(grid,tag='wgs84')
Converts from an OS Grid Reference to latitude / longitude.
grid: The point to be converted. Either an OSGridReference object, or a string formatted as an Ordnance Survey grid reference, e.g. ‘TG 51408 13177’ tag: The name of the mapping datum used in the conversion; default is WGS84, referring to the standard datum used by Ordnance Survey 返回值是一个latlong对象。为了简单起见 重要的是,l的转换就是这样一个对象,然后l.latitude 它的纬度表示为十进制的北纬度,g。经度是 它的经度以东边的十进制度数表示。
示例:
>>> from OSGridConverter import grid2latlong >>> l=grid2latlong('TG 51408 13177') >>> (l.latitude,l.longitude) (52.65798005789814, 1.7200761111093394)
OSGridConverter。标记
A list of strings: names of the standing mapping Data that the package is aware of and can convert between. Its members are the valid values that can be used in the tag field of the conversion functions.
Tag Details WSG84 UK OSGB36 Former UK standard (replaced by WGS84) ED50 UK; used for oil and gas exploration Irl1975 Republic of Ireland NTF France TokyoJapan Japan NAD83 North America; very similar to WGS84 For more information (and more examples of mapping Data) see the Wikipedia page on Geodetic Datum.
注释
从lat/long转换为grid并返回lat/long通常不 以原始值结束。这是由于内部舍入的组合 误差,加上国家网格将点分解为10米x 10米的正方形。 在上面的例子中,前后纬度相差约1.0e-5 经度大约是3.0e-3,这是典型的。