ArcGIS Blog

Developers

ArcGIS Maps SDKs

A Guide to Coordinate Reference Systems for Game Developers

By Luis Flores Carrubio

Introduction

Coordinate Reference Systems (CRS) are familiar to game engine developers and GIS professionals alike, but in very different contexts. For the game developer, the CRS matters so that objects are placed accurately relative to each other in world space. For the GIS professional, it matters so that objects are positioned relative to their real-world locations. How do these different approaches relate to each other in the context of building geospatial applications using game engines – that is, applications which rely on the positioning of spatial data on the Earth’s surface rather than world space?

In this blog, I’ll share information about the Cartesian, geographic, and projected coordinate systems and how they relate to each other to help you create immersive and interactive 3D experiences with real-world geographic data using the ArcGIS Maps SDKs for Game Engines.

Cartesian systems

Cartesian coordinate systems are fundamental to the world spaces created in Unity and Unreal Engine. Although these game engines follow different axes conventions, the ArcGIS Maps SDKs for Game Engines are built to ensure that the same mapping application can be created regardless of the preferred engine. Cartesian systems measure distance from the intersection point between three mutually perpendicular coordinate axes or direction vectors specified in relation to an orthogonal basis. The axes convention and orientation of space are components of the basis and these game engines adopt a left-hand coordinate system where a positive rotation is clockwise around the rotation axis. The images below show that a rotation around the up-direction vector in Unreal Engine takes the +X axis to the +Y axis while in Unity the +Z axis goes to +X axis (Figure 1).

Figure 1. The Cartesian XYZ coordinate systems used in Unity (left) and Unreal Engine (right).
Figure 1. The Cartesian XYZ coordinate systems used in Unity (left) and Unreal Engine (right).

A distinction between these two systems is that the axes are uniquely described because the bases assign a different order to the coordinates. Therefore, the XYZ axes are often referred to by their direction vector counterparts. For example, in Unreal Engine the XYZ axes correspond to the forward, right, and up vectors and contrastingly, the right, up, and forward vectors in Unity. This is relevant for accurate alignment of spatial data and game objects between coordinate systems through a process known as georeferencing. Spatial data is often aligned with coordinate systems that define locations in angular units facilitating calculations on surfaces that resemble the shape of the Earth. The Game Engine Maps SDKs integrate these systems enabling you to create mapping applications that can be used to accurately solve spatial problems in global and local real-world areas. Let’s have a closer look at geographic systems and how these relate to game engine world space.

Geographic systems

The shape of the Earth has been thoroughly researched with efforts being traced back to the pre-scientific era resulting in the field known as geodesy. Geodesists have developed several models that approximate the Earth’s figure using spheres and ellipsoids. These regular shapes are preferred because they simplify geometrical problems, but the surface of the Earth is found to be irregular due to variations in its mass distribution. Consequently, surface models known as geoids provide an accurate representation of the Earth’s figure by approximating mean sea level. Geoids can be used for obtaining precise elevation values but are not ideal for mapping and solving spatial problems because of surface irregularities. As a result, reference ellipsoids optimized to minimize height variations to the geoid are ultimately preferred.

Figure 2. Geographic coordinate system with geodetic latitudes (ϕ) representing the angles (±90°) between the normal to the ellipsoid and the equatorial plane. Geodetic longitudes (λ) represent the angles (±180°) east or west from the prime meridian.
Figure 2. Geodetic latitudes (ϕ) represent the angles (±90°) between the normal to the ellipsoid and the equatorial plane. Geodetic longitudes (λ) represent the angles (±180°) east or west from the prime meridian. Image source: https://kartoweb.itc.nl

