Git Product home page Git Product logo

britishnationalgrid.jl's Introduction

BritishNationalGrid

Build Status Coverage Status

Convert between WGS84 coordinates and British National Grid references

BritishNationalGrid provides the type BNGPoint to convert between longitude-latitude and grid references in the British National Grid system. It assumes your points are geodetic longitude and latitude in decimal degrees using the WGS84 ellipsoid.

This package is reliable to within a metre or so. Advanced users needing greater accuracy will probably already know how to convert between different systems, but any additions to the package that remain easy to use will be welcome.

Install

julia> import Pkg

julia> Pkg.add("BritishNationalGrid")

Use

Construct points in the grid using BNGPoint.

julia> using BritishNationalGrid

julia> p1 = BNGPoint(42513, 100231) # Full grid reference
BNGPoint{Int64}(42513, 100231)

julia> lonlat(p1) # Convert to longitude-latitude (°)
(-7.063648859478239, 50.69155306935914)

julia> p2 = BNGPoint(lon=0.32, lat=51.0) # Construct point from lon-lat
BNGPoint{Float64}(562885.4557430055, 124851.2191743746)

julia> p3 = BNGPoint(00123, 51422, "TA") # Construct from 100 km square name
BNGPoint{Int64}(500123, 451422)

Get a formatted grid reference:

julia> gridref(p1, 10) # 10-figure grid reference
"04251 10023"

julia> gridref(p2, 6, true) # 6-figure reference within the 100 km square TQ
"TQ 628 248"

Find the 100 km square in which a point lies:

julia> square(p3)
"TA"

Direct (unchecked) lon-lat ↔ easting-northing conversion

The lonlat2bng and bng2lonlat functions convert directly between the two coordinate systems, but do not check that points are actually in the National Grid; therefore use these functions with caution.

julia> lon, lat = -3.183503, 55.954983;

julia> lonlat2bng(lon, lat)
(326200.06052230217, 674183.9198954724)

julia> bng2lonlat(175154, 225430)
(-5.268407238735794, 51.88199105278528)

Todo

Other ways to convert to the British National Grid

  • Use the Ordnance Survey's online converter. This also includes links to the OS's Pascal programs to do coordinate transforms.
  • Use the British Geological Survey's online converter, which also assumes WGS84 longitude and latitude.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.