Skip to content

This is a simple to use Geodetic Library for .Net that will allow simple transformation to and from British National Grid.

License

Notifications You must be signed in to change notification settings

IeuanWalker/GeoUK

Repository files navigation

Dependabot Codacy Badge FOSSA Status

This is port from GeoUK. I created this port to convert the project to .NET Standard

The original authors have created a blog post detailing how to use both NuGet packages - Converting Latitude and Longitude to British National Grid in C#. Please go and read this article to get a better understanding of the concepts used.

TIP: When working with locations i like to use this website - Grid reference finder

GeoUK Nuget Nuget

License: LGPL v3

Build Status

The project allows for a conversion from GPS coordinates to British National Grid and back again. The product is licensed under the GNU Lesser General Public License (LGPL).

GeoUK.OSTN Nuget Nuget

License: LGPL v3

Build Status

The GeoUk.OSTN project, adds OSTN02 and OSTN15 transformation which provide a greater accuracy. It should be noted that the this package contains the OSGM02 geoid and OSTN02 OSTN15 transformations, as a result is fairly large, in addition, transformations will be slower than using the Helmert transformations as used in the above nuget. The product is licensed under the GNU Lesser General Public License (LGPL).

How to use

Install GeoUK

Convert Easting/ Northing to Latitude/ Longitude

  1. Convert to Cartesian
// Given an easting and northing in metres (see text)
const double easting = 651409.903;
const double northing = 313177.270;

// Convert to Cartesian
Cartesian cartesian = Convert.ToCartesian(new Airy1830(),
    new BritishNationalGrid(),
    new EastingNorthing(easting, northing));
  1. Transform from OSBB36 datum to ETRS89 datum
Cartesian wgsCartesian = Transform.Osgb36ToEtrs89(cartesian); //ETRS89 is effectively WGS84
  1. Convert back to Latitude/Longitude
LatitudeLongitude wgsLatLong = Convert.ToLatitudeLongitude(new Wgs84(), wgsCartesian);

Convert Latitude/ Longitude to Easting/ Northing

LatitudeLongitude latLong = new LatitudeLongitude(51.469886, -3.1636964);

Cartesian cartesian = Convert.ToCartesian(new Wgs84(), latLong);
Cartesian bngCartesian = Transform.Etrs89ToOsgb36(cartesian);
EastingNorthing bngEN = Convert.ToEastingNorthing(new Airy1830(), new BritishNationalGrid(), bngCartesian); 

Get OS Map reference

The map references (Easting/Northing) used in Ordnance Survey maps are divided into 500km squares which are sub-divided into 100km squares. These squares are given a two letter code. The first letter represents the 500km square and the second represents the 100km square within it. A six digit map reference would look something like TL123456 where the first two characters represents the 100km square as indicated on the map with the first three digits of the six representing the easting and the last three digits representing the northing. Using this system means that a map reference is quoted as an easting/northing (in metres) from the square's origin. An EastingNorthing coordinate object, as returned from the transformation described above, can be converted to an OS map reference by using the Osgb36 class as follows:

EastingNorthing eastingNorthing = new EastingNorthing(319267, 175189);

Osgb36 osgb36EN = new Osgb36(eastingNorthing);
string mapReference = osgb36EN.MapReference;

Obtaining Greater Accuracy

In order to obtain greater accuracy when transforming ETRS89 (WGS84) coordinates to British National Grid, the Ordnance Survey Geoid Model (OSGM02) needs to be used. The OSGM02 can be thought of as a large rubber sheet covering Great Britain, Northern Island and the Republic of Ireland. Special transformations are applied to the data within the OSGM02 to transform from ETRS89 and OSGB36. For Great Britain, the transformation is called OSTN02. The OSTN02 transformations combined with the ETRS89 positions of active GPS network stations represents the official definition of OSGB36 and can give very accurate transformations.

This rubber sheet geoid is effectively a lookup table that can be used to determine Othometric (geoid) heights and, via the OSTN transformation, accurate Easting and Northing coordinates. It is worth noting that Northern Island and the Republic of Ireland use the same geoid model but with a different transformation (OSi/OSNI) which, for now at least, is outside of the scope of this article.

The GeoUK.OSTN Nuget package extends the GeoUK package to include OSGM02/OSTN0 and OSTN15 functionality and provides a simple method to make an accurate one-way transformation from ETRS89 to BNG. The package can be added to a project using the following Package Manager command. The package is dependent upon the GeoUK package and will add it as required.

Install GeoUK.OSTN

It should be noted that the GeoUK.OSTN package contains the OSGM02 geoid and OSTN02 OSTN15 transformations, as a result is fairly large, in addition, transformations will be slower than using the Helmert transformations as used in the examples above.

The example below converts an ETRS89 Latitude/Longitude/Ellipsoid height to BNG Easting and Northing and ODN Height to within 10 centimetres or so.

LatitudeLongitude latLong = new LatitudeLongitude(51.469886, -3.1636964, 108.05);
Osgb36 bng = GeoUK.OSTN.Transform.Etrs89ToOsgb(latLong);

License

Both NuGet packages are licenced under GNU Lesser General Public License (LGPL). This to respect the previous arthors licence. Learn more here.

License

FOSSA Status

About

This is a simple to use Geodetic Library for .Net that will allow simple transformation to and from British National Grid.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Sponsor this project

 

Packages

No packages published

Contributors 3

  •  
  •  
  •  

Languages