GridLocW - a Lat/Long to Maidenhead converter for Windows - with optional GPS support

{ GridLocW : Grid Locator (for) Windows }

{ Name derived from the various versions of Gridloc around on the web - most of which are DOS or BASIC (eg GWBASIC) releases }



A side issue from operating in the 2009 John Moyle Field Day was the fact that some operators - particularly home stations - did not know their (maidenhead) grid squares. 

To make it easier for any future field days, I wrote GridLocW - Grid Locator (for) Windows - in the pascal-based environment of "Delphi". That way, provided they can give me a latitude and longtitude, I can calculate it for them via software loaded on the logging PC - and then tell them as well - as using it in the log itself. Of course, it has a side benefit for any field day operators in that it has internal GPS support that can tell them exactly what grid square they are in - all they need to do is connect a suitable GPS to the PC via a serial port -and run GridLocW !

Best of all, it''s free !



The Maidenhead grid locator system divides the entire world into squares one degree (in latitude) by two degrees (in longitude). Each square is given a label, two letters followed by two numbers. You can determine grid locators in the Americas, Europe, Australia etc using various maps/tables/documents available on the internet. If those references are not handy, or you need a grid locator for some other spot around the world, just run the likes of GridLocWM.exe. GridLocWM will take any latitude and longitude and calculate the corresponding grid locator (eg "QG62"). By common usage, these locators are also called "Grid Squares".

For more precise location information, the Maidenhead system also allows an optional two characters to be appended to the 4 digit basic grid locator (eg. adding the letters "mj" to "QG62" to become "QG62mj" ). These two additional letters will pin a station's location down to within several kilometres and are usually listed in lower case. GridLocWM will handle the precise locator detail as well. Given the minutes and seconds of latitude and longitude (as well as the degrees), GridLocWN will display the precise locator.

A worldwide standard is that degrees South in Latitude is signed negative, as is degrees West longtitude, when dealing in calculations relating to lat/long conversions. GridLocWM doesn't really care if you use the identifiers + (plus) or a - (minus) or the letters N, S, E or W when describing any degrees parts.


While doing a bit of research on Latitude/Longtitude to Maidenhead converters, I discovered that the likes of the ARRL only have links to DOS-based converters on their web site and that led me to extract some code from a Delphi-based application that I have been using for some time. The result is a program that will will run on any 32 bit version of Windows - ie Win 2000 and up, does decimal or degrees/minutes/seconds cross-conversions as well as the Maidenhead grid squares.

To make it easier to use in some situations, I have written in some simple GPS support to determine latitude and longtitude details. Most GPS devices that output data to a serial port ( direct or via a serial/USB adapter) should work with this software. You will still need to press the "Convert" button to obtain your grid square details.. Hey, YOU have to do something.


The "Raw" tickbox allows part of the GPS data to be displayed so that you will find it easier to determine that you are on the correct COM port. Once you know, you will probably never use Raw again.


Please do not copy the file/s from this site and publish them on any other sites otherwise software revisions will not be apparent - and that means bugs will not be fixed in those versions. Always link to the actual files here so that any downloads come only from this site.



Basic program mode - manual entry of latitude and longtitude details into either the Decimal format boxes OR into the Degrees/ Minutes / Seconds boxes.

Pressing the Convert button fills in the empty boxes and calculated the Maidenhead grid square.

  • The Clear Dec button clears only the Decimal format boxes and Maidenhead grid
  • The Clear D/M/S button clears only the D/M/S format boxes and Maidenhead grid
  • The Clear All button clears all of the Lat/Long boxes and Maidenhead grid


GridLocW with GPS enabled

With GPS support enabled by using the tick box at the RHS top.
The details shown were derived using a Magellan Explorist 500 with it's USB adapter function but a Garmin GPS16 has also been tested and works correctly.



Please Note:

  • that GPS devices can have different message streams so may not display all of the available selections in the Raw GPS Data box.
  • the Time detail in some GPS data has decimals of seconds available while others do not.
  • just be sure that you have satellite acquisition BEFORE YOU COMPLAIN THAT THE GPS PART DOESN'T WORK !
  • The "Latest Version" button will take you to this web page provided that you have a valid internet connection at the time.

The functionality of GridLocW has been extended to include a UTC date display plus a "Clock Set" button to allow you
to set the computer clock from the GPS data, taking into account the time zone set on the PC.

