| Overview | How to use... Windows | How to use... UNIX |
The National Grid Converter converts Ordnance Survey grid references into pairs of coordinates. Files of coordinate pairs are useful as they can be easily geocoded by a GIS into a data layer of points.
Grid Reference | Precision |
---|---|
TA | 100 km by 100 km square |
TA04 | 10 km by 10 km square |
TA04SW | 5 km by 5 km square |
TA0343 | 1 km by 1 km square |
TA0343SW | 500m by 500m square |
TA034434 | 100m by 100m square |
TA03434340 | 10m by 10m square |
TA0343543405 | 1m by 1m square |
Table 1: Grid references
Grid references show a range of precisions, all of which can be processed by the converter into coordinates (given in metres). For more details see the National Grid References page. Two versions of the National Grid Converter are available: one for use with Windows and one for use on a UNIX platform.
| Overview | How to use... Windows | How to use... UNIX |
The National Grid Converter is available free to Digimap users. To download the NGConv.exe file simply right click on the link below and save it to your computer in a suitable location (e.g. C:\NGConv).
Once downloaded, the program can be activated by double clicking on the icon in Windows Explorer or from the Run prompt in the start menu. If you have a list of grid references in a text file, this can be dragged and dropped onto the desktop icon as explained below. The converter can output a range of coordinates for each grid square depending on the options selected. The following sections explain how to use the converter in a range of situations.To convert a grid reference to a coordinate pair double click on the NGConv.exe icon; a DOS prompt should open as shown in figure 1. Type in your grid reference and press return to get the coordinates of the southwest corner of the square. Your new coordinate pair is given in metres.
Figure 1: DOS Interface, here the grid reference TA034434 has been entered and the coordinates 503400, 443400 have been returned.
If you require coordinates for a different corner of the grid square or for its centre then the program needs to be started from the Run prompt in the start menu as shown in figure 2. To do this you need to know the location of NGconv.exe i.e. its file path. Type the file path followed by NGconv and the options that you want. For example:
Figure 2: Run Interface
The command displayed in Figure 2 accesses the converter from a folder called ngc on the D drive; it also sets up the converter to return the coordinates from the centre or mid point of the square defined by the grid reference. There are several other point options outlined below:
By starting the converter with one of these options all the coordinates generated in that session will be for the point specified in the command. The converter will look exactly the same as the one started by double clicking the icon but will produce results dependent on the options set.
To convert a list of grid references they should be saved as a text (.txt) file with each grid reference on a new line. Drag the icon and drop it on to the NGConv.exe icon and a comma separated value file (.csv) file containing a list of coordinates for the southwest corner will be created. The csv file is automatically created in the same file as the source text file and given the same name with an additional _en appended to it as shown in Figure 3.
Figure 3: Dragging and dropping the gridref.txt icon on the NGconv.exe icon will create the gridref_en.csv file.
To change these default settings the converter will need to be started from the Run prompt in the start menu. To do this you need to know the location of NGconv.exe (its file path). It also helps to store your text file of grid references (gridref.txt in this example) in the same folder as the NGConv application is stored. Type the file path followed by NGconv and the options that you want, then the name of the text file containing the list of grid references. For example:
D:\ngc\ngconv -includengr gridref.txt
This command accesses the converter from a folder called ngc on the D drive; it will also set up the converter to include the grid references in the csv file with the coordinates. The grid references will be read from the file gridref.txt which is in the same folder as the converter.
As well as varying the point to output as outlined in the single grid reference section above there are other options available when outputting data to a csv file.
D:\ngc\ngconv -o coords.csv D:\ngc\textfiles\gridref.txtThis command will run the converter from the folder ngc, it will use gridref.txt from the textfiles folder and will create a new coordinates file called coords.csv in the ngc folder.
Note: You must specify full pathnames for the files. If you specify a path for the input file and you want to change the name of the output file you need to specify a path name for this too to avoid it being placed in the same folder as the converter.
| Overview | How to use... Windows | How to use... UNIX |
The National Grid Converter is available free to Digimap users as a PERL script. To download the NGConv.pl file simply right click on the link below and save it to your computer in a suitable location.
To run the PERL version of the converter your UNIX machine must have a version of PERL installed. Create a directory and download the NGconv.pl file from the Digimap help pages. Make the file executable with the command:chmod 755 NGconv.plThe converter can be used for quick queries, converting grid references as they are typed in at the prompt. It is also possible to use the converter to produce files of coordinates from lists of grid references. The following sections outline how the converter can be used for such operations. For usage options enter:
NGconv.pl -help,this will bring up the information shown in Figure 4 below.
Figure 4: Usage options.
If perl is not located at /usr/bin/perl but is in the path then it can be run as:
perl NGconv.pl -helpYou will need to type perl before running the converter at all times.
To convert a grid reference to a coordinate type:
NGconv.plYou will be prompted for a grid reference and the coordinate pair will be returned once you enter it as shown in Figure 5.
Figure 5: UNIX Interface, here the grid reference TA034434 has been entered and the coordinates 503400, 443400 have been returned.
To vary the point the converter produces coordinates you can start the converter with one of the point options outlined below:
The converter can be used to convert lists of grid references to coordinates if they are saved as a text (.txt) file with each grid reference on a new line. To convert the file you need to specify its name and location when starting the converter as shown below:
NGconv.pl textfiles\gridref.txt
This example would read the gridref.txt file from the textfiles folder. By default the grid references will be converted into coordinate pairs in a .csv file. The csv file is automatically created in the same folder as the source text file and given the same name with an additional _en appended to it, gridrefs_en.csv in this example. While the file is being written the entries are displayed on screen by default, for larger files it may be best to set the option -v so only a dot is displayed for each grid reference converted. Using the -vv will display the grid reference and the coordinate pairs for each conversion.
Figure 6: Working display options
To add the grid references into the .csv file as an initial value before the coordinate pair, use the -includengr option. Figure 7 shows the difference between two .csv files created with and without the -includengr option.
Figure 7: .csv files created without (left) and with (right) the -includengr option
The -o option allows you to specify a name for the output file; you can also specify a path for the file placing it in a different folder from the text file.
All these options can be used in conjunction with each other as in the example shown below:
NGconv -v -o csvfiles\coords.csv textfiles\gridref.txtIn this example the grid references would be read from a file called gridref.txt in the text files folder; the coordinate pairs would be written into a file called coords.csv in the csvfiles folder. Only a series of dots would be written to the screen to indicate how many grid references had been converted.