Scenes (3D)

Maps and scenes provide interactive displays of geographic data that enable you to visualize and explore patterns, answer questions, and share insight. They can be opened, edited, and shared across the ArcGIS system and beyond. While the programming patterns are similar and many of the classes you work with are the same, maps are designed for working with geographic data in two dimensions (2D) and scenes in three dimensions (3D). Most applications contain a basemap layer to display geographic data with streets or satellite imagery, but you can also use data layers and graphics to display additional data. See Maps (2D) in this guide for more information about working with maps.

You can use a scene and a scene view to:

  • Display a basemap layer such as streets or satellite imagery.
  • Access and display data layers based on files or services, including data you have authored.
  • Display terrain with an elevation layer.
  • Display real-world objects such as buildings, cars, and trees.
  • Display 3D visualizations of 2D objects.
  • Perform 3D analysis, such as line-of-sight, visibility, and 3D measurements.
  • Provide context for temporary points, lines, polygons, or text displayed as graphics.
  • Measure distance and explore spatial relationships between geometries.
  • Inspect data layers and display information from attributes.

How a scene works

A scene works together with a scene view to display geographic content in three dimensions. A scene contains a collection of layers including multiple data layers from online or local sources, a basemap layer that gives geographic context, and a base surface containing elevation data. A scene can also contain datasets that enable searches for addresses or place names, networks for solving routes, and non-spatial tables.