To test it once you have GPS data available, double click on the Windows (2000, XP,+..) system clock (typically bottom RH corner of your screen),
change the time or date, Apply, then press the "Clock Set" button in GridLocW...

Watch the Windows clock snap back to the correct time/date..

This Clock Set function has been included to make it easier to determine/set the correct time on the computer when out Field Day'ing.


Just a hint : Read these words behind the "About GPS" button FIRST !

Repeated here....

GPS Support.


The GPS must be set to 4800 baud, 8 bits, 1 stop bit, no parity and can be connected to any COM port number - whether physical or virtual (eg from a serial to USB adapter). Simply select the apropriate detail from the Port dropdown box. The GPS brand should not be important but should be set to output NMEA data.

Only data is read from the port and if there is no data stream then the box marked GPS Time UTC will state "No GPS Data". Try any and or all COM ports and check for GPS data. If you add a USB-based com port after starting the software, use the "Recheck COM Ports" button to find any additional ports. "Raw" displays some of the basic data from the GPS, useful for confirming the correct port is selected.. If no GPS data is displayed, use the message drop-down to check for other messages. The most common problem is that the GPS does not have enough satellites to obtain a fix. On at least some GPS devices, if GGA and RMC are blank and GSV has data showing, no satellite fix !

Lat & Long values and the time & date should appear within 2 seconds of selecting the correct com port - it is not an immediate display. The Clock Set button allows you to set the computer system clock to the GPS time (+/- APPROX 0.5 sec) and takes into account your time zone setting.

The higher the number of satellites (Sats), the better the GPS position fix.

Always turn off the GPS support before unplugging any GPS device. If you get an error while using the GPS option, exit and re-start the software.

