Fast lon, lat to and from ETRS89 and BNG (OSGB36) using Rust FFI
Project description
Description
Accuracy
convertbng and convertlonlat use the standard seven-step Helmert transform to convert coordinates. This is fast, but not particularly accurate – it can introduce positional error up to approximately 7 metres. For most applications, this is not of particular concern – the input data (especially those originating with smartphone GPS ) probably exceed this level of error in any case.
OSTN02
If greater accuracy is required, you may use the OSTN02-enabled functions, which use OSTN02 data for highly accurate conversions from ETRS89 latitude and longitude or ETRS89 Eastings and Northings to OSGB36 Eastings and Northings, and vice versa. These data will usually have been recorded using the National GPS Network:
Use ``convert_osgb36(lons, lats)`` to convert ETRS89 Longitudes and Latitudes to OSGB36
Use ``convert_osgb36_to_lonlat(eastings, northings)`` to convert OSGB36 Eastings and Northings to ETRS89 longitudes and latitudes
Use ``convert_etrs89_to_osgb36(eastings, northings)`` to convert ETRS89 Eastings and Northings to OSGB36 Eastings and Northings
Use ``convert_osgb36_to_etrs89(eastings, northings)`` to convert OSGB36 eastings and Northings to ETRS89 Eastings and Northings.
Accuracy of the OSTN02 transformation used in this library
ETRS89 longitude and latitude / Eastings and Northings to OSGB36 conversion agrees with the provided Ordnance Survey test data in 31 of the 42 test coordinates (excluding two coordinates designed to return no data). The 11 discrepancies are of 1mm in each case.
OSGB36 to ETRS89 longitude and latitude conversion is accurate to within 8 decimal places, or 1.1mm.
Implementation
Installation
pip install convertbng
Note
convertbng is currently only available in Wheel format for OSX, though standard installation for *nix using pip from PyPI works, and doesn’t require a Rust installation.
Usage
All functions try to be liberal about what containers they accept: list, tuple, array.array, numpy.ndarray, and pretty much anything that has the __iter__ attribute should work, including generators.
from convertbng.util import convertbng, convertlonlat
# convert a single value
res = convertbng(lon, lat)
# convert lists of longitude and latitude values to BNG Eastings and Northings
lons = [lon1, lon2, lon3]
lats = [lat1, lat2, lat3]
res_list = convertbng(lons, lats)
# convert lists of BNG Eastings and Northings to longitude, latitude
eastings = [easting1, easting2, easting3]
northings = [northing1, northing2, northing3]
res_list_en = convertlonlat(eastings, northings)
# assumes numpy imported as np
lons_np = np.array(lons)
lats_np = np.array(lats)
res_list_np = convertbng(lons_np, lats_np)
Building the binary for local development
ensure you have Rust 1.x and Cargo installed
clone https://github.com/urschrei/lonlat_bng, and ensure it’s adjacent to this dir (i.e. code/witnessme/convertbng and code/witnessme/rust_bng)
in this dir, run make clean then make build
Tests
License
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for convertbng-0.3.2-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f84659f124659830b8cae72df9090cafbfee71a674e407058028e785feb2ae68 |
|
MD5 | ca8aa17dce55e2c2df56c172d4ef3cfb |
|
BLAKE2b-256 | ea97c6c8e1a4569be50c864b472d21d67af99441111bd8c5b0cc384401ee5cd1 |