Managing the Coordinate System of the Map - MapBasic - 2023

MapInfo MapBasic Reference

Product type
Software
Portfolio
Locate
Product family
MapInfo
Product
MapInfo > MapBasic
Version
2023
Language
English
Product name
MapBasic
Title
MapInfo MapBasic Reference
First publish date
1985
Last updated
2023-09-12
Published on
2023-09-12T16:32:32.686312

The following clauses affect the coordinate system of the map and distance type in use.

Syntax

Set Map 
	[ Window window_id ] 
	[ CoordSys... ] 
	[ Distance Type { Spherical | Cartesian } ]
	[ XY Units  xy_unit  [ 
		{ Display  Decimal  {On | Off } | 
			Display  Grid [ { MGRS | USNG [ Datum datumid ] } ] 
		} 
	] ]	

window_id is the integer window identifier of a Map window.

xy_unit is a string representing the name of an x/y coordinate unit (for example, "m" for meters, "degree" for degrees). If the XY Units are in degrees, the Display Decimal clause specifies whether to display in decimal degrees. Set to On to display in decimal degrees or Off to set in degrees, minutes, or seconds. Set Display Grid to display in Military grid reference format.

datumid is a numeric expression representing the datum id. It must evaluate to one of the following values:

	DATUMID_NAD27  (62)
	DATUMID_NAD83  (74)
	DATUMID_WGS84 (104)
Note: DATUMID_* are defines in MapBasic.def. WGS84 and NAD83 are treated as equivalent.

Description

CoordSys clause Assigns the Map window a different coordinate system and projection. For details on the syntax of a CoordSys clause, see CoordSys clause.

The MapBasic coordinate system must be set explicitly with a Set CoordSys statement and can be retrieved with the SessionInfo( ) function.

Note: When a Set Map statement includes a CoordSys clause, the MapBasic application's coordinate system is automatically set to match the map's coordinate system.

This example only alters the map's coordinate system and units; the MapBasic coordinate system is unaffected:

	Set Map XY Units "m" CoordSys Earth Projection 8, 
	33, "m", -55.5, 0, 0.9999, 304800, 0 

Distance Type is either Spherical or Cartesian. All distance, length, perimeter, and area calculations for objects contained in the Map window will be performed using one of these calculation methods. Note that if the coordinate system of the Map window is NonEarth, then the calculations will be performed using Cartesian methods regardless of the option chosen, and if the coordinate system of the Map window is Latitude/Longitude, then calculations will be performed using Spherical methods regardless of the option chosen.

XY Units specifies the type of coordinate unit used to display x-, y-coordinates (for example, when the user has specified that the map should display the cursor position on the status bar). The unit name can be "degree" (for degrees longitude/latitude) or a distance unit such as "m" for meters.

If the XY Units are in degrees, the Display Decimal clause specifies whether to display in decimal degrees (On) or in degrees, minutes, seconds (Off). Display Grid will display coordinates in Military Grid reference system format no matter how the XY Units are specified.

	Set Map XY Units "m" Display Grid 
	Set Map XY Units "degree" Display Grid 
	Set Map XY Units "degree" Display Decimal On 
	Set Map XY Units "degree" Display Decimal Off 

The following statement specifies meters as the coordinate unit:

Set Map XY Units "m"