If you were Registered and logged in, you could reply and use other advanced thread options
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
convert regular British National Grid coordinates (6 digit easting and
northing coordinates) to OS NGCs (e.g. TL5467 6723)?
Regards,
AndyB
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
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
Else
SecondLet = CHR$(ASC("A")+(x+5*(4-y)))
End If
GetTileLetters = FirstLet + SecondLet
End Function
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
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
Thanks Greg,
It sounds perfect.
greg.driver@btinternet.com wrote in message
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
>
> 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
- Read / convert ESRI grid raster files with open source client?
- Geographic Information Systems (GIS)
- 2006-05-27
- Satnav that accepts input in UK BNG (Ordnance Survey) Grid reference ++INSIDE
- UK GPS Discussions
- 2010-01-01
- Nuvi 700/200/600 Series - Coordinates
- Garmin GPS
- 2008-01-13
- coordinates
- Garmin GPS
- 2007-10-14





