ArcGIS Blog

Developers

ArcGIS Maps SDKs

Creating Spatially Accurate Apps with the ArcGIS Maps SDKs for Game Engines

By Luis Flores Carrubio

Introduction

In version 2.0 of the ArcGIS Maps SDKs for Game Engines, we’ve introduced an improved user interface enhancing the low-code/no-code experience for creating your maps. In this blog post, you’ll learn how to take advantage of these improvements to ensure spatial data accuracy in your application. With the enhanced user interface, you can now specify a Coordinate Reference System (CRS) enabling you to create maps using supported horizontal and vertical coordinate systems without the need to write code.

If you’d like to learn about CRSs, you can find additional information in our Guide to Coordinate Reference Systems for Game Developers. Let’s have a closer look at the new user interface along with details on the implications of choosing a CRS for your map.

Choosing a CRS to improve spatial accuracy

The ArcGIS Maps SDKs for Game Engines enables you to position spatial data and game objects in world space using real world coordinates. In previous releases, specifying a CRS for the map could only be done using the respective APIs for Unity and Unreal Engine and would otherwise take on the horizontal CRS of the first loaded data layer. However, you can now set the CRS of the map through the enhanced user interface. This blog will help you determine the best workflow to use for ensuring data accuracy in your application. Let’s go through some of the steps for creating a map and setting its CRS to visualize the city of Munich, Germany using Esri hosted 3D Tiles data with the ArcGIS Maps SDK for Unreal Engine. This workflow is also applicable to the Maps SDK for Unity to create the same application. The list of supported coordinate systems can be found in the respective documentation websites for the ArcGIS Maps SDKs for Unity and Unreal Engine.

Figure 1. Configuration for the map, its origin position, and camera position located at Munich, Germany using the ArcGIS Maps SDK for Unreal Engine.
Figure 1. Configuration for the map, its origin position, and camera position located at Munich, Germany using the ArcGIS Maps SDK for Unreal Engine.

Setting the CRS of a map can be done by checking the Enable Manual Selection option enabling you to manually set the horizontal (HCS) and vertical (VCS) coordinate systems (Figure 1). When the checkbox is unchecked, the map HCS is that of the first loaded data layer which is often the basemap. For the example global scene configuration (Figure 1), Web Mercator is manually set as the map HCS for compatibility with ArcGIS Basemap Styles. The ArcGIS Imagery Standard is selected as the basemap and World Elevation 3D is added both tiled data sources in Web Mercator (Figure 2). Accordingly, had the HCS of the map not been set manually with the checkbox remaining unchecked, the same result would have been achieved since the basemap already uses Web Mercator. However, this is only applicable to the map HCS and setting a VCS must be done manually. To best match the 3D Tiles coordinate system, the map VCS should be set to WGS84 to avoid reprojection thereby improving spatial accuracy. Note, while specifying a VCS is optional, data layers might not coincide without one, and it is recommended to set a VCS for the map when also setting one for the origin position. It is also recommended to set the map origin position closest to an area of interest as height changes for different locations on the Earth’s surface. The result of this configuration can be seen in (Figure 3) where added data is coincident both horizontally and vertically.

Figure 2. Adding the ArcGIS Imagery basemap and Terrain 3D elevation data to the map along with 3D Tiles data for Munich, Germany using the ArcGIS Maps SDK for Unreal Engine.
Figure 2. Adding the ArcGIS Imagery basemap and Terrain 3D elevation data to the map along with 3D Tiles data for Munich, Germany using the ArcGIS Maps SDK for Unreal Engine.

An ideal configuration is to have matching spatial frames for the map and data layers including the basemap and elevation. Given the 3D Tiles coordinate system is WGS84, manually setting the map HCS to WGS84 is best for accuracy. However, a basemap in WGS84 such as World Imagery (WGS84) and elevation data in WGS84 must be used. When data in a specific spatial frame is not available, you can rely on automatic reprojection with minimal loss in accuracy but there are some limitations. The next section of this blog describes what happens when there is a mismatch between the spatial frame of the map and added data.

Figure 3. Munich, Germany visualized using 3D Tiles data and the ArcGIS Imagery basemap with the ArcGIS Maps SDK for Unreal Engine displaying horizontal and vertical spatial accuracy.
Figure 3. Munich, Germany visualized using 3D Tiles data and the ArcGIS Imagery basemap with the ArcGIS Maps SDK for Unreal Engine.

When spatial frames don’t match

Let’s have a closer look at what happens when the map HCS is changed to WGS84 from Web Mercator for the example configuration (Figure 1). The map and 3D Tiles data now use the same spatial frame but to add image and vector tiled data sources such as ArcGIS Basemap Styles, currently the HCS of the map and these two tiled sources must match. When the map HCS is manually changed to WGS84 and the VCS to zero (none), the ArcGIS View State Logging Component outputs an error message when trying to add tiled sources that do not have a matching HCS along with warning messages when a VCS is not set and when reprojection occurs (Figure 4). The use of this component is essential for obtaining information about the current state of your data sources. The error messages correspond to the basemap and elevation tiled sources that cannot be reprojected to WGS84 and therefore not added to the map. Although the map is now using WGS84, there’s a warning message for the Munich 3D Tiles data because the VCS is now set to none thus not completely matching the data spatial frame. Given the current reprojection limitations of image and vector tiled sources, basemap and elevation data sources take on a more important role when deciding which spatial frame to use for your map. Moreover, what determines if data is automatically reprojected depends on the CRS of the map and data but also the map type for creating a global or local scene covered in the next section of this blog.