For offline workflows (when you don't have network connectivity), you can open a scene stored in a mobile scene package. You can create mobile scene packages using ArcGIS Pro, share them using your ArcGIS organization, or distribute directly by copying to a device. See Offline maps, scenes, and data for more information about implementing offline workflows with ArcGIS Runtime.

Scene

A scene contains a collection of layers. Two dimensional layers are displayed in the order in which they are added, while three dimensional layers are displayed using the layer's elevation information. You can use the scene to change the display order of two dimensional layers as well as to control which layers are visible, and expose this functionality with user interface controls such as lists, check boxes, or switches. Scenes extend the concept of a basemap by introducing a base surface that contains a collection of elevation sources. Layers can be draped on top of the surface, positioned relative to the surface or displayed based on their absolute values.

You can instantiate a new AGSScene object by creating a new scene and building it entirely with code. With this approach, you typically first add a basemap layer and then one or more data layers.

                             
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import ArcGIS

AGSArcGISRuntimeEnvironment.apiKey = "YOUR_API_KEY"

let scene = AGSScene(basemap: .topographic())

let worldElevationServiceURL = URL(string: "https://elevation3d.arcgis.com/arcgis/rest/services/WorldElevation3D/Terrain3D/ImageServer")!
let elevationSource = AGSArcGISTiledElevationSource(url: worldElevationServiceURL)
let surface = AGSSurface()
surface.elevationSources.append(elevationSource)
scene.baseSurface = surface


@IBOutlet weak var sceneView: AGSSceneView!

...

sceneView.scene = scene

sceneView.setViewpointCamera(
    AGSCamera(
        latitude: 33.961,
        longitude: -118.808,
        altitude: 2000,
        heading: 0,
        pitch: 75,
        roll: 0
    )
)

You can also instantiate an AGSScene that's stored in a portal (such as ArcGIS Online) using its item ID or URL.

When the AGSScene first appears in the AGSSceneView, you can focus the initial display at a specified view point with the AGSScene.initialViewpoint method. If an initial view point is not defined, the scene will initially display at a global scale.

Layer

Each layer in a scene references geographic data, either from an online service or from a local dataset. There are a variety of layers that can be added to a scene, each designed to display a particular type of data. Some layers display images, such as satellite photos or aerial photography, others are composed of a collection of features to represent real-world entities using point, line, or polygon geometries. In addition to geometry, features have attributes that provide details about the entity it represents.

Scenes can also contain scene layers enabling you to create advanced 3D visualizations. ArcGIS Runtime supports scene layers containing one of four data types: points, point cloud, 3D objects, or an integrated mesh. To learn more about scene layers, visit What is a scene layer? in the ArcGIS Pro documentation.

The AGSLayer class is the base class for all types of layers used in ArcGIS Runtime. The type of layer you create depends on the type of data you want to display. For example, to display feature data (point, line, or polygon geometry), for example, you can create a AGSFeatureLayer that references an online service (such as a feature service) or a supported local dataset. Some layers cannot be displayed in a scene, such as AGSArcGISVectorTiledLayer and AGSAnnotationLayer. Similarly, 3D layers cannot be displayed in a map, such as AGSArcGISSceneLayer.

Add layers to a scene
                                                                                                               
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
// Fix blank line

AGSArcGISRuntimeEnvironment.apiKey = "YOUR-API-KEY"

let map = AGSMap(
    basemapStyle: .arcGISTopographic
)

let trailheadsLayer = AGSFeatureLayer(featureTable:
    AGSServiceFeatureTable(url: URL(string: "https://services3.arcgis.com/GVgbJbqm8hXASVYi/arcgis/rest/services/Trailheads_Styled/FeatureServer/0")!)
)
let trailsLayer = AGSFeatureLayer(featureTable:
    AGSServiceFeatureTable(url: URL(string: "https://services3.arcgis.com/GVgbJbqm8hXASVYi/arcgis/rest/services/Trails_Styled/FeatureServer/0")!)
)
let openSpacesLayer = AGSFeatureLayer(featureTable:
    AGSServiceFeatureTable(url: URL(string: "https://services3.arcgis.com/GVgbJbqm8hXASVYi/arcgis/rest/services/Parks_and_Open_Space_Styled/FeatureServer/0")!)
)

map.operationalLayers.addObjects(from: [openSpacesLayer, trailsLayer, trailheadsLayer])

AGSArcGISRuntimeEnvironment.apiKey = "YOUR-API-KEY"

let scene = AGSScene(
    basemap: .topographic()
)

let trailheadsLayer = AGSFeatureLayer(featureTable:
    AGSServiceFeatureTable(url: URL(string: "https://services3.arcgis.com/GVgbJbqm8hXASVYi/arcgis/rest/services/Trailheads_Styled/FeatureServer/0")!)
)
let trailsLayer = AGSFeatureLayer(featureTable:
    AGSServiceFeatureTable(url: URL(string: "https://services3.arcgis.com/GVgbJbqm8hXASVYi/arcgis/rest/services/Trails_Styled/FeatureServer/0")!)
)
let openSpacesLayer = AGSFeatureLayer(featureTable:
    AGSServiceFeatureTable(url: URL(string: "https://services3.arcgis.com/GVgbJbqm8hXASVYi/arcgis/rest/services/Parks_and_Open_Space_Styled/FeatureServer/0")!)
)

scene.operationalLayers.addObjects(from: [openSpacesLayer, trailsLayer, trailheadsLayer])


// --------- Basemap layer -------


AGSArcGISRuntimeEnvironment.apiKey = "YOUR_API_KEY"

let map = AGSMap(
    basemapStyle: .arcGISStreets  // .arcGISTopographic, .arcGISLightGray, .osmLightGray
)


AGSArcGISRuntimeEnvironment.apiKey = "YOUR_API_KEY"

let map = AGSMap(
    basemapStyle: .arcGISImagery  // .arcGISHillshadeLight, .arcGISHillshadeDark
)


settings = AGSENCEnvironmentSettings.shared()
settings.resourceDirectory = URL(fileURLWithPath: "pathToHydrographyDirectory")
settings.sencDataDirectory = URL(fileURLWithPath: "pathToSENCDirectory")


// create an exchange set
let catalogURL = URL(fileURLWithPath: "pathToENCData/CATALOG.031")
encExchangeSet = AGSENCExchangeSet(fileURLs: [catalogURL])
//load the exchange set
self.encExchangeSet.load {[weak self] (error) in
    if let error = error {
        print("Error loading exchange dataset \(error.localizedDescription)")
        return
    }
    //Loop through the exchange set datasets
    self?.encExchangeSet.datasets.forEach {(dataset) in
        //create the ENC Cell from the dataset
        let encCell = AGSENCCell(dataset: dataset)
        // create the ENC layer
        let encLayer = AGSENCLayer(cell: encCell)
        encLayer.name = dataset.name
        // add the ENC layer to the map
        self?.map.basemap.baseLayers.add(encLayer)
    }
}


let pathToOriginal = URL(fileURLWithPath: "pathToOriginalDirectory")
let pathToUpdate = URL(fileURLWithPath: "pathToUpdateDirectory")
let encExchangeSetUpdate = AGSENCExchangeSet(fileURLs: [pathToOriginal, pathToUpdate])


func geoView(_ geoView: AGSGeoView, didTapAtScreenPoint screenPoint: CGPoint, mapPoint: AGSPoint) {
         self.mapView.identifyLayer(self.encLayer, screenPoint: screenPoint, tolerance: 12, returnPopupsOnly: false, maximumResults: 10) { (identifyLayerResult: AGSIdentifyLayerResult) -> Void in
        //check for errors and ensure identifyLayerResult is not nil
        if let error = identifyLayerResult.error {
            print(error)
            return
        }
        // get the layer identified and cast it to an ENC Layer
        if let theENCLayer = identifyLayerResult.layerContent as? AGSENCLayer {
            // iterate each identified GeoElement in the results
            for geoElement in identifyLayerResult.geoElements
            {
                // select the ENC feature in the ENC layer
                if let theENCFeature = geoElement as? AGSENCFeature {
                    theENCLayer.select(theENCFeature)
                                     }
            }
        }
    }
}


settings.displaySettings.textGroupVisibilitySettings.natureOfSeabed = true

Camera

Scenes and scene views extend the concept of two dimensional viewpoints with a camera that represents the observer's position and perspective within three dimensions.

The following properties define the camera position:

  • Geographic location on the surface (longitude and latitude)
  • Altitude (height, in meters, above sea level)
  • Heading (angle about the z axis the camera is rotated, in degrees)
  • Pitch (angle the camera is rotated up or down, in degrees)
  • Roll (angle the camera is rotated side-to-side, in degrees)

A scene view has an associated controller that manages the camera for the scene. Each type of camera controller is designed to provide a specific user experience for interacting with the scene display. The camera controller and its properties can be changed at run time, enabling you to provide the scene view interaction experience best suited for the current context.

When a camera controller other than the default AGSGlobeCameraController is active, the scene view's viewpoint cannot be assigned. Attempts to do so do not raise an exception, but they are ignored.

ArcGIS Runtime SDK provides the following camera controllers:

  • AGSGlobeCameraController (default)—Provides the default scene view camera behavior. Allows the user to freely move and focus the camera anywhere in the scene.
  • AGSOrbitGeoElementCameraController—Locks the scene view's camera to maintain focus relative to a (possibly moving) graphic. The camera can only move relative to the target graphic.
  • AGSOrbitLocationCameraController—Locks the scene view's camera to orbit a fixed location (map point). The camera can only move relative to the target map point.
  • AGSTransformationMatrixCameraController—Provides navigation by using a AGSTransformationMatrix to control the camera's location and rotation. You need to pass this object to all `TransformationMatrixCameraController` functions. This can be used with transformation matrices produced by Augmented Reality APIs like ARKit (iOS) and ARCore (Android).

SceneView

A scene view is a user interface control that displays a single scene in your application. It contains built-in functionality that allows the user to explore the scene by zooming in and out, panning and rotating, or getting additional information about elements in the scene. Scene views may also contain graphics in one or more graphics overlays.

After creating a scene view, you typically set the scene and the camera position. Unlike a map, a scene uses a camera to define the viewer's perspective and to determine the visible area. The perspective is defined by setting the camera's position, location, altitude (height), heading, and tilt.

Add an AGSScene to a AGSSceneView control to display it. Changes you make to the scene, such as adding, removing, or reording layers, will immediately be reflected in the display. The AGSScene.initialViewpoint method will set the area shown when the scene loads.

                             
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import ArcGIS

AGSArcGISRuntimeEnvironment.apiKey = "YOUR_API_KEY"

let scene = AGSScene(basemap: .topographic())

let worldElevationServiceURL = URL(string: "https://elevation3d.arcgis.com/arcgis/rest/services/WorldElevation3D/Terrain3D/ImageServer")!
let elevationSource = AGSArcGISTiledElevationSource(url: worldElevationServiceURL)
let surface = AGSSurface()
surface.elevationSources.append(elevationSource)
scene.baseSurface = surface


@IBOutlet weak var sceneView: AGSSceneView!

...

sceneView.scene = scene

sceneView.setViewpointCamera(
    AGSCamera(
        latitude: 33.961,
        longitude: -118.808,
        altitude: 2000,
        heading: 0,
        pitch: 75,
        roll: 0
    )
)

A scene view control also allows you to:

  • Adjust light, atmosphere, and space effects.
  • Display image overlays on the scene surface.
  • Lock the camera to a location or geoelement.
  • Add analysis overlays to visualize analysis results.
  • Identify and select features using a mouse or tap location.
  • Export an image of the current display.
  • Apply a time extent to filter the display of features.

Examples

Display a scene with elevation

This example uses an AGSScene and AGSSceneView to display the topographic basemap layer. The basemap layer is draped on an elevation layer to create a 3D perspective. A AGSCamera is created to define the initial view of the scene.

Steps

  1. Create an AGSScene and add a basemap layer.
  2. Use an elevation service with AGSScene.baseSurface to define a base surface.
  3. Create a AGSSceneView and set the camera position.
                                        
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
class ViewController: UIViewController {
    @IBOutlet weak var sceneView: AGSSceneView!

    private func setupScene() {

        AGSArcGISRuntimeEnvironment.apiKey = "YOUR_API_KEY"

        let scene = AGSScene(
            basemap: .topographic()
        )

        let surface: AGSSurface = {
            let url = URL(string: "https://elevation3d.arcgis.com/arcgis/rest/services/WorldElevation3D/Terrain3D/ImageServer")!
            let elevationSource = AGSArcGISTiledElevationSource(url: url)
            let surface = AGSSurface()
            surface.elevationSources.append(elevationSource)
            return surface
        }()
        scene.baseSurface = surface

        sceneView.scene = scene

        sceneView.setViewpointCamera(
            AGSCamera(
                latitude: 33.961,
                longitude: -118.808,
                altitude: 2000,
                heading: 0,
                pitch: 75,
                roll: 0
            )
        )

    }

    override func viewDidLoad() {
        super.viewDidLoad()
        setupScene()
    }
}

Display a scene from a mobile scene package

This example displays a scene from a mobile scene package. You can create your own mobile scene packages using ArcGIS Pro or download existing ones from ArcGIS Online. The Philadelphia scene package, for example, shows an area of downtown Philadelphia with textured buildings.

Steps

  1. Create a AGSMobileScenePackage using the path to a local .mspk file.
  2. Call AGSMobileScenePackage.loadWithCompletion() to load the package.
  3. When the package loads, get the first scene from the package using AGSMobileScenePackage.scenes.
  4. Display the scene in a AGSSceneView.
                           
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import ArcGIS

class ViewController: UIViewController {
    @IBOutlet weak var sceneView: AGSSceneView!
    private var scenePackage: AGSMobileScenePackage!

    private func setupScene() {

        AGSArcGISRuntimeEnvironment.apiKey = "YOUR_API_KEY"

        //initialize scene package
        self.scenePackage = AGSMobileScenePackage(name: "Philadelphia")

        //load scene package
        self.scenePackage.load
        let scene = self.scenePackage.scenes.first

        //assign the first scene from the scene package to the scene view
        self.sceneView.scene = scene

    }

    override func viewDidLoad() {
        super.viewDidLoad()
        setupScene()
    }
}

Tutorials

Samples

Services

Next steps

Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.