A library to convert BNG/OSNG coordinates
Project description
PyBNG
An Ordinance-Survey National Grid coordinates converter
Getting Started
PyBNG is built on top of OSGridConverter and is used to convert coordinates from the Ordnance Survey National Grid system (often called the British National Grid -- BNG) to latitude and longitude using WGS84 (other geodetic reference systems available).
While OSGridConverter can convert BNG to latitude and longitude, it does not support all-numeric grid references, which is the primary feature in this library.
Installation
PIP (recommended)
pip install PyBNG
Manual Installation
Simply clone the entire repo and extract the files in the PyBNG folder, then copy all the content to your project folder
Or use one of the shorthand methods below
GIT
cdinto your project directory- Use
sparse-checkoutto pull the library files only into your project directorygit init PyBNG cd PyBNG git remote add -f origin https://github.com/ThunderStruct/PyBNG.git git config core.sparseCheckout true echo "PyBNG/*" >> .git/info/sparse-checkout git pull --depth=1 origin master
- Import the newly pulled files into your project folder
SVN
cdinto your project directorycheckoutthe library filessvn checkout https://github.com/ThunderStruct/PyBNG/trunk/PyBNG
- Import the newly checked out files into your project folder
Usage
Initialization
A PyBNG object can be instantiated as follows:
from PyBNG import PyBNG
bng = PyBNG(easting=519080, northing=185050)
latlon = PyBNG(lat=51.55178424773851, lon= -0.2835125528796557)
The initializer expects easting and northing OR lat and lon parameters, depending on the required conversion
Methods
get_latlon(datum='WGS84'):- Description: calculates the latitude and logitude based on the given BNG coordinates
- Parameters: none (passed to constructor)
- Return Value: tuple -- (latitude, longitude)
- Usage:
from PyBNG import PyBNG bng = PyBNG(easting=519080, northing=185050) bng.get_latlon() # (51.55178424773851, -0.2835125528796557)
get_bng(datum='WGS84'):- Description: calculates the BNG coordinates given a latitude and a longitude
- Parameters: none (passed to constructor)
- Return Value: typle -- (easting, northing)
- Usage:
from PyBNG import PyBNG latlon = PyBNG(lat=51.55178424773851, lon= -0.2835125528796557) latlon.get_bng() # (519107, 185051)
Please note that converting BNG coordinates to latitude/longitude and back to BNG will yield different results due to internal float rounding
Acknowledgment
I would like to thank Dr. Lakshmi Babu-Saheer for her unwavering support, encouragement, and advice.
License
This project is licensed under the MIT License - see the LICENSE file for details
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pybng-0.2.0.tar.gz.
File metadata
- Download URL: pybng-0.2.0.tar.gz
- Upload date:
- Size: 7.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6789d244a5b6ec514daa247445c25b988ed0bb3c2119c183e7d041a6684a26be
|
|
| MD5 |
7934f357e25e99118033a5ba62eb0d49
|
|
| BLAKE2b-256 |
8d72c75ca8164a7ee17ed07c301477d72694515486ac30659c71ff0d7cca32b0
|
File details
Details for the file pybng-0.2.0-py3-none-any.whl.
File metadata
- Download URL: pybng-0.2.0-py3-none-any.whl
- Upload date:
- Size: 8.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
510671d14a76043fb098d5acd3e6b5dc8fb84bd4ab73cd246eb589e5cd32b3de
|
|
| MD5 |
8131c4b284e953b86aa17d07397ca737
|
|
| BLAKE2b-256 |
d4cc7b0ab808d710d132daeb5eb109584626c3740b652191683e628ea1ee7413
|