What is a data file?
A data file is a local file stored on a device that contains data that can be displayed by a layer in a map or scene. Some data files also support editing, querying, and analyzing data. Data files can be created using a number of tools or scripts, or downloaded from the internet.
You use data files to create offline applications that:
- Display maps or scenes without a network connection.
- Can access, display, and analyze data sideloaded onto a device.
- Include data with an application install.
- Collect data on devices that never have access to a network connection.
- Share datasets between applications using peer-to-peer technology.
Types of data files
The following types of data files are supported directly by the ArcGIS Maps SDKs for Native Apps:
Data file type | Data access API | Layer API | Can query? | Can edit? | License level |
---|---|---|---|---|---|
Vector tile package | Vector Tile Cache | ArcGI | No | No | Lite |
Map tile package | Tile Cache | Map Tile Layer | No | No | Lite |
Mobile geodatabase | Mobile Geodatabase | Feature Layer | Yes | Yes | Lite |
Scene Layer Package | Access a Scene Layer Package (.slpk ) file directly from the ArcGIS Scene Layer | ArcGI | No | No | Lite |
Shapefile | Shapefile Feature Table | Feature Layer | Yes | Yes | Standard |
Local raster file The following raster formats are supported: ASRP/USRP, CIB, CADRG/ECRG, DTED, GeoPackage Raster, GeoTIFF/TIFF, HFA, HRE, IMG, JPEG, JPEG2000, Mosaic Dataset in SQLite, NITF, PNG, RPF, SRTM, CRF, and MrSID. | Raster | Raster Layer | No | No | Standard |
OGC GeoPackage (feature data) | Geo | Feature Layer | Yes | Yes | Standard |
OGC GeoPackage (raster data) | Geo | Raster Layer | No | No | Standard |
OGC KML file | KM | KM | No | Yes | Standard |
Electronic Nautical Chart (S-57) For display in maps only. Not supported in scenes. | EN | EN | No | No | Standard |
Other (e.g. GeoJSON) | Feature Collection | Feature Collection Layer | Yes | Yes | Lite |
Files created by ArcGIS (vector tile packages, image tile packages, mobile geodatabases, and scene layer packages) can be used with a free Lite license. Files that require custom parsing code and are used with a Feature Collection Layer
can also be used with a free Lite license. Other files require a Standard license.
How to work with data files
The general workflow to work with a data file in an offline application is:
1. Create
To begin working with a data file, you need to have one of the supported data files. You can either create your own data files using ArcGIS Pro, tools, and scripts, or download public data files from the internet.
When choosing a data file to host in your offline app, make sure that its type is also supported by your license level. A license is needed for when you want to deploy your app to production. Some data files such as vector tile package, image tile package, and mobile geodatabase are supported by the Lite license, which is the lowest level license. Meanwhile, to use shapefiles, OGC GeoPackage, KML files, or local raster files, you need a Basic license.
The typical steps to create a data file are:
- Determine the data file you will need in your offline app from the list of supported data files.
- Use tools in ArcGIS Pro or the portal to import dataset.
- Export into the desired data file format.
2. Manage
Once you have your data file, you sideload or download it onto a device. You can then access it directly from local storage. Optionally, you can also include the data file in your application build folder and reference the folder path in your offline app.
The typical steps to manage a data file are:
- Transfer the data file onto your device through sideloading or including it in the application build folder.
- Keep note of the location path of the data file, since you will need to reference it in the application code.
3. Access
To display a data file in your offline app, you typically start with a layer that references the shapefile (either in your device or included in the application build), and add the layer to a map or scene.
Once you have your data file displayed in your offline app, you can perform additional capabilities as supported by your file type. Some types of data file support editing, such as mobile geodatabases and shapefiles, while others are read-only. Shapefiles and mobile geodatabases also allow you to perform SQL queries on them. Additionally, you can apply a renderer to define symbols for features in the layer. Shapefiles, GeoPackages, and mobile geodatabase tables only have a default renderer with black solid symbols when first applied to a layer.
The typical steps to access a data file (in this case, a shapefile) are:
-
Set up your project using one of the ArcGIS Maps SDKs for Native Apps for your platform of choice within your preferred IDE.
- Create a
Shapefile
referencing the shapefile in local storage.Feature Table - Create a
Feature
with theLayer Shapefile
.Feature Table - Add the
Feature
to aLayer Map
displayed in aMap
.View
Code examples
Display a shapefile
After you create and manage your data file (in this case, a shapefile), you can access it in your offline app.
var shapefileTable = new ShapefileFeatureTable("\\path\\to\\shapefile.shp");
var shapefileLayer = new FeatureLayer(shapefileTable);
MainMapView.Map.OperationalLayers.Add(shapefileLayer);
Display features from an OGC GeoPackage
After you create and manage your data file (in this case, an OGC GeoPackage), you can access it in your offline app.
Steps
-
Set up your project using one of the ArcGIS Maps SDKs for Native Apps for your platform of choice within your preferred IDE.
- Create a
Geo
referencing the GeoPackage file in local storage.Package - Load the
Geo
to read its contents.Package - Get a
Geo
from thePackage Feature Table Geo
collection in thePackage Feature Tables Geo
.Package - Create a
Feature
with theLayer Geo
.Package Feature Table - Add the
Feature
to aLayer Map
displayed in aMap
.View
try
{
var geoPackage = await GeoPackage.OpenAsync("\\path\\to\\geopackage.gpkg");
await geoPackage.LoadAsync();
foreach (var table in geoPackage.GeoPackageFeatureTables)
{
var featureLayer = new FeatureLayer(table);
MainMapView.Map.OperationalLayers.Add(featureLayer);
}
}
catch(Exception ex)
{
// Handle error
}
Query features in a shapefile (SQL)
After you create, manage, and access your shapefile, you can query features in it.
Steps
- Create a
Shapefile
referencing the shapefile in local storage.Feature Table - Create a
Query
object and set aParameters where
.Clause - Call
Query
on theFeatures With Parameters Shapefile
.Feature Table
try
{
var shapefileTable = await ShapefileFeatureTable.OpenAsync("\\path\\to\\shapefile");
var queryParameters = new QueryParameters { WhereClause = "Shape__Length > 150" };
var queryResult = await shapefileTable.QueryFeaturesAsync(queryParameters);
foreach(var feature in queryResult)
{
double shapeLength = (double)feature.Attributes["Shape__Length"];
// do something with shapeLength value
}
}
catch (Exception ex)
{
// Handle error
}