What is offline data?
Offline data is data that is generated and downloaded from an offline-enabled data service
You use offline data to create offline apps that:
- Support disaster recovery operations when infrastructure has been damaged.
- Enable mobile workers to collect and edit data.
- Provide current, detailed maps to large workforces.
- Display offline vector tile or map tile basemap layers.
Types of offline data
There are two types of offline data:
-
Feature data is data created from a feature service. The offline data is downloaded as a geodatabase
A geodatabase is a spatial data storage format that can contain multiple datasets of geographic features and non-spatial tabular data, as well as attachments, field domain definitions, and relationships between layers/tables. file that can contain data for feature layers, non-spatial tables, and attachments. This data can be created, updated, or deleted according to the capabilities of the source feature service. Offline data edits can be synchronized with the source feature service whenever a network connection is available. To support offline data, the feature service must be sync-enabled. Later, when the offline data is no longer needed, you should unregister geodatabase to clean up the tracking metadata stored on the feature service. -
Tile data is data created from one of the following service types and downloaded as a read-only package of static tiles. Depending on the type of service, tiles will be downloaded as vector tiles or map tiles:
Source tile service type Downloaded files Basemap styles service (vector basemap layer A basemap layer is the layer in a map or scene that displays basemap data. The data source for a basemap layer is typically a basemap service. )VTPK A vector tile package, also known as a VTPK, is a read-only data file containing static tiles of vector data. + Item Resource CacheAn item resource cache is a package of style resources downloaded from a vector tile style item in ArcGIS. Basemap styles service (image basemap layer A basemap layer is the layer in a map or scene that displays basemap data. The data source for a basemap layer is typically a basemap service. )TPK An map tile package, formerly known as image tile package, is a read-only data file containing static, pre-rendered map tiles. Custom basemap style created with the Vector Tile Style Editor VTPK + Item Resource Cache An item resource cache is a package of style resources downloaded from a vector tile style item in ArcGIS. Offline-enabled vector tile service VTPK Offline-enabled map tile service TPK An map tile package, formerly known as image tile package, is a read-only data file containing static, pre-rendered map tiles.
How to work with offline data
The general workflow to work with offline data in an offline application
1. Create
To begin working with offline data, you need to create a data service. To create a data service, you use a data management tool
The typical steps to create a feature service, vector tile service, or map tile service are:
- Import data into ArcGIS or define a new dataset using data management tools.
- Create a new hosted feature layer item from the data.
- Go to the item page
An item page is a web page in ArcGIS Online or the developer dashboard used to access and manage the properties for an item and the content it references such as a web map, hosted layer, or file. in your ArcGIS portal. - In the Settings, scroll down to the Editing section.
- Click the Enable Sync (required for offline use and collaboration) and Enable editing check box, then Save.
2. Manage
Once your service is published, you need to enable it for offline use. Go to the Settings tab in the item page of the service to enable it for offline use. You also need to set a proper sharing level for your service in order for it to be discoverable.
The typical steps to manage a feature service, vector tile service, or map tile service are:
- Go to the item page of your hosted feature layer in your ArcGIS portal
- In the Settings tab, scroll down to the Editing section.
- Click the Enable Sync (required for offline use and collaboration) and Enable editing check box, then Save.
- Optionally, configure the item and service properties, editing and synchronization, and sharing and security settings for your feature service.
3. Access
After publishing a data service and enabling it for offline use, you can request a geographic area covered within that service to be taken offline. The service will generate offline data which you can then download to your device. You will also specify where to store the downloaded data on your local device.
After you download offline data, you can apply it to your map. The capabilities you can do with your offline data depend on the source service:
-
If your source service is a feature service, you can query, edit features, and use feature layer in your map. You can also synchronize your offline edits with the source feature service, or unregister geodatabase when you no longer need the offline data.
Geodatabase unregistration
When you download offline data from a feature service, the offline data is downloaded as a geodatabase file and registered with the feature service. This allows the feature service to track edits and compare its state with the offline data, and enables synchronizing the offline data with the feature service. When the offline data is no longer needed, it is best practice to unregister it to clean up the tracking metadata stored on the feature service.
Geodatabase unregistration is the process of removing the association between a local geodatabase containing offline data and the corresponding feature service on the server. Once unregistered, changes made to the local geodatabase will not synchronize back to the server. To unregister, a network connection is required.
-
If your source service is a vector tile service, you can add the vector tile package (VTPK) and optional item resource cache as a basemap to your map.
-
If your source service is a map tile service, you can add the tile package (TPK) as a basemap to your map.
There are two steps to access offline data:
-
When you download offline data and apply it on your map for the first time. This requires a network connection. The typical steps to access a feature service, vector tile service, or map tile service in your offline app are:
-
Set up your project using one of the ArcGIS Maps SDKs for Native Apps
ArcGIS Maps SDKs for Native Apps, previously known as ArcGIS Runtime SDKs, are developer products for building mapping and spatial analysis applications for native devices. for your platform of choice within your preferred IDE. - Define an area of interest from the feature layer you want to take offline.
- Create a
Geodatabasereferencing the hosted feature layer item.Sync Task - Get a set of default parameters to download the area of interest, and modify them to not download attachments.
- Create a
Generate.Geodatabase Job - Start the job and wait for it to complete, returning a ready to use
Geodatabasethat references the downloaded geodatabase file. - Use this to access
Geodatabase. You can use aFeature Tables Geodatabaseto create anFeature Table Feature Layer, which can be added to a map.
-
-
When you access previously downloaded offline data from your local storage. This does not require a network connection.
If your source service is a feature service, you start by creating a
Geodatabasefrom the downloaded geodatabase file:ArcGIS Maps SDK for .NET ArcGIS Maps SDK for .NET ArcGIS Maps SDK for Swift ArcGIS Maps SDK for Kotlin ArcGIS Maps SDK for Java ArcGIS Maps SDK for Qt ArcGIS Maps SDK for Flutter Use dark colors for code blocks Copy Geodatabase offlineGeodatabase = await Geodatabase.OpenAsync("path\\to\\file.geodatabase");
Code examples
Display offline data from a feature service
You can access offline data from your feature service in your offline app.
var featureServiceUri = new Uri("https://services2.arcgis.com/ZQgQTuoyBrtmoGdP/arcgis/rest/services/WaterDistributionNetwork/FeatureServer");
GeodatabaseSyncTask geodatabaseSyncTask = await GeodatabaseSyncTask.CreateAsync(featureServiceUri);
GenerateGeodatabaseParameters gdbGenerateParameters
= await geodatabaseSyncTask.CreateDefaultGenerateGeodatabaseParametersAsync(areaOfInterest.Extent);
gdbGenerateParameters.ReturnAttachments = false;
GenerateGeodatabaseJob job = geodatabaseSyncTask.GenerateGeodatabase(gdbGenerateParameters, "path\\to\\file.geodatabase");
// Optionally listen for progress changes
job.ProgressChanged += (o,e) => { };
Geodatabase generateResult = await job.GetResultAsync();
MainMapView.Map.OperationalLayers.AddRange(
generateResult.GeodatabaseFeatureTables.Select(table => new FeatureLayer(table))
);
Display offline data from a vector tile service
You can access offline data from your vector tile service in your offline app.
ExportVectorTilesTask exportVectorTileCacheTask = await ExportVectorTilesTask.CreateAsync(hostedItem);
ExportVectorTilesParameters exportVectorTilesParams = await exportVectorTileCacheTask.CreateDefaultExportVectorTilesParametersAsync(
areaOfInterest: areaOfInterest,
maxScale: 100);
ExportVectorTilesJob exportJob = exportVectorTileCacheTask.ExportVectorTiles(
parameters: exportVectorTilesParams,
vectorTileCachePath: "path\\to\\something.vtpk",
itemResourceCachePath: "path\\to\\cache\\dir");
ExportVectorTilesResult exportResult = await exportJob.GetResultAsync();
var offlineVectorTileLayer = new ArcGISVectorTiledLayer(
vectorTileCache: exportResult.VectorTileCache,
itemResourceCache: exportResult.ItemResourceCache
);
MainMapView.Map.Basemap = new Basemap(offlineVectorTileLayer);Display offline data from a map tile service
You can access offline data from your map tile service in your offline app.
ExportTileCacheTask exportImageTilesTask = await ExportTileCacheTask.CreateAsync(imageTileUrl);
ExportTileCacheParameters exportImageTileParams = await exportImageTilesTask.CreateDefaultExportTileCacheParametersAsync(
areaOfInterest: areaOfInterest,
minScale: 500_000_000,
maxScale: 10_000_000);
ExportTileCacheJob exportImageTilesJob = exportImageTilesTask.ExportTileCache(exportImageTileParams, "\\path\\to\\file.tpk");
TileCache exportImageTileCacheResult = await exportImageTilesJob.GetResultAsync();
ArcGISTiledLayer imageTiledLayer = new ArcGISTiledLayer(exportImageTileCacheResult);
Edit offline data from a feature service
You can perform edits on the data from the feature service while disconnected. Edits are stored on device storage and you must synchronize the edits with the feature service when you go back online. The owner of a feature service can configure how data can be edited. In your offline application, you can read the configuration settings from the Geodatabase object properties, such as Editable, Can, Editable.
You can edit your offline data in the following ways:
Add a feature
- Create an in-memory
Featureby callingCreateon aFeature() Geodatabase.Feature Table - Optionally, modify the
Feature's geometryA geometry is a geometric shape, such as a point, polyline, or polygon, that contains one or more coordinates and a spatial reference. and/or attributesAttributes are fields and values for a single feature or non-spatial record. They are typically stored in a database or service such as a feature service. . - Add the
Featureto the offline data by callingAddon theFeature() Geodatabase.Feature Table
var newFeature = geodatabaseFeatureTable.CreateFeature();
newFeature.Geometry = new MapPoint(x: -117.157, y: 32.707, spatialReference: SpatialReferences.Wgs84);
newFeature.SetAttributeValue("Name", "Friar's house");
try
{
await geodatabaseFeatureTable.AddFeatureAsync(newFeature);
}
catch(Exception ex)
{
// Report the error
}
Update a feature
- Modify the
geometryand/orattributesof theFeature. - Pass the modified feature
A feature is a single record, also known as a row, that represents a real-world entity. It typically contains a geometry (point, multipoint, polyline, or polygon) and attributes but it can also contain just attributes. toUpdateon the feature'sFeature() Geodatabase.Feature Table
existingFeature.Geometry = new MapPoint(x: -1.9025, y: 52.4559, spatialReference: SpatialReferences.Wgs84);
existingFeature.SetAttributeValue("Name", "Edgbaston");
if (existingFeature.FeatureTable is FeatureTable featureTable)
{
try
{
await featureTable.UpdateFeatureAsync(existingFeature);
}
catch (Exception ex)
{
// Report the error
}
}
Delete a feature
- Pass the
FeaturetoDeleteon the feature'sFeature() Geodatabase.Feature Table
if (existingFeature.FeatureTable is FeatureTable featureTable)
{
try
{
await featureTable.DeleteFeatureAsync(existingFeature);
}
catch (Exception ex)
{
// Report the error
}
}Synchronize offline data with source feature service
You can synchronize the edits with its source feature service. This operation requires a network connection. You can choose whether to upload edits from offline data to the source feature service, download edits from the source feature service to the offline data, or both (default configuration).
Steps
- Create a
Geodatabasereferencing the source feature service for the offline data.Sync Task - Use the
Geodatabaseto generate defaultSync Task Sync.Geodatabase Parameters - Use the
Geodatabaseto create aSync Task Geodatabase.Sync Job - Start the job. If it completes without errors, the offline data and feature service will be in sync.
Uri serviceUrl = offlineGeodatabase.Source;
GeodatabaseSyncTask gdbSyncTask = await GeodatabaseSyncTask.CreateAsync(serviceUrl);
SyncGeodatabaseParameters offlineSyncParams = await gdbSyncTask.CreateDefaultSyncGeodatabaseParametersAsync(offlineGeodatabase);
SyncGeodatabaseJob syncJob = gdbSyncTask.SyncGeodatabase(offlineSyncParams, offlineGeodatabase);
IReadOnlyList<SyncLayerResult> syncResult = await syncJob.GetResultAsync();
if (syncJob.Status != Esri.ArcGISRuntime.Tasks.JobStatus.Succeeded)
{
// Handle errors
}















