Bookmark this page: Add E N coordinates convert to GB OS National Grid Sheet Coordinates to Yahoo MyWeb Add E N coordinates convert to GB OS National Grid Sheet Coordinates to Google Bookmarks Add E N coordinates convert to GB OS National Grid Sheet Coordinates to Windows Live Add E N coordinates convert to GB OS National Grid Sheet Coordinates to Del.icio.us Digg E N coordinates convert to GB OS National Grid Sheet Coordinates! Add E N coordinates convert to GB OS National Grid Sheet Coordinates to Netscape
  •  
  • Subject
  • Author
  • Date
If you were  Registered and logged in, you could reply and use other advanced thread options
Posted by Andy B on April 7, 2005, 12:18 am
Anybody know where i can get my hands on a conversion function to
convert regular British National Grid coordinates (6 digit easting and
northing coordinates) to OS NGCs (e.g. TL5467 6723)?

Regards,
AndyB


Posted by greg.driver on April 11, 2005, 1:39 pm
Andy,

This is a MapBasic function (Mapinfo scripting language) that I've
written to do what you want:
<-------
'// function to return the tile letters (ie SU) given the x,y coords
Function GetTileLetters(ByVal szXcoord As Float, ByVal szYcoord As
Float) as String
Dim x, y As Float
Dim FirstLet, SecondLet As String
szXcoord = szXcoord + 1000000
szYcoord = szYcoord + 500000

'// do the 500km squares first
x = (szXcoord/500000) MOD 5
y = (szYcoord/500000) MOD 5

If (ASC("A")+(x+5*(4-y))) >= ASC("I") Then
FirstLet = CHR$(ASC("A")+(x+5*(4-y))+1)
Else
FirstLet = CHR$(ASC("A")+(x+5*(4-y)))
End If

'// do the 100km squarea
x = (szXcoord/100000) MOD 5
y = (szYcoord/100000) MOD 5

If (ASC("A")+(x+5*(4-y))) >= ASC("I") Then
SecondLet = CHR$(ASC("A")+(x+5*(4-y))+1)
Else
SecondLet = CHR$(ASC("A")+(x+5*(4-y)))
End If

GetTileLetters = FirstLet + SecondLet

End Function
------->
ASC() returns the ASCII character code - ASC("A") = 65
CHR$() returns the character-string of the corresponding ASCII code -
CHR$(65) = "A"

I got it from somewhere on the web but can't remember where.

Let me know if you need anything clarifying.

Gref



Posted by Andy B on April 24, 2005, 1:02 pm
Thanks Greg,
It sounds perfect.

greg.driver@btinternet.com wrote in message
> Andy,
>
> This is a MapBasic function (Mapinfo scripting language) that I've
> written to do what you want:
> <-------
> '// function to return the tile letters (ie SU) given the x,y coords
> Function GetTileLetters(ByVal szXcoord As Float, ByVal szYcoord As
> Float) as String
> Dim x, y As Float
> Dim FirstLet, SecondLet As String
> szXcoord = szXcoord + 1000000
> szYcoord = szYcoord + 500000
>
> '// do the 500km squares first
> x = (szXcoord/500000) MOD 5
> y = (szYcoord/500000) MOD 5
>
> If (ASC("A")+(x+5*(4-y))) >= ASC("I") Then
> FirstLet = CHR$(ASC("A")+(x+5*(4-y))+1)
> Else
> FirstLet = CHR$(ASC("A")+(x+5*(4-y)))
> End If
>
> '// do the 100km squarea
> x = (szXcoord/100000) MOD 5
> y = (szYcoord/100000) MOD 5
>
> If (ASC("A")+(x+5*(4-y))) >= ASC("I") Then
> SecondLet = CHR$(ASC("A")+(x+5*(4-y))+1)
> Else
> SecondLet = CHR$(ASC("A")+(x+5*(4-y)))
> End If
>
> GetTileLetters = FirstLet + SecondLet
>
> End Function
> ASC() returns the ASCII character code - ASC("A") = 65
> CHR$() returns the character-string of the corresponding ASCII code -
> CHR$(65) = "A"
>
> I got it from somewhere on the web but can't remember where.
>
> Let me know if you need anything clarifying.
>
> Gref