A few positioning maps have been implemented in more recent versions. The World map has an additional feature that shows Grid Locator plus Distance (in either KM (standard) or Statute Miles plus a bearing from the origin location. These latter values are generated using Vincenty's formula.

A conversion feature allows the entry of a Grid code in either 4 or 6 character format to calculate Latitude and Longtitude plus distance and bearing from the current Maidenhead locator code.

The ability to change from the standard Metric measurements to Imperial (height in feet, distances in Statute Miles) is available as a checkbox on the basic program panel.

The program's software settings deemed important are saved to the Windows registry on program exit and are thus available on subsequent uses.

Use the "About GPS" button again to remove this screen.


( right-click and Save Target As.. )
{ about 490KB }


(right-click and Save Target As.. )
{ about 260KB }
[ ZIP contains 1 file ]

THIS version is dated 20/3/2009 and is known to have some "bugs"....

There is greater error trapping included in the later releases !

Note - the above images may not show the current release date and all functions


For those of you who want "more", there is an additional version of GridLocW called GridLocWM which has a world map facility built-in - which works in two ways.

  • By having a Lat/Long value before launching the map by using the "Map" button on the primary application, it will spot the resultant Grid Square on the world map.
  • Alternatively, roving your mouse cursor over the map produces readouts of latitude, longtitude and grid square down the bottom of the display.

The displayed info from the cursor position is reasonably accurate however as the map is not perfect, there are some small errors noted - particularly towards the RH side. The textual info is correct.

Because the map graphic is included within the application, this version is considerably larger to download.
Note that map operation is inhibited on screen resolutions smaller than 1024 x 768 pixels.

This is what the main program screen looks like....

Grid Locator Windows - with Map

(Mouse over to see full size)


Note : in Australia, we use DD/MM/YY format so all dates quoted in documentation are this format.

As of the version dated 02/04/2009, there is also an Australian map option which is accessed by selecting the AUS box next to the map button.
Note that by the time places like Tasmania are accessed, the linearity of the map itself is not particularly good and some positioning errors are introduced,
this being a normal situation with Mercator-series maps. Unfortunately I have not located any suitable linear-scaled maps on the web.
( I could have removed Tassie but then some 'Taswegians' would have been upset. )

Minor changes at Version dated 15/5/09 : Added automatical recall of main program position, updated date formats to suit international users, last COM port, last map used etc.. plus a map of the USA & some of the Central Americas. Maps ( World, Aus, USA) are selected from a drop-down box at LHS. Size is now 4.7MB as an EXE, 1MB as a ZIP.

Minor changes at Version dated 16/5/09 : Added mouse pointer distance plus bearing from GPS location - featured only on World map - using Vincenty's formula. Added an extra checkbox on primary screen to allow display of Imperial measurements of GPS height and any distances (Metric is standard). Size is still around 4.7MB as an EXE, 1MB as a ZIP.

Minor changes at Version dated 19/5/09 : Added an entry box for a destination Maidenhead Grid plus a Calculate button to convert back to a Latitude and Longtitude (at the centre of the grid), plus a distance in Km (/ Statute Miles) and bearing in degrees FROM the main Calculated Grid value.

Minor changes at Version dated 20/5/09 : Added mouse pointer distance plus bearing from GPS location to the USA and Australian maps. When right-clicking on a map, a Summary box appears with the Lat/ Long/ Grid / Distance / Bearing values 'frozen'. The Summary box can be moved from over the map (to a clear part of screen) and subsequent left-clicks on alternate map areas will update the 'frozen' data. Added more error trapping for occasional floating point, COM and initial Windows registry startup errors.


Locator JJ00 is at 0 degrees latitude, 0 degrees longtitude and is the default marker placed when there are no Lat and Long values in the decimal degrees boxes.

AUS Map :

USA Map :

Other maps may be added in future releases IF I can find suitable linear map images.

( right-click and Save Target As.. )
{ about 4.8MB }


(right-click and Save Target As.. )
{ about 1000KB }
[ ZIP contains 1 file ]

Current version is dated 19/5/2009



No installation is necessary for either version, no setup.exe, no additional files. Just run GridLocW.exe / GridLocWM.exe from the folder it is saved/extracted into..

Free to download, free to use, but please - no copies on other websites.

If, perchance, your GPS does not decode correctly then use something like Windows HyperTerminal to capture some of the raw GPS serial output into a text file to email to me.
Please make sure that the device has a good satellite acquisition window by taking the unit to near a door, window or even outside.


Formatting/indentation of the Delphi code has been lost in the functions & procedure listed below, which is normal for web pages which only allow one space between characters & no tabs. Even so, those who need to should be able to copy and paste into a Delphi Unit for inclusion with their own code to create an application.


------------------------------------ Added 30 June 2009 ------------------------------------


For those who are seeking info/code on Vincenty's formula in Delphi :

//* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
//* Vincenty Inverse Solution of Geodesics on the Ellipsoid (c) Chris Veness 2002-2008, edited to suit Delphi 5 by Doug Hunter VK4ADC 2009 */
//* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

// * Calculate geodesic distance (in m) between two points specified by latitude/longitude
// * (in numeric degrees) using Vincenty inverse formula for ellipsoids
// Returns the distance as the function result, the forward azimuth in the var Azim in the calling variable.

// eg yy := distVincenty(strtofloat(form1.edit1.text), strtofloat(form1.edit2.text), strtofloat(form1.edit3.text), strtofloat(form1.edit4.text), zz);
// where edit1 & edit 2 are first Lat & Long (respectively) in decimal format, edit3 and edit 4 are second Lat & Long (respectively) in decimal format, returns distance in metres in yy (real), azimuth in degrees in zz (real), // */

function distVincenty(lat1, lon1, lat2, lon2 : real; var azim : real) : real;

a, b, c, f, U1, U2, uSq, sinU1, sinU2, CosU1, CosU2,lambda, lambdap, sinlambda, sinsigma, coslambda, cossigma, sigma, sinalpha, cosSqalpha, cos2sigmam, deltasigma : double;
l, aa, bb, s, rads, a1, a2 : real;
iterlimit : integer;

azim := 0;
rads := pi / 180;
a := 6378137; b := 6356752.3142; f := 1/298.257223563; // WGS-84 ellipsoid
L := (lon2-lon1)* rads;
U1 := arctan((1-f) * tan(lat1 * rads));
U2 := arctan((1-f) * tan(lat2 * rads));
sinU1 := sin(U1);
cosU1 := cos(U1);
sinU2 := sin(U2);
cosU2 := cos(U2);

lambda := L;
lambdaP := 100;
iterLimit := 100;
while (abs(lambda-lambdaP) > 1e-12) and (iterLimit>0) do
sinLambda := sin(lambda);
cosLambda := cos(lambda);
sinSigma := sqrt((cosU2*sinLambda) * (cosU2*sinLambda) +
(cosU1*sinU2-sinU1*cosU2*cosLambda) * (cosU1*sinU2-sinU1*cosU2*cosLambda));
if (sinSigma =0) then
begin // co-incident points
iterlimit := 0;
cosSigma := sinU1*sinU2 + cosU1*cosU2*cosLambda;
sigma := arctan2(sinSigma, cosSigma);
sinAlpha := cosU1 * cosU2 * sinLambda / sinSigma;
cosSqAlpha := 1 - sinAlpha*sinAlpha;
if (sinU1 <> 0) and (sinU2 <> 0) and (cosSqAlpha <> 0)
then cos2SigmaM := cosSigma - 2*sinU1*sinU2/cosSqAlpha
else cos2SigmaM := cosSigma;
if cos2SigmaM = 0 then
iterlimit := 0;
exit; // equatorial line: cosSqAlpha=0 (§6)
C := f/16*cosSqAlpha*(4+f*(4-3*cosSqAlpha));
lambdaP := lambda;
lambda := L + (1-C) * f * sinAlpha *
(sigma + C*sinSigma*(cos2SigmaM+C*cosSigma*(-1+2*cos2SigmaM*cos2SigmaM)));


if (iterLimit = 0) then result := 0
begin // formula failed to converge

uSq := cosSqAlpha * (a*a - b*b) / (b*b);
AA := 1 + uSq/16384*(4096+uSq*(-768+uSq*(320-175*uSq)));
BB := uSq/1024 * (256+uSq*(-128+uSq*(74-47*uSq)));
deltaSigma := BB*sinSigma*(cos2SigmaM+BB/4*(cosSigma*(-1+2*cos2SigmaM*cos2SigmaM)-
s := b*AA*(sigma-deltaSigma);

a1 := arctan2(cosU2*sinlambda, cosU1*sinU2 - sinU1*cosU2*coslambda);
a2 := arctan2(cosU1*sinlambda, -sinU1*cosU2 + cosU1*sinU2*coslambda);

// same lines as above but with different variable names to be declared globally

// fwdAz = arctan2(cosU2*sinLambda, cosU1*sinU2-sinU1*cosU2*cosLambda);
// revAz = arctan2(cosU1*sinLambda, -sinU1*cosU2+cosU1*sinU2*cosLambda);

azim := a1; // Forward azimuth in degrees, only really need this one
result := s; // distance in metres


For those who are seeking info/code on conversion of a Maidenhead Grid locator back to Latitude and Longtitude in Delphi :

// Again, not the neatest code I have encountered but certainly works.

Variables : mh = maidenhead in 4 or 6 charcater format, Lat : lat:6:2, Long : long:6:2

PROCEDURE maidenhead_to_latlong(mh : string; var lat,long : real);

var g1,g2,g3,g4,g5,g6 : integer;
g1s,g2s,g3s,g4s,g5s,g6s : char;
a,b,c,d : integer;
s1,s2,s3,s4 : string;
ge,te,gn,tn : real;

lat := 0;
long := 0;

a := length(mh);
if a < 4 then
lat := 0;
long := 0;

{ upper case}
for b := 1 to a do mh[b] := upcase(mh[b]);

{ separate chars of maidenhead code }
for b := 1 to a do
case b of
1 : g1s := mh[1];
2 : g2s := mh[2];
3 : g3s := mh[3];
4 : g4s := mh[4];
5 : g5s := mh[5];
6 : g6s := mh[6];

{ allow for last 2 chars to be missing}
if a = 4 then
g5 := 0;
g6 := 0;
g5s := chr(0);
g6s := chr(0);

g1 := ord(g1s) - 65;
g2 := ord(g2s) - 65;
g3 := ord(g3s) - 48;
g4 := ord(g4s) - 48;
g5 := ord(g5s) - 65;
g6 := ord(g6s) - 65;

ge := 20 * g1;
te := 10 * g2;
gn := 0;
tn := 0;
ge := ge + (2 * G3);
te := te + g4;
if a > 4 then
gn := g5 * 5;
if gn > 59 then ge := ge + 1;
if gn > 59 then gn := gn - 60;
tn := 2.5 * g6;

ge := int(ge - 180);
if ge < 0 then gn := 60 - gn;
if ge < 0 then
if g5 = 0 then ge := ge + 1;
gn := int(g5 div 5) * 5;

long:= (ge)+ (gn / 60);

te := int(te - 90);
if te < 0 then gn := 60 -gn;
if te < 0 then
if g5 = 0 then te := te + 1;
tn := int(tn / 2.5) * 2.5;

lat := (te) + (tn / 60);