Version 5 (modified by iopa, 9 years ago) (diff)

--

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 when calling nextmapdem.sh so that any intervening tiles are also included in the generation of the dem file. demgen.py can be used to produce a list of tiles in the same format as gettiles.sh


  1. 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).

  1. 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)

Download all attachments as: .zip