PROJ.4 库和 OSGB36

发布于 2024-08-04 23:42:22 字数 420 浏览 14 评论 0原文

希望你一切都好

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

还有其他人成功地做到了这一点吗?我需要填充 srcPrj4String 和 destPrj4String 变量,例如

string srcPrj4String = "+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs";
字符串 destPrj4String = "+proj=utm +zone=11 +ellps=GRS80 +datum=NAD83 +units=m";

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

有什么想法吗?

非常感

谢莱迪

hope you are well

I am trying to convert lat/long coordinates to OSGB36 x and y using the proj.4 library.

Has anyone else successfully done this? I need to fill the srcPrj4String and destPrj4String variables, e.g.

string srcPrj4String = "+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs";

string destPrj4String = "+proj=utm +zone=11 +ellps=GRS80 +datum=NAD83 +units=m";

but I can't figure out the what the destPrj4String should be with OSGB36 - i know the datum should be +datum=OSGB36, but everything I try, doesn't work

Any ideas?

Many thanks in advance

leddy

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

再可℃爱ぅ一点好了 2024-08-11 23:42:22

谷歌搜索发现这个来自曼彻斯特大学地球学家约翰史蒂文森博士科学学术——如果有人做对了,谁应该做对。这是一个引用。


问题是转向 OSGB36 需要投影和
数据转换。在 2007 年 10 月之前,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 略有失真
投影(例如 WGS84 和 ETRS89)。这个偏移量很小,并且
仅对于更高精度的测量很重要。很多搜索关于
OSGB36 偏移量会显示与此相关的页面。如果你想
也弥补这一点
您可以下载 nadgrid 文件并使用它 。对于我的数据,这移动了
点相差约 1 m。

Googling turns up this from Dr John Stevenson, a Manchester University Earth Science academic - who should get it right if anyone does. Here's a quote.


The problem was that going to OSGB36 requires both a projection and a
datum conversion. Prior to October 2007, proj was only carrying
out the projection, thus resulting in the large offset. You can check
if you have the new version by running 'proj -v' or by looking at your
epsg file:

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  <> 

The new versions have +datum=OSGB36.

If you have an old version, you can correct it by replacing the line with:

+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 <> 

A complication is that OSGB36 is slightly distorted with respect to GPS
projections (such as WGS84 and ETRS89). This offset is small, and
is only important for higher precision surveying. Many searches about
OSGB36 offsets bring up pages relating to this. If you want to
compensate for this too,
you can download a nadgrid file and use it. For my data, this moved
the points by about 1 m.

萌酱 2024-08-11 23:42:22

明白了:

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";

干杯!

got it:

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";

cheers!

李白 2024-08-11 23:42:22

spatialreference.org 上的 EPSG:27700 提供了用于定义此值的各种字符串,包括 proj4 的字符串。

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

#!/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”方法,但这拒绝进行数据转换,导致所有内容都超出了 100m。似乎有必要使用“srcPrj”字符串和“transform”方法来进行数据转换。

另请参阅我的博客文章:用于从 WGS84 转换为英国地形测量局坐标系的 Ruby 代码? 其中包括用于执行相同操作的纯 Ruby 版本(不是 proj4)

EPSG:27700 on spatialreference.org gives various strings for defining this, including one for proj4.

Here is example code in ruby using the proj4 bindings :

#!/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"

The output:

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

So this is working accurately now. Originally I was trying just the 'destPrj' string, and calling the 'forward' method, but this refused to do the datum conversion, resulting everything being 100m out. It seemed to be necessary to use the 'srcPrj' string and the 'transform' method, to get the datum conversion happening.

See also my blog post: Ruby code for converting to UK Ordnance Survey coordinate systems from WGS84? which includes a pure ruby version (not proj4) for doing the same

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文