Figure 4. ArcGIS View State Logging Component messages when adding an ArcGIS Basemap, Terrain 3D data, and Munich 3D Tiles data for a map with HCS set to WGS84 without a VCS in a global scene.
Figure 4. ArcGIS View State Logging Component messages when adding an ArcGIS Basemap, Terrain 3D data, and Munich 3D Tiles data for a map with HCS set to WGS84 without a VCS in a global scene.

Similarly to horizontal reprojections, spatial data is vertically reprojected when it doesn’t match the map VCS and it is possible for data layers to not vertically coincide given different CRSs and elevation data. A gravity related VCS such as EGM2008 can be used for improved spatial accuracy over both EGM96 and WGS84 and automatic reprojection can prove beneficial when most added data layers already use orthometric heights. However, in some cases where data is in ellipsoidal height, the map VCS should be set to WGS84. For example, when overlaying Google’s Photorealistic 3D Tiles in WGS84 with an Esri hosted 3D Object Scene layer in EGM96 for visualizing San Francisco, USA, the data coincides when the VCS is WGS84 (Figure 5). To verify the spatial frame of Esri hosted data, you can look at its JSON information and search for the layer’s spatialReference field. The following JSON corresponds to the 3D Object Scene layer described above showing its HCS as WGS84 and VCS, EGM96.

...
"href": "./layers/0",
"associatedLayerID": 0,
"layerType": "3DObject",
"spatialReference": {
    "wkid": 4326,       --> HCS
    "latestWkid": 4326,
    "vcsWkid": 5773,    --> VCS
    "latestVcsWkid": 5773
    },
    "heightModelInfo": {
    "heightModel": "gravity_related_height",
    "vertCRS": "EGM96_Geoid",
    "heightUnit": "meter"
}
...

 

When the map VCS is gravity-related, but the spatial data uses ellipsoidal heights such as with 3D Tiles, a grid transformation is necessary which requires data files to be downloaded. In version 2.0 of the Maps SDKs for Game Engines, the data files required for grid transformations between EGM96 and WGS84 are included. This allows creating applications entirely in e.g., WGS84 to best match the 3D Tiles coordinate system without downloading files and writing code while also avoiding reprojections for WGS84 data. Further details on grid transformations can be found in the respective documentation websites for the ArcGIS Maps SDKs for Unity and Unreal Engine.

Figure 5. San Francisco 3D Object Scene layer over Google’s Photorealistic 3D Tiles showcasing vertical spatial accuracy when using VCS WGS84 with the ArcGIS Maps SDKs for Unreal Engine.
Figure 5. San Francisco 3D Object Scene layer over Google’s Photorealistic 3D Tiles showcasing vertical spatial accuracy when using VCS WGS84 with the ArcGIS Maps SDKs for Unreal Engine.

Choosing between a global or local scene

When creating global and local scenes, data layers are displayed using their default HCS when the map has a matching HCS for geographic and projected systems, respectively. There are exceptions for commonly used spatial frames such as WGS84 and Web Mercator. The ArcGIS Maps SDKs for Game Engines automatically reprojects Web Mercator to WGS84 in global scenes. For the example configuration (Figure 1), the 3D Tiles data is not reprojected although the map uses Web Mercator because the global map type is selected. This is the only projected system that can be used in global scenes and while it allows displaying Web Mercator data on the globe such as ArcGIS Basemap Styles, a reprojection is performed which might not be ideal for local scale accuracy and performance. Depending on the use case, a local scene could provide better results when using map projections such as Web Mercator. This is because when the map and data are both using Web Mercator in a local scene, reprojections are not performed other than what is already inherent from the Web Mercator projection. Similarly, geographic WGS84 and GCS2000 can be used in a local scene but to display data on a planar surface, a reprojection to Plate Carrée is ultimately performed. Therefore, it is essential to know the spatial frame of your data so that the most appropriate map type for your scene can be selected to avoid reprojections. For local scenes, the use of a VCS might not seem relevant given data is projected, but setting one is essential for ensuring vertical accuracy e.g., when adding 3D Tiles data. Additional information on global and local scenes can be found in the respective documentation websites for the ArcGIS Maps SDKs for Unity and Unreal Engine.

Summary

Creating maps using your preferred CRS provides flexibility when working with data in different coordinate frames allowing you to improve the spatial accuracy of your application. With the release of version 2.0 of the ArcGIS Maps SDKs for Game Engines, this flexibility is extended to the user interface enabling you to create spatially accurate apps through a complete low-code/no-code experience. Future releases are planned to include support for reprojecting tiled data sources between Web Mercator and WGS84 and improved vertical accuracy when using data in different coordinate systems.

If you’d like to get started using the ArcGIS Maps SDKs for Unity and Unreal Engine, check out the respective documentation websites. There, you can find comprehensive tutorials on how to create applications and learn how to sign up for a free account gaining access to everything you need to get started building your apps. You can also visit the ArcGIS Maps SDKs for Game Engines community website to ask or search for questions and to provide feedback.

Share this article