https://github.com/mjjbell/go-osgb
Accurate conversion between OS National Grid and GPS coordinates
https://github.com/mjjbell/go-osgb
geotools go golang gps-coordinates national-grid ordnance-survey transformations
Last synced: 6 months ago
JSON representation
Accurate conversion between OS National Grid and GPS coordinates
- Host: GitHub
- URL: https://github.com/mjjbell/go-osgb
- Owner: mjjbell
- License: bsd-2-clause
- Created: 2017-04-27T23:05:47.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2021-06-18T12:21:37.000Z (over 4 years ago)
- Last Synced: 2025-04-10T01:04:38.971Z (6 months ago)
- Topics: geotools, go, golang, gps-coordinates, national-grid, ordnance-survey, transformations
- Language: Go
- Size: 38.3 MB
- Stars: 5
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
go-osgb
============[](https://godoc.org/github.com/mjjbell/go-osgb)
A Go library for performing accurate conversions between OS National Grid and GPS coordinates. (More technically, coordinate transformations between the OSGB36/ODN and ETRS89 geodetic datums)
Why would I need this?
------------
Geodetic transformations that assume perfect geometry lose precision on imperfect geoids (e.g. The Helmert transformation for ETRS89 to OSGB36/ODN has errors up to 5m). This library implements the definitive transformation developed by Ordnance Survey for converting between National Grid and GPS coordinates, resulting in very accurate conversions (average < 0.1m error).Features
------------
- Supports OSTN02/OSGM02 and OSTN15/OSGM15 transformations
- All transformation parameters are included in the library. No need to load additional files!
- Fully tested against the conversion samples provided in the Ordnance Survey developer resourcesInstallation
------------
go get github.com/mjjbell/go-osgbUsage
------------
Converting from National Grid to GPS
```go
import (
"log"osgb "github.com/mjjbell/go-osgb"
)func main() {
trans, err := osgb.NewOSTN15Transformer()
if err != nil {
log.Fatal(err)
}
easting := 400001.4
northing := 305001.4
height := 5.0
nationalGridCoord := osgb.NewOSGB36Coord(easting, northing, height)
gpsCoord, err := trans.FromNationalGrid(nationalGridCoord)
if err != nil {
log.Fatal(err)
}
log.Printf("%#v\n", gpsCoord)
// &osgb.ETRS89Coordinate{Lon:-2.001408181413446, Lat:52.64276984554203, Height:55.34172940576156}
}
```Converting from GPS to National Grid
```go
import (
"log"osgb "github.com/mjjbell/go-osgb"
)func main() {
trans, err := osgb.NewOSTN15Transformer()
if err != nil {
log.Fatal(err)
}lon := -0.1262
lat := 51.5080
height := 10.5
gpsCoord := osgb.NewETRS89Coord(lon, lat, height)
nationalGridCoord, err := trans.ToNationalGrid(gpsCoord)
if err != nil {
log.Fatal(err)
}
log.Printf("%#v\n", nationalGridCoord)
// &osgb.OSGB36Coordinate{Easting:530136.3274244666, Northing:180449.45428526515, Height:-35.04663654446814}
}
```Coordinate Units
------------
National Grid eastings, northings and ODN height are all in metres.
GPS longitude and latitude are in decimal degrees. Height is in metres.Transformation Limits
------------
The transformation is only accurately defined for onshore positions of British Islands.When using OSTNO2, transformations attempted for positions greater than 10km offshore will return an `ErrPointOutsidePolygon` error.
OSTN15 will not return an error for offshore transformations, but precision is severely degraded, so usage is not recommended. However, straying outside the extents of the 700x1250km transformation grid completely will lead to an `ErrPointOutsideTransformation` error.
I want to know more about the transformation
------------
The full details can be found in the [developers section](https://www.ordnancesurvey.co.uk/business-and-government/help-and-support/navigation-technology/os-net/formats-for-developers.html) of the Ordnance Survey website.Roadmap
------------
- [ ] Expose geoid regions for ODN heights
- [ ] Support transformations on the Irish mainlandLicense
------------
This library is released under the BSD license, as are the transformation models provided by Ordnance Survey. Full details can be found in the LICENSE file.