If your 3D apps need to operate in a disconnected or offline capacity, use offline scenes in your ArcGIS Runtime app.
You can use ArcGIS Pro to consolidate scenes into a single mobile scene package (.mspk) that can be shared with your organizational account or copied directly to your mobile device. These read-only scenes, their layers and associated data will be contained in a single mobile scene package (.mspk). This mobile scene package adheres to a common scene definition that allows you to transport your scenes and data across the ArcGIS platform.
Create a mobile scene package with ArcGIS Pro
You can create mobile scene packages with ArcGIS Pro using the tool called create a mobile scene package from the Data Management Toolbox. With ArcGIS Pro 2.4 (or later) you can use this tool to set an expiration date on your mobile scene package as long as ArcGIS Pro is licensed with the ArcGIS Publisher extension
You can distribute .mspk files to your users, for use in your app, by:
Uploading and sharing the files in your organization (with ArcGIS Online or your portal)
Delivering the files to individual devices through common file sharing methods (network share, email, and so on)
Offline scenes can include basemaps, operational layers, 3D scene layers, tiled layers (.tpk), tables, relationship classes, locators and elevation sources as tiled data. Raster elevation sources are not supported.
Before you open and display scenes provided by a mobile scene package you should consider:
- Does the mobile scene package contain raster data that needs to be unpacked?
- Has the mobile scene package expired?
Unpack a mobile scene package
With ArcGIS Pro version 2.1 (or higher) you can include raster datasets in a mobile scene package. Raster data that's an operational or basemap layer cannot be read directly from an .mspk file, so it's recommended you always perform a check. To perform this check, follow the steps below:
- Make sure the .mspk file gets added to your users' devices. For example, you can have your users download it from ArcGIS Online or your portal to their device when connected.
- Check whether the mobile scene package file supports direct reading by calling the MobileScenePackage.isDirectReadSupportedAsync() method.
- If the file can be read directly, skip to step 5.
- If the file cannot be read directly, then unpack the .mspk file in an output directory. Before unpacking the file, confirm that the device has
sufficient space for the file using the device's native API. An unpacked .mspk file occupies a
similar amount of space as the original packaged file. After the unpacking operation completes, you can delete the original .mspk file to save space (unless you need the file for another purpose).
To avoid having to unpack the .mspk file, instead of adding raster data to an .mspk file as an operational or basemap layer, you can create a .tpk file from the raster data and add that to the scene before creating the .mspk file.
- Instantiate the MobileScenePackage object from the .mspk file or output directory.
- Load the MobileScenePackage.
Once you have instantiated and loaded the .mspk file, you can access any of its scenes for display.
- To display a scene, pass it to the scene view.
Unpacking a mobile scene package file into a directory obviously occupies space. You may want to confirm that the device has sufficient space before you unpack the mobile scene package file to avoid an unpacking error. To save space you could delete the original mobile scene package file after unpacking completes (unless you need this file for another purpose).
Further advice regarding unpacking a mobile scene package:
- If you try to load a mobile scene package where direct read is not supported an error will be thrown. The error message will advise you to unpack the mobile scene package file.
- Instead of adding raster data to a scene as an operational or basemap layer you could create a .tpk from raster data and add that to the scene before creating the mobile scene package. This would avoid the need to unpack the mobile scene package.
- An unpackaged mobile scene package takes roughly the same amount of space as the original file.
- You should confirm that the device has sufficient space before you unpack the mobile scene package to avoid an unpacking error.
- You could delete the original mobile scene package file after unpacking completes to save space (unless you need to retain this file for another purpose).
Mobile scene package expiration
With ArcGIS Pro 2.4 (or later) you can set an expiration date on your mobile scene package using some options provided by the ArcGIS Publisher extension. Expiration gives you more control over the lifetime of your data. For example, it will allow you to:
- Provide data to 3rd party contractors which will expire at the end of a contract.
- Indicate to your users that frequently changing data has become obsolete.
As an ArcGIS Runtime developer there are three possible outcomes when you try to load a mobile scene package.
- You can access the mobile scene package. This situation occurs if the package has not expired or if it has been created without an expiration.
- You can access the mobile scene package even though the scenes and their data have expired. You will be warned that the package is out of date.
- You cannot access the mobile scene package because it has expired. In this case the package will fail to load and you will not be able to access its scenes and data.
These three outcomes are managed by the mobile scene package load process MobileScenePackage.Load. No extra workflow or code-paths are required to accommodate these.
You can, however, retrieve the expiration details from the expiration property on the MobileScenePackage if you want to provide your users with extra information. For example, you could display how many days remain before the package expires:
- Load the mobile scene package.
- Read the expiration property on the mobile scene package.
- Confirm that it has not expired.
- Get the expiry date.
- Calculate the number of days between today and the expiry date. Report the number of days remaining.