PROJ.4库和OSGB36

时间:2009-09-15 12:39:50

标签: gis proj4js proj4

希望你很好

我正在尝试使用proj.4库将纬度/经度坐标转换为OSGB36 x和y。

有没有其他人成功完成此操作?我需要填充srcPrj4String和destPrj4String变量,例如

string srcPrj4String =“+ proj = longlat + ellps = WGS84 + datum = WGS84 + no_defs”;
string destPrj4String =“+ proj = utm + zone = 11 + ellps = GRS80 + datum = NAD83 + units = m”;

但我无法弄清楚destPrj4String应该与OSGB36一起使用 - 我知道数据应该是+ datum = OSGB36,但我尝试的一切都不起作用

有什么想法吗?

非常感谢提前

莱迪

3 个答案:

答案 0 :(得分:6)

谷歌搜索来自曼彻斯特大学地球科学学院的约翰史蒂文森博士this,如果有人这样做,他应该做对。这是一个引用。


问题是去OSGB36需要一个投影和一个 datum conversion。在October 2007之前,proj只携带 超出投影,从而产生大的偏移。你可以检查一下 如果您通过运行'proj -v'或查看您的新版本来获得新版本 epsg文件:

cat /usr/share/proj/epsg | grep -A 1 "British National Grid" 

# OSGB 1936 / British National Grid 
<27700> +proj=tmerc +lat_0=49 +lon_0=-2 +k=0.9996012717 +x_0=400000 
+y_0=-100000 +ellps=airy +datum=OSGB36 +units=m +no_defs  <> 

新版本有+ datum = OSGB36。

如果您使用的是旧版本,则可以使用以下代码替换该行:

+proj=tmerc +lat_0=49 +lon_0=-2 +k=0.999601 +x_0=400000 +y_0=-100000 
+ellps=airy 
+towgs84=446.448,-125.157,542.060,0.1502,0.2470,0.8421,-20.4894 +units=m 
+no_defs <> 

一个复杂因素是OSGB36相对于GPS是slightly distorted 预测(例如WGS84和ETRS89)。这个偏差很小,而且 仅对更高精度的测量很重要。很多搜索 OSGB36偏移会显示与此相关的页面。如果你想 也弥补了这一点, 您可以下载nadgrid文件和​​use it。对于我的数据,这感动了 点数约1米。

答案 1 :(得分:5)

得到了它:

string srcPrj4String = "+proj=longlat +ellps=WGS84 +towgs84=0,0,0 +no_defs";
string destPrj4String = "+proj=tmerc +lat_0=49 +lon_0=-2 +k=0.9996012717 +x_0=400000 +y_0=-100000 +ellps=airy +towgs84=446.448,-125.157,542.060,0.1502,0.2470,0.8421,-20.4894 +units=m +no_defs";

喝彩!

答案 2 :(得分:1)

EPSG:27700 on spatialreference.org给出了用于定义它的各种字符串,包括用于proj4的字符串。

以下是使用proj4绑定的中的示例代码>:

#!/usr/bin/ruby
require 'rubygems'
require 'proj4'

#Some example WGS84 lat lon coordinates to convert:
lon = -0.10322
lat = 51.52237

srcPoint = Proj4::Point.new(Math::PI * lon.to_f / 180, 
                            Math::PI * lat.to_f / 180)

srcPrj  = Proj4::Projection.new("+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs") 
destPrj = Proj4::Projection.new("+proj=tmerc +lat_0=49 +lon_0=-2 +k=0.999601 +x_0=400000 +y_0=-100000 +ellps=airy +towgs84=446.448,-125.157,542.060,0.1502,0.2470,0.8421,-20.4894 +units=m +no_defs <>")

point = srcPrj.transform(destPrj, srcPoint)

puts "http://www.openstreetmap.org/?mlat=" + lat.to_s + "&mlon=" + lon.to_s + "&zoom=16"
puts "Converts to:";
puts "http://streetmap.co.uk/grid/" + point.x.round.to_s + "_" + point.y.round.to_s + "_106"

输出:

http://www.openstreetmap.org/?mlat=51.52237&mlon=-0.10322&zoom=16
转换为:
http://streetmap.co.uk/grid/531691_182089_106

所以现在这个工作正常。最初我只是尝试'destPrj'字符串,并调用'forward'方法,但这拒绝进行基准转换,导致一切都在100米外。似乎有必要使用'srcPrj'字符串和'transform'方法来进行基准转换。

另请参阅我的博文:Ruby code for converting to UK Ordnance Survey coordinate systems from WGS84?,其中包含用于执行相同操作的纯ruby版本(不是proj4)