Converting lat/long to BNG
The point of writing this code was to have a fast way to scan all the eagle/hawk header files for a project and use the co-ordinates from them to determine the UK OS grid squares they covered. To do this, run gettiles.sh in the base project directory and it'll go do it for you. The steps it goes through are below and can be used for other conversions.
Note that this only prints out the end tiles of the flight lines - the lines may also include intervening tiles that are not printed, which is why gettiles.sh has been replaced by demgen.py so that any intervening tiles are also discovered. demgen.py can be used to produce a list of tiles in the same format as gettiles.sh
- Use Proj to convert lat/long to BNG co-ordinates:
proj +proj=tmerc +ellps=airy +lat_0=49 +lon_0=-2 +x_0=400000 +y_0=-100000 +k=0.9996012717
Then once that's running you enter the lat/long to be converted at the prompt in x y format (ie long then lat) and it will return transverse mercator co-ordinates in the BNG co-ordinate system (still have to convert to the right OS grid square though).
- Run bnglookup.py to convert this to grid squares:
python bnglookup.py eastings northings
(Note this requires alphaconv.py)
ll2bng.sh runs steps 1 and 2 on a specific set of coordinates:
ll2bng.sh latitude longitude
This accepts any Proj.4 format lat/lon
Attachments (4)
- alphaconv.py (5.2 KB) - added by benj 17 years ago.
- bnglookup.py (2.4 KB) - added by benj 17 years ago.
- gettiles.sh (965 bytes) - added by benj 17 years ago.
- ll2bng.sh (399 bytes) - added by benj 17 years ago.
Download all attachments as: .zip