{"id":23453,"library":"convertbng","title":"convertbng","description":"Convert latitude/longitude to and from British National Grid (OSGB36) / ETRS89 coordinates using the OS OSTN15 transform. The library is powered by Rust FFI for high performance. Current version 0.7.11, requires Python >=3.10. Released irregularly.","status":"active","version":"0.7.11","language":"python","source_language":"en","source_url":"https://github.com/urschrei/convertbng","tags":["coordinates","geospatial","british-national-grid","ostn15","rust","gis"],"install":[{"cmd":"pip install convertbng","lang":"bash","label":"Install from PyPI"}],"dependencies":[{"reason":"Inputs and outputs are numpy arrays; required for all operations.","package":"numpy","optional":false}],"imports":[{"note":"Functions are in convertbng.util, not top-level.","wrong":"from convertbng import convert_lonlat_to_bng","symbol":"convert_lonlat_to_bng","correct":"from convertbng.util import convert_lonlat_to_bng"},{"note":"Functions are in convertbng.util, not top-level.","wrong":"from convertbng import convert_bng_to_lonlat","symbol":"convert_bng_to_lonlat","correct":"from convertbng.util import convert_bng_to_lonlat"}],"quickstart":{"code":"import numpy as np\nfrom convertbng.util import convert_lonlat_to_bng, convert_bng_to_lonlat\n\n# Example coordinates (lon, lat)\nlon = np.array([-0.1276, -2.0])\nlat = np.array([51.5074, 53.0])\n\n# Convert to BNG (returns (easting, northing) tuple of numpy arrays)\neasting, northing = convert_lonlat_to_bng(lon, lat)\nprint(easting, northing)\n\n# Convert back to lon/lat\nlon_back, lat_back = convert_bng_to_lonlat(easting, northing)\nprint(lon_back, lat_back)","lang":"python","description":"Convert between longitude/latitude and British National Grid coordinates. Inputs must be numpy arrays."},"warnings":[{"fix":"Install Rust via https://rustup.rs/ or use a conda-forge build: conda install -c conda-forge convertbng","message":"Installation may require Rust toolchain (rustc and cargo) if no precompiled wheel is available for your platform. This can cause cryptic errors on some systems.","severity":"breaking","affected_versions":"all"},{"fix":"Always convert inputs to numpy arrays: np.array(values, dtype=np.float64)","message":"Input must be numpy arrays of float64 type. Passing lists or other dtypes will raise TypeError or produce wrong results.","severity":"gotcha","affected_versions":">=0.7.0"},{"fix":"Validate results using np.isnan(easting) or similar.","message":"Coordinates outside the British National Grid coverage area (approx. 49°N–61°N, 8°W–2°E) will return NaN. Error handling not built-in; check for NaN yourself.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Use `from convertbng.util import convert_lonlat_to_bng`.","cause":"Incorrect import path; users try `from convertbng import convert_lonlat_to_bng`.","error":"ImportError: No module named 'convertbng.util'"},{"fix":"Wrap inputs in numpy arrays: np.array(lons, dtype=np.float64).","cause":"Passing a Python list directly instead of a numpy array.","error":"TypeError: float() argument must be a string or a number, not 'list'"},{"fix":"Cast arrays to float64: arr.astype(np.float64).","cause":"Input array dtype is float32; the Rust backend expects float64.","error":"ValueError: Buffer dtype mismatch, expected 'float64' but got 'float32'"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}