Having an ellipsoid by itself is not sufficiently useful until its spatial frame is bound to real-world space. There are different spatial frames identified by geodetic datums i.e., horizontal and vertical datums that fix the ellipsoid to the Earth. The combination of these datums or spatial frames define a Compound Coordinate Reference System (CCRS). This system can be used to integrate a two-dimensional Geographic Coordinate System (GCS) with a Vertical Coordinate System (VCS) creating a three-dimensional CRS. The GCS defines coordinates often as geodetic latitudes (φ) and longitudes (λ). Therefore, a surface point measures distances in angular units often from the equatorial plane and prime meridian for latitude and longitude values, respectively (Figure 2). In contrast, the VCS defines the origin of height and depth values measuring geodetic (ellipsoidal) or gravity-related heights. Geodetic heights are provided by satellites calculating distances from the reference ellipsoid to the Earth’s topography and can be negative when the ellipsoid is above the surface topography. However, for applications requiring precise height measurements, gravity-related or orthometric values are preferred. This is because height is measured from the geoid to the Earth’s topography instead of using the ellipsoid. Additionally, orthometric and geodetic heights can be related if the difference between the geoid and ellipsoid is known. This difference is referred to as the geoid height with negative values indicating that the geoid is below the ellipsoid (Figure 3).

Figure 3. Vertical systems relationship between orthometric, geodetic (ellipsoidal), and geoid heights. The geoid, from which zero-level heights can be measured, undulates around the ellipsoid surface.
Figure 3. Relationship between the orthometric, geodetic (ellipsoidal), and geoid heights. The geoid, from which zero-level heights can be measured, undulates around the ellipsoid surface. Image source: https://www.unavco.org/

The spatial reference frames are each assigned a unique Well-Known ID (WKID). These values are necessary for the Game Engine Maps SDKs to accurately georeference data layers and objects in your application. Some common WKIDs for horizontal and vertical coordinate systems are listed below:

Name Coordinate System WKID
Earth Gravitational Model 1996 Vertical (gravity-related) 5773
Earth Gravitational Model 2008 Vertical (gravity-related) 3855
World Geodetic System 84 Vertical (ellipsoidal) 115700
World Geodetic System 84 Horizontal (geographic) 4326
China Geodetic Coordinate System 2000 Horizontal (geographic) 4490
Web Mercator / Pseudo-Mercator Horizontal (projected) 3857
Plate Carrée Horizontal (projected) 32662

With the Game Engine Maps SDKs, you can define a two or three-dimensional CRS for use in your application. This is done by choosing a global or local map type to determine how the map is viewed and the WKID of a supported system for the map via the user interface or using our powerful C# or C++ APIs for the Unity and Unreal Engine SDKs, respectively. From the table above, the World Geodetic System 1984 (WGS84) can be used to describe horizontal and vertical geodetic datums but also a reference ellipsoid. The Game Engine Maps SDKs use the WGS84 ellipsoid as a reference to render spatial data (Figure 4). This ellipsoid is defined using a right-hand Cartesian system positioned at the Earth’s center of mass. A term used to describe such systems is Earth-centered, Earth-fixed (ECEF) where rectangular coordinates are converted to ellipsoidal facilitating the solution of spatial problems. The WGS84 vertical datum can be used to obtain geodetic heights but when higher accuracy is required, the Earth Gravitational Model (EGM) can be used instead. The EGM is a vertical spatial frame based on the Earth’s gravitational equipotential surface instead of an ellipsoid. This model was developed with the objective of creating a reference surface for a global vertical datum relative to WGS84. Therefore, EGMs are related to the WGS84 ellipsoid enabling grid transformations between ellipsoidal and orthometric heights using the geoid defined by the EGM.

Figure 4. Representation of the Earth’s figure using the ArcGIS Maps SDKs for Game Engines, displaying a population density layer for the USA (left) and the ArcGIS Imagery basemap (right).
Figure 4. Representation of the Earth’s figure using the ArcGIS Maps SDKs for Game Engines, displaying a population density layer for the USA (left) and the ArcGIS Imagery basemap (right).

