PROJ.4 library and 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 done this successfully? I need to populate srcPrj4String and destPrj4String variables, for example.

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 understand what should be with destPrj4String with OSGB36 - I know that the datum should be + datum = OSGB36, but everything I try does not work

Any ideas?

Thank you very much in advance

Leddy

+6
gis proj4js proj4
source share
3 answers

got:

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

Hooray!

+4
source share

Googling discovers this from Dr. John Stevenson, an academician at the Academy of Sciences of the University of Manchester, who must get it right if someone does it. Here is a quote.


The problem was that OSGB36 required both projection and datum transformation . Until October 2007, proj only carried projection, which leads to a large displacement. You can check if you have a 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 <> 

In new versions there is + datum = OSGB36.

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

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

The difficulty is that OSGB36 is slightly distorted relative to GPS (for example, WGS84 and ETRS89). This offset is small and important only for more accurate shooting. Many OSGB36 Offset searches bring up pages associated with this. If you want to compensate for this too, you can download the nadgrid file and use it . According to my data, these are points at about 1 m.

+6
source share

EPSG: 27700 on surroundreference.org contains various lines for defining this, including for proj4.

Here is a sample code in ruby using 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" 

Exit:

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

So now it works for sure. Initially, I tried to use only the string "destPrj" and called the method "forward", but it refused to perform the zero point conversion, resulting in everything being 100 m. It seems that you need to use the string 'srcPrj' and the 'transform' method to get the zero conversion points.

See also my blog post: Ruby code to convert to UK Ordnance Survey coordinate system from WGS84? which includes a clean ruby ​​version (not proj4) to do the same

+1
source share

All Articles