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
This page describes what you can do with data files and lists supported data file formats. It also provides details on how to use a data file in your app, which are summarized in the following steps:
- Create, sideload
Sideloading is the process of deploying a file or package to a device without using a network. , or download the data fileA data file is a stand-alone file containing geographic data that can be sideloaded on to a device. It is typically used in offline applications that never connect to a network. onto your user's device. - Access the data file
A data file is a stand-alone file containing geographic data that can be sideloaded on to a device. It is typically used in offline applications that never connect to a network. . - Create a layer
A layer is a reference to a collection of geographic data that is used to access and display data. The data for layers are typically provided by the basemap layer service and data services. referencing the data fileA data file is a stand-alone file containing geographic data that can be sideloaded on to a device. It is typically used in offline applications that never connect to a network. . - Apply a renderer
A renderer is a collection of rules and symbols used to display the data in a layer. to define symbolsA symbol defines the properties used to display a geometry or text. for features in the layer (Optional). - Add the layer
A layer is a reference to a collection of geographic data that is used to access and display data. The data for layers are typically provided by the basemap layer service and data services. to a mapA map is a collection of layers that are displayed in 2D. It is typically composed of a basemap layer and data layers. or sceneA scene is a collection of layers that are displayed in 3D. It is typically composed of a basemap layer, data layers, and 3D data. .
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.
What you can do with data files
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.
Supported data file formats
The following data files are supported:
| Data file type | Data access API | Layer API | Can query? | Can edit? | License level |
|---|---|---|---|---|---|
| Vector tile package | VectorTileCache | ArcGISVectorTiledLayer | No | No | Lite |
| Image tile package | TileCache | ArcGISTiledLayer, ArcGISTiledElevationSource | No | No | Lite |
| Mobile geodatabase | Geodatabase | FeatureLayer | 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. | ArcGISSceneLayer | No | No | Lite |
| Shapefile | ShapefileFeatureTable | FeatureLayer | 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 | RasterLayer | No | No | Standard |
| OGC GeoPackage | GeoPackageFeatureTable | FeatureLayer | Yes | Yes | Standard |
| OGC GeoPackage | GeoPackageRaster | RasterLayer | No | No | Standard |
| OGC KML file (.kml file or compressed .kmz file)§ | KmlDataset§ | KmlLayer§ | No | Yes | Standard |
| Electronic Nautical Chart (S-57). For display in maps only. Not supported in scenes.§ | EncCell§ | EncLayer§ | No | No | Standard |
| Other (e.g. GeoJSON) | FeatureCollection | FeatureCollectionLayer | Yes | Yes | Lite |
Vector tile package
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 project's assets folder, and then instantiate a vector tiled layer, ArcGISVectorTiledLayer, with the following code:
// Load the vector tile package data from assets.
final vectorTilePackageData = await rootBundle.load(
'assets/vtpk/$vectorTilePackageName',
);
// Get the temporary directory path on the platform.
final platformTempDir = await getTemporaryDirectory();
final pathToFile =
'${platformTempDir.absolute.path}/$vectorTilePackageName';
// Create a file in the temporary directory and write the vector
// tile package data to it.
final vectorTilePackageFile = File(pathToFile);
vectorTilePackageFile.writeAsBytesSync(
vectorTilePackageData.buffer.asUint8List(),
flush: true,
);
// Create a vector tiled layer using the URI of the file.
final vectorTiledLayer = ArcGISVectorTiledLayer.withUri(
Uri.file(pathToFile),
);
// Create a basemap with the vector tiled layer as the base layer.
final basemap = Basemap.withBaseLayer(vectorTiledLayer);
// Create a map with the basemap and set it to the map view controller.
final map = ArcGISMap.withBasemap(basemap);
mapViewController.arcGISMap = map;
Image tile package
Image tiled layers are typically used to display pregenerated tiled data as basemaps.tpk/.tpkx file. The file contains a tile cache of the data and metadata about the layer, packaged into a single, portable file.
- To create a tile package file, run the ArcGIS Pro geoprocessing tool Create Map Tile Package.
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.
// Get the application documents directory.
final appDir = await getApplicationDocumentsDirectory();
// Create a tile cache, specifying the path to the local tile package.
const tilePackageName = 'SanFrancisco.tpkx';
final pathToFile = '${appDir.absolute.path}/$tilePackageName';
final tileCache = TileCache.withFileUri(Uri.parse(pathToFile));
// Create a tiled layer with the tile cache.
final tiledLayer = ArcGISTiledLayer.withTileCache(tileCache);
// Create a basemap with the tiled layer.
final basemap = Basemap.withBaseLayer(tiledLayer);
// Create a map with the basemap.
final map = ArcGISMap.withBasemap(basemap);
// Set the map to the map view controller.
mapViewController.arcGISMap = map;
Create elevation source from tile package
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.
// Get the application documents directory.
final appDir = await getApplicationDocumentsDirectory();
// Create a tile cache, specifying the path to the local tile package.
const tilePackageName = 'WorldElevation3DTiles.tpkx';
final pathToFile = '${appDir.absolute.path}/$tilePackageName';
final tileCache = TileCache.withFileUri(Uri.parse(pathToFile));
// Use the tile cache to create an ArcGIS tiled elevation source.
final localElevationSource =
ArcGISTiledElevationSource.withTileCache(tileCache);
// Create a surface with the elevation source.
final elevationSurface = Surface()
..elevationSources.add(localElevationSource);
// Set the elevation source into your scene as its base surface.
final scene = ArcGISScene()..baseSurface = elevationSurface;
// Set the scene to the scene view controller.
sceneViewController.arcGISScene = scene;
Feature layer
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.png file) or a document, that is associated with individual features in a geodatabase or feature layer.
Mobile geodatabase
Mobile geodatabases
To create a mobile geodatabase that you can sideload
- In ArcGIS Pro, follow the instructions in the ArcGIS Pro help topic Create a mobile geodatabase.
To create a mobile geodatabase with this SDK:
- 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.geodatabasefile. - Instantiate a
FeatureTablefrom one of the mobile geodatabase's tables or create a new one using aTableDescriptionand associatedFieldDescriptionobjects and callingGeodatabase.createTable(). - Create a new
FeatureLayerfrom the feature table and add it to the map. Optionally, create a newRendererto 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.
If you have copied the geodatabase into the app's documents directory, you can instantiate a feature layer.
// Get the application documents directory.
final appDir = await getApplicationDocumentsDirectory();
// Create a file to the geodatabase.
final geodatabaseFile = File(
'${appDir.absolute.path}/LA_Trails/LA_Trails.geodatabase',
);
// Create a geodatabase with the file uri and load the geodatabase.
final geodatabase = Geodatabase.withFileUri(geodatabaseFile.uri);
await geodatabase.load();
// Get the feature table using the table name.
final geodatabaseFeatureTable = geodatabase.getGeodatabaseFeatureTable(
tableName: 'Trailheads',
);
// Check if the feature table is not null.
if (geodatabaseFeatureTable != null) {
// Create a feature layer with the feature table.
final geodatabaseFeatureLayer = FeatureLayer.withFeatureTable(
geodatabaseFeatureTable,
);
// Clear the operational layers and add the feature layer to the map.
map.operationalLayers.clear();
map.operationalLayers.add(geodatabaseFeatureLayer);
}
GeoPackage
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 the
GeoPackagewith the.gpkgfile path. -
Load the GeoPackage and then examine its list of
GeoPackageFeatureTables. -
Create a
FeatureLayerfrom one of theGeoPackageFeatureTables and add it as an operational layer to the map.
If you have copied the geodatabase file into the app's documents directory, you can instantiate a feature layer.
// Get the application documents directory.
final appDir = await getApplicationDocumentsDirectory();
// Create a file to the geopackage.
final geopackageFile = File(
'${appDir.absolute.path}/AuroraCO/AuroraCO.gpkg',
);
// Create a geopackage with the file uri and load it.
final geopackage = GeoPackage.withFileUri(geopackageFile.uri);
await geopackage.load();
// Get the geopackage feature tables.
final geopackageFeatureTables = geopackage.geoPackageFeatureTables;
// Create a feature layer with the first geopackage feature table.
final geopackageFeatureLayer = FeatureLayer.withFeatureTable(
geopackageFeatureTables.first,
);
// Clear the operational layers and add the geopackage feature layer
// to the map.
map.operationalLayers.clear();
map.operationalLayers.add(geopackageFeatureLayer);
Shapefiles
A shapefile.shp, .dbf, and .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. The.shpfile's associated files (.shx,.dbf, and so on) must be present at the same location. -
Create a
FeatureLayerfrom theShapefileFeatureTableand add it to the map.
If you have copied the shapefiles into the app's documents directory, you can instantiate a feature layer.
// Get the application documents directory.
final appDir = await getApplicationDocumentsDirectory();
// Get the Shapefile from the download resource.
final shapefile = File(
'${appDir.absolute.path}/ScottishWildlifeTrust_reserves/ScottishWildlifeTrust_ReserveBoundaries_20201102.shp',
);
// Create a feature table from the shapefile uri.
final shapefileFeatureTable = ShapefileFeatureTable.withFileUri(
shapefile.uri,
);
// Create a feature layer for the Shapefile feature table.
final shapefileFeatureLayer = FeatureLayer.withFeatureTable(
shapefileFeatureTable,
);
// Clear the operational layers and add the feature layer to the map.
map.operationalLayers.clear();
map.operationalLayers.add(shapefileFeatureLayer);
Raster layer
Raster data consists of a matrix of cells in which each individual cell contains a value representing information. You can visualize this raster data by defining specific renderers. Several raster formats are supported that allow you to use data from satellite and aerial images or photographs, for example. 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, Add raster data.