---
name: "Example Code: Convert Position To Map Grid"
type: topic
aliases: ["Converting position to map grid"]
source: https://community.bistudio.com/wiki/Example_Code:_Convert_Position_To_Map_Grid
revid: 378162
updated: 2026-02-28T20:46:00Z
---

# Example Code: Convert Position To Map Grid

### Arma 3 (Arma 3 v1.00 Arma 2 v1.04)

> [!NOTE]
> - [mapGridPosition](../commands/mapGridPosition.md) has been introduced in Arma 2 v1.04

```sqf
private _mapGridPosition = mapGridPosition player;
```

### Arma 2 (Arma 2 v1.00)

> [!NOTE]
> - [BIS_fnc_posToGrid](../functions/BIS_fnc_posToGrid.md) has been introduced in Arma 2 v1.00

```sqf
local _mapGridPosition = player call BIS_fnc_posToGrid;
```

### Armed Assault (Armed Assault v1.00)

> [!NOTE]
> - [floor](../commands/floor.md) has been introduced in Armed Assault v1.00

```sqf
private ["_gridSize", "_yOffset", "_xPos", "_yPos"]
private ["_letter1Index", "_letter2Index", "_letter1Choice", "_letter2Choice", "_letter1", "_letter2"]
private ["_numbers", "_mapGridPosition"]

_gridSize = 200; // given grid squares are 200 × 200
_yOffset = -280; // position [0,0,0] is somewhere in the middle of second big grid on Y axis

_xPos = floor ((_this select 0) / _gridSize);
_yPos = floor (((_this select 1) + _yOffset) / _gridSize);

_letter1Index = floor (_xPos / 10);
_letter2Index = floor (_xPos % 10);
_letter1Choice = ["A", "B", "C", "D", "E", "F", "G", "H", "I", "J"];
_letter2Choice = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j"];
_letter1 = _letter1Choice select _letter1Index;
_letter2 = _letter2Choice select _letter2Index;

_numbers = 100 - _yPos; // coordinate numbers start from top-left of the map

_mapGridPosition = format ["%1%2%3", _letter1, _letter2, _numbers];
```

### Operation Flashpoint (Operation Flashpoint v1.00)

```sqs
private ["_gridSize", "_yOffset", "_xPos", "_yPos"]
private ["_letter1Index", "_letter2Index", "_letter1Choice", "_letter2Choice", "_letter1", "_letter2"]
private ["_numbers", "_mapGridPosition"]

; given grid squares are 200 × 200
_gridSize = 200

; position [0,0,0] is somewhere in the middle of second big grid on Y axis
_yOffset = -280

_xPos = (_this select 0) / _gridSize
_yPos = ((_this select 1) + _yOffset) / _gridSize
_xPos = _xPos - (_xPos mod 1)
_yPos = _yPos - (_yPos mod 1)

_letter1Index = _xPos / 10
_letter2Index = _xPos % 10
_letter1Index = _letter1Index - (_letter1Index mod 1)
_letter2Index = _letter2Index - (_letter2Index mod 1)
_letter1Choice = ["A", "B", "C", "D", "E", "F", "G", "H", "I", "J"]
_letter2Choice = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j"]
_letter1 = _letter1Choice select _letter1Index
_letter2 = _letter2Choice select _letter2Index

; coordinate numbers start from top-left of the map
_numbers = 100 - _yPos

_mapGridPosition = format ["%1%2%3", _letter1, _letter2, _numbers]
```

<sub>Source: [BI Community Wiki — Example Code: Convert Position To Map Grid](https://community.bistudio.com/wiki/Example_Code:_Convert_Position_To_Map_Grid) (revision 378162).</sub>
