Skip To Content ArcGIS for Developers Sign In Dashboard

ArcGIS Runtime SDK for .NET

Feature layer (GeoPackage)

This code sample is available for these platforms:
View Sample on GitHub

Display features from a local GeoPackage.

Image of feature layer geopackage

Use case

A GeoPackage is an OGC standard, making it useful when your project requires an open source data format or when other, non-ArcGIS systems may be creating the data. Accessing data from a local GeoPackage is useful when working in an environment that has an inconsistent internet connection or that does not have an internet connection at all. For example, a department of transportation field worker might source map data from a GeoPackage when conducting signage inspections in rural areas with poor network coverage.

How to use the sample

Pan and zoom around the map. View the data loaded from the geopackage.

How it works

  1. Create a GeoPackage passing the URI string into the constructor.
  2. Load the GeoPackage with GeoPackage.loadAsync
  3. When it's done loading, get the GeoPackageFeatureTable objects from the geopackage with geoPackage.getGeoPackageFeatureTables()
  4. Create a FeatureLayer(featureTable) for each feature table and add it to the map as an operational layer. Add each to the map as an operational layer with map.OperationalLayers.Add(featureLayer).

Relevant API

  • Map
  • FeatureLayer
  • GeoPackage
  • GeoPackageFeatureTable

Offline data

This sample downloads the following items from ArcGIS Online automatically:

  • Aurora, Colorado GeoPackage - GeoPackage with datasets that cover Aurora Colorado: Public art (points), Bike trails (lines), and Subdivisions (polygons), Airport noise (raster), Buildings (raster).


feature table, geopackage, gpkg, OGC, package, standards

Sample Code

    xmlns:esriUI="using:Esri.ArcGISRuntime.UI.Controls" >
    <esriUI:MapView x:Name="MyMapView" />
// Copyright 2017 Esri.
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.
// You may obtain a copy of the License at:
// Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific
// language governing permissions and limitations under the License.

using System;
using ArcGISRuntime.Samples.Managers;
using Esri.ArcGISRuntime.Data;
using Esri.ArcGISRuntime.Mapping;
using System.Linq;
using Windows.UI.Popups;

namespace ArcGISRuntime.UWP.Samples.FeatureLayerGeoPackage
        name: "Feature layer (GeoPackage)",
        category: "Data",
        description: "Display features from a local GeoPackage.",
        instructions: "Pan and zoom around the map. View the data loaded from the geopackage.",
        tags: new[] { "OGC", "feature table", "geopackage", "gpkg", "package", "standards" })]
    public partial class FeatureLayerGeoPackage
        public FeatureLayerGeoPackage()

            // Read data from the GeoPackage

        private async void Initialize()
            // Create a new map centered on Aurora Colorado
            MyMapView.Map = new Map(BasemapType.LightGrayCanvasVector, 39.7294, -104.8319, 9);

            // Get the full path
            string geoPackagePath = GetGeoPackagePath();

                // Open the GeoPackage
                GeoPackage myGeoPackage = await GeoPackage.OpenAsync(geoPackagePath);

                // Read the feature tables and get the first one
                FeatureTable geoPackageTable = myGeoPackage.GeoPackageFeatureTables.FirstOrDefault();

                // Make sure a feature table was found in the package
                if (geoPackageTable == null) { return; }

                // Create a layer to show the feature table
                FeatureLayer newLayer = new FeatureLayer(geoPackageTable);
                await newLayer.LoadAsync();

                // Add the feature table as a layer to the map (with default symbology)
            catch (Exception e)
                await new MessageDialog(e.ToString(), "Error").ShowAsync();

        private static string GetGeoPackagePath()

            return DataManager.GetDataFolder("68ec42517cdd439e81b036210483e8e7", "AuroraCO.gpkg");