Click here to get back home

E,N coordinates convert to GB OS National Grid Sheet Coordinates

 HomeNewsGroups | Search | About
 comp.infosystems.gis    Post an article   get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
E,N coordinates convert to GB OS National Grid Sheet Coordinates Andy B 04-07-2005
Get Chitika Premium
Posted by Andy B on April 7, 2005, 12:18 am
Please log in for more 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


Posted by greg.driver on April 11, 2005, 1:39 pm
Please log in for more thread options
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
Please log in for more thread options
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


Similar ThreadsPosted
Grid Coordinates to UTM October 14, 2005, 7:20 am
What are UNI and UFI coordinates? How to convert them? April 24, 2008, 11:10 am
Accessing X, Y coordinates February 18, 2005, 1:48 pm
Lat/Long Coordinates?? March 8, 2005, 12:57 am
US-CAN border coordinates April 26, 2005, 7:07 am
Centroids GPS coordinates November 26, 2008, 10:28 am
which SRID for coordinates in PostGIS ? February 3, 2005, 9:41 am
Extracting street coordinates from a map April 20, 2008, 9:04 am
Converting cartesian coordinates to geographical gps December 15, 2008, 4:22 am
calculate coordinates of points given a matrix of distances May 13, 2005, 12:58 pm

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap