ArcGIS Pro 3.4 API Reference Guide
ArcGIS.Desktop.Mapping.Offline Namespace / GenerateOfflineMap Class / ExportRasterTileCache Method
The map whose raster service content will be exported
The parameters to use for the export
Example Version

ExportRasterTileCache Method
Export raster tile caches from the map using the specified ExportTileCacheParams. This method must be called on the MCT. Use QueuedTask.Run.
Syntax
public void ExportRasterTileCache( 
   Map map,
   ExportTileCacheParams cacheParams
)

Parameters

map
The map whose raster service content will be exported
cacheParams
The parameters to use for the export
Exceptions
ExceptionDescription
This method or property must be called within the lambda passed to QueuedTask.Run.
Map cannot be null
Extent cannot be null or empty
Map and extent spatial references must be equal
No raster tile cache content to export
Remarks
Exported tile caches are copied to the specified ExportTileCacheParams.DestinationFolder. Use GetCanExportRasterTileCache to determine if a map has raster service content that can be exported. Raster tile caches can be exported from tiled map services and image services.
If a map has no raster service content that can be exported a System.InvalidOperationException is thrown. At the conclusion of the export, a layer is created for each exported tile cache.
Example
Export Map Raster Tile Cache Content
//namespace ArcGIS.Desktop.Mapping.Offline
var extent = MapView.Active.Extent;
var map = MapView.Active.Map;

//await if needed...
QueuedTask.Run(() =>
{
  //Does the map have any exportable raster content?
  var canExport = GenerateOfflineMap.Instance.GetCanExportRasterTileCache(map);
  if (canExport)
  {
    //Check the available LOD scale ranges
    var scales = GenerateOfflineMap.Instance.GetExportRasterTileCacheScales(map, extent);
    //Pick the desired LOD scale
    var max_scale = scales[scales.Count() / 2];

    //Configure the export parameters
    var export_params = new ExportTileCacheParams()
    {
      Extent = extent,//Use same extent as was used to retrieve scales
      MaximumUserDefinedScale = max_scale
      //DestinationFolder = .... (optional)
    };
    //If DestinationFolder is not set, output defaults to project
    //offline maps location set in the project properties. If that is 
    //not set, output defaults to the current project folder location.

    //Do the export. Depending on the MaximumUserDefinedScale and the
    //area of the extent requested, this can take minutes for tile packages
    //over 1 GB or less if your network speed is slow...
    GenerateOfflineMap.Instance.ExportRasterTileCache(map, export_params);
  }
});
Requirements

Target Platforms: Windows 11, Windows 10

ArcGIS Pro version: 3 or higher.
See Also