Work with data files
Just as layers in your app can use data sourced from online services, such as ArcGIS Online, WFS, or WMS services, layers can also use data from data files stored locally on your user's device. Local data files support scenarios where your users never have a network connection.
- Create, sideload, or download the data file onto your user's device.
- Access the data file.
- Create a layer referencing the data file.
- Apply a renderer to define symbols for features in the layer (Optional).
- Add the layer to a map or scene.
For information on mobile map packages and mobile scene packages, which are also stand-alone files, see Offline maps, scenes, and data or the ArcGIS Pro topics Share a mobile map package and Share a mobile scene package. For details on working with data from services while offline, see Work with offline data.
You can do the following types of things in your app using local data files:
- Display maps or scenes without a network connection.
- Access, display, and analyze geospatial data.
- Include data with the installation of your app.
- Collect data on devices that never have access to a network connection.
- Create new mobile geodatabases, tables, and domains.
- Share datasets between applications using peer-to-peer technology.
The following data files are supported:
|Data file type||Data access API||Layer API||Can query?||Can edit?||License level|
|Vector tile package||No||No||Lite|
|Image tile package||No||No||Lite|
|Mobile geodatabase You can create a geodatabase file (SQLite database) with this API, using ArcGIS Pro or ArcMap, or by downloading offline data from a feature service.||Yes||Yes||Lite|
|Scene layer package For display in scenes only.||N/A Access a Scene Layer Package (.slpk) file directly from the ArcGIS Scene Layer||No||No||Lite|
|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.||No||No||Standard|
|OGC GeoPackage (feature data)||Yes||Yes||Standard|
|OGC GeoPackage (raster data)||No||No||Standard|
|OGC KML file (.kml file or compressed .kmz file)||No||Yes||Standard|
|Electronic Nautical Chart (S-57) For display in maps only. Not supported in scenes.||No||No||Standard|
|Other (e.g. GeoJSON)||Yes||Yes||Lite|
Vector tiled layers contain vector representations of data across a range of scales. Unlike raster tiles, they can adapt to the resolution of their display device as you zoom in and out.
When you create a vector tile package, it must be in the same spatial reference as the map in which it will be displayed.
To use a local vector tile package (
.vtpk file) with your app, copy or sideload the .vtpk file onto the device into your app's documents folder, and then instantiate a vector tiled layer,
ArcGISVectorTiledLayer, with the following code:
Image tiled layers are typically used to display pregenerated tiled data as basemaps. A tile cache can also be used to provide offline elevation data for visualizing 3D terrain in a scene. You can take a portion of tiled data and store it within a single tile package (.tpk or .tpkx) file for completely disconnected scenarios. To store a portion of tile data as a tile package, you must specify area of interest, the tiling scheme, the levels of detail, and the tile format using one of the following approaches:
- Run the ArcGIS Pro python tool, Create Map Tile Package, to create a tile package file.
- In ArcMap, choose File > Share As > Tile Package to create a tile package file, as described in the ArcMap topic, How to create a tile package.
- In ArcMap, choose Share as > ArcGIS Runtime Content to export the map's basemap layer to a tile package file (.tpk) that is output within the ArcGIS Runtime Content folder. For details, see the ArcMap topic Creating ArcGIS Runtime content, which is available with ArcGIS 10.2.1 for Desktop or later. Also see ArcMap's tile packages.
When you create a tile package, it must have the same spatial reference as the map in which it will be displayed.
To create a tiled layer from a tile package file, instantiate an
ArcGISTiledLayer object with the path to the tile package file on the device.
To create an elevation source from a tile package file, instantiate an
ArcGISTiledElevationSource object with the path to the tile package file on the device.
Feature layers allow you to display, select, edit, and query individual features and their attributes. You can work with features offline using features stored in a data file, such as a mobile geodatabase file (
.geodatabase), a GeoPackage file (
.gpkg), or a shapefile (
.shp). You can edit feature geometry and attributes, and, when using a mobile geodatabase, can also edit attachments and related records.
Mobile geodatabases (.geodatabase) can be created with ArcGIS Pro (2.7 or later) or ArcMap (10.2.1 or later). At version 100.14, they can also be created in your app.
To create a mobile geodatabase that you can sideload for use in your app:
In ArcGIS Pro, follow the instructions in the ArcGIS Pro help topic Create a mobile geodatabase.
In ArcMap, follow the instructions in the ArcMap help topic Creating ArcGIS Runtime content.
To create a mobile geodatabase with this API:
- Use the static method
Geodatabase.create()to create a new geodatabase at the provided path.
To display tables from a mobile geodatabase:
- Instantiate the
Geodatabaseobject by opening an existing geodatabase or creating a new one. In either case, you need to specify a path to the
- Instantiate a
FeatureTablefrom one of the mobile geodatabase's tables or create a new one using a
FieldDescriptionobjects and calling
- Create a new
FeatureLayerfrom the feature table and add it to the map. Optionally, create a new
Rendererto symbolize features in the layer. If the layer is based on a new geodatabase table, nothing will appear in the layer until features are created.
GeoPackage is an open, standards-based, platform-independent, portable, self-describing, compact format for transferring geospatial information. It uses a single SQLite file (
.gpkg) that conforms to the OGC GeoPackage standard. You can create a GeoPackage file from your own data using the Create SQLite Database tool in ArcGIS Pro.
To display features stored in a GeoPackage file, you must do the following:
- Instantiate a
- Load the
Geoand then examine its list of
- Create a
FeatureLayerfrom one of the
GeoPackageFeatureTables and add it as an operational layer to the map.
A shapefile is a vector data storage format that contains geometry and attribute data for geographic features. Despite the name, a shapefile dataset is composed of at least three physical files:
.shx. A shapefile may include several other files, such as projection information, spatial indices, attribute indices, and so on.
To create a feature layer from a shapefile (.shp), do the following:
- Instantiate the
ShapefileFeatureTablewith the path to the shapefile. This path must point to the
.shpfile's associated files (
.dbf, and so on) must be present at the same location.
- Create a
ShapefileFeatureTableand add it to the map.
Raster data consists of a matrix of cells in which each individual cell contains a value representing information. For example, satellite or aerial images and photographs for visualizing an area. You can define renderers to display the raster data. Several raster formats are supported. To work offline, copy the raster data onto your device and add the raster dataset to your app using the
Raster class. For more information and a list of supported raster formats, See Add raster data.