The Game Engine Maps SDKs currently use EGM96 as the default vertical system for your map unless specified otherwise. This can be combined with a geographic horizontal datum and the global map type to create a three-dimensional CRS. For this configuration, most gravity-related data layers are rendered at orthometric height from the WGS84 ellipsoid. However, these can be rendered at ellipsoidal height by performing a grid transformation. Further information on geographic systems and grid transformations can be found in the respective documentation websites for the Game Engines Maps SDKs for Unity and Unreal Engine. The next section of the blog introduces projected coordinate systems which are preferred for creating two-dimensional maps with the local map type.

Projected systems

Maps are used to represent the Earth’s surface in two dimensions by projecting or flattening geographic systems onto developable surfaces like planes, cones, and cylinders. This process involves mathematical formulas that convert geodetic measurements to eastings and northings known as map coordinates. These describe the vertical and horizontal lines that divide the map from west to east and north to south forming a grid. The advantage of using projected systems is that rectangular coordinates can simplify calculations and display of information. A disadvantage is that the conversion from angular to rectangular coordinates introduces errors causing map deformations depending on the projection used. There are several map projections including conformal, equal area, equidistant, and azimuthal projections that produce different results depending on the spatial properties that are preserved. The Game Engine Maps SDKs enables you to create maps using projected systems where the choice of projection determines the accuracy of locations on your map.

Figure 5. Representations of the Plate Carrée (left) and Web Mercator projections (right) using the ArcGIS Maps SDKs for Game Engines.
Figure 5. Representations of the Plate Carrée (left) and Web Mercator projections (right) using the ArcGIS Maps SDKs for Game Engines.

An example of a widely used conformal cylindrical map projection is the Mercator projection preserving direction, angles, and shapes but area is distorted with increasing distance from the equator. This projection uses ellipsoidal formulas ideal for global mapping and navigational charts which led to adaptations like the Web Mercator system based on the WGS84 geodetic datum (Figure 5). Similarly to geographic systems, projected systems also have unique WKIDs for identification. The Game Engine Maps SDKs allows you to define a two or three-dimensional CRS using map coordinates when the WKID of a projected system is specified. The Web Mercator system is of particular interest because of its efficiency and thus commonly used in web maps and services. However, it can create distortions reaching 40 kilometers because it combines spherical formulas with an ellipsoidal geodetic datum i.e., WGS84.

In contrast to Web Mercator, the Plate Carrée is an equidistant cylindrical map projection causing significant distortion at higher and lower latitudes but parallel lines in the grid maintain the same distance from each other (Figure 5). When using the Game Engine Maps SDKs, a Plate Carrée projection is performed by default for geographic systems with the local map type. However, if the WKID of a projected system is specified for the map and the local map type is used, the map is viewed in that same spatial frame. Additional information on how projected maps are viewed using the Game Engine Maps SDKs for Unity and Unreal Engine can be found in the respective documentation websites.

Summary

Coordinate reference systems are essential for creating two and three-dimensional applications. The Game Engine Maps SDKs have extensive support for different CRSs enabling the creation of maps in your preferred spatial frame through the use of our powerful C# or C++ APIs for the Unity and Unreal Engine SDKs. Additionally, a no-code option is available through the user interface where maps are created automatically by taking the spatial frame of the basemap or the first data layer added to the map. This is done to ensure accuracy between the map and spatial data by having both in the same spatial frame. However, when adding data layers in different spatial frames to the map, the Game Engine Maps SDKs automatically projects your data to the spatial frame of the map with minimal loss in accuracy.

Upcoming changes to the Game Engine Maps SDKs include an enhanced user interface allowing you to specify the preferred spatial frame for the map improving the no-code experience. These changes facilitate the creation of maps by entering the preferred WKIDs for the horizontal and vertical spatial frames. Additional improvements include automatic transformations between ellipsoidal and gravity-related heights, enabling you to combine layers in either vertical coordinate system, and new Unity and Unreal Engine samples to help you create your own application taking advantage of the GIS capabilities of the Game Engine Maps SDKs.

If you’d like to get started using the Game Engine Maps SDKs for Unity and Unreal Engine, check out the respective documentation websites. There, you can learn how to sign up for a free account and gain access to everything you need to get started building your apps.

Share this article