Purpose
Converts a string representing an USNG (United States National Grid) coordinate into a point object in the current MapBasic coordinate system. You can call this function from the MapBasic window in MapInfo Pro.
Syntax
USNGToPoint( string )
string is a string expression representing a USNG grid reference.
Return Value
Object.
Description
The returned point will be in the current MapBasic coordinate system, which by default is Long/Lat (no datum). For the most accurate results when saving the resulting points to a table, set the MapBasic coordinate system to match the destination table's coordinate system before calling USNGToPoint(). This will prevent MapInfo Pro from doing an intermediate conversion to the datumless Long/Lat coordinate system, which can cause a significant loss of precision.
Example 1
dim obj1 as Object
dim s_USNG As String
dim obj2 as Object
obj1 = CreatePoint(-74.669, 43.263)
s_USNG = PointToUSNG$(obj1)
obj2 = USNGToPoint(s_USNG)
Example 2
Open Table "C:\Temp\MyTable.TAB" as USNGfile
' When using the PointToUSNG$() or USNGToPoint() functions,
' it is very important to make sure that the current MapBasic
' coordsys matches the coordsys of the table where the
' point object is being stored.
'Set the MapBasic coordsys to that of the table used
Set CoordSys Table USNGfile
'Update a Character column (for example COL2) with USNG strings from
'a table of points
Update USNGfile
Set Col2 = PointToUSNG$(obj)
'Update two float columns (Col3 & Col4) with
'CentroidX & CentroidY information
'from a character column (Col2) that contains USNG strings.
Update USNGfile
Set Col3 = CentroidX(USNGToPoint(Col2))
Update USNGtestfile ' USNGfile
Set Col4 = CentroidY(USNGToPoint(Col2))
Commit Table USNGfile
Close Table USNGfile
See Also:
PointToUSNG$(obj, datumid)