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.


Use case

Useful for applications which consume data maintained by a local source on the device running the application.

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:

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


GeoPackageFeatureTables, OGC, gpkg, 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
        "Feature layer (GeoPackage)",
        "This sample demonstrates how to open a GeoPackage and show a GeoPackage feature table in a feature layer.",
        "The GeoPackage will be downloaded from an ArcGIS Online portal automatically."
    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");