Click or drag to resize

GeoPackageRaster Class

The GeoPackage raster object which is derived from Raster
Inheritance Hierarchy
SystemObject
  Esri.ArcGISRuntime.RastersRaster
    Esri.ArcGISRuntime.RastersGeoPackageRaster

Namespace:  Esri.ArcGISRuntime.Rasters
Assembly:  Esri.ArcGISRuntime (in Esri.ArcGISRuntime.dll) Version: 100.7.0.0
Syntax
C#
public sealed class GeoPackageRaster : Raster

The GeoPackageRaster type exposes the following members.

Properties
  NameDescription
Public propertyDescription
Gets the description for the GeoPackage raster.
Public propertyFunction
Gets the raster function for this instance.
(Inherited from Raster.)
Public propertyGeoPackage
Gets the GeoPackage from which the raster was loaded.
Public propertyLoadError
Gets the load status of raster.
(Inherited from Raster.)
Public propertyLoadStatus
Gets the load status of raster.
(Inherited from Raster.)
Public propertyPath
Gets the raster path for this instance.
(Inherited from Raster.)
Public propertyRasterType
Gets the type of the raster (data source)
(Inherited from Raster.)
Top
Methods
  NameDescription
Public methodCancelLoad
Cancels an ongoing load.
(Inherited from Raster.)
Public methodCode exampleLoadAsync
Initiates loading of raster.
(Inherited from Raster.)
Public methodRetryLoadAsync
Retry loading raster.
(Inherited from Raster.)
Top
Events
  NameDescription
Public eventLoaded
Occurs when raster is loaded.
(Inherited from Raster.)
Public eventLoadStatusChanged
Occurs when raster's LoadStatus is changed.
(Inherited from Raster.)
Top
Examples

Android

Example Name: RasterLayerGeoPackage

Open a GeoPackage, obtain a raster from the package, and display the table as a `RasterLayer`.

Code example screen shot.

C#
// 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: http://www.apache.org/licenses/LICENSE-2.0
// 
// 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 System.Linq;
using Android.App;
using Android.OS;
using Android.Widget;
using Esri.ArcGISRuntime.Mapping;
using Esri.ArcGISRuntime.UI.Controls;
using ArcGISRuntime.Samples.Managers;
using Esri.ArcGISRuntime.Data;
using Esri.ArcGISRuntime.Rasters;

namespace ArcGISRuntime.Samples.RasterLayerGeoPackage
{
    [Activity (ConfigurationChanges=Android.Content.PM.ConfigChanges.Orientation | Android.Content.PM.ConfigChanges.ScreenSize)]
    [ArcGISRuntime.Samples.Shared.Attributes.OfflineData("68ec42517cdd439e81b036210483e8e7")]
    [ArcGISRuntime.Samples.Shared.Attributes.Sample(
        "Raster layer (GeoPackage)",
        "Data",
        "This sample demonstrates how to open a GeoPackage and show a GeoPackage raster in a raster layer.",
        "The GeoPackage will be downloaded from an ArcGIS Online portal automatically.")]
    public class RasterLayerGeoPackage : Activity
    {
        private MapView _myMapView;

        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            Title = "Raster layer (GeoPackage)";

            // Create the UI, setup the control references and execute initialization
            CreateLayout();
            Initialize();
        }

        private async void Initialize()
        {
            // Create a new map
            _myMapView.Map = new Map(Basemap.CreateLightGrayCanvas());

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

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

                // Read the raster images and get the first one
                Raster gpkgRaster = myGeoPackage.GeoPackageRasters.FirstOrDefault();

                // Make sure an image was found in the package
                if (gpkgRaster == null) { return; }

                // Create a layer to show the raster
                RasterLayer newLayer = new RasterLayer(gpkgRaster);
                await newLayer.LoadAsync();

                // Set the viewpoint
                await _myMapView.SetViewpointAsync(new Viewpoint(newLayer.FullExtent));

                // Add the image as a raster layer to the map (with default symbology)
                _myMapView.Map.OperationalLayers.Add(newLayer);
            }
            catch (Exception e)
            {
                new AlertDialog.Builder(this).SetMessage(e.ToString()).SetTitle("Error").Show();
            }
        }

        private static string GetGeoPackagePath()
        {
            return DataManager.GetDataFolder("68ec42517cdd439e81b036210483e8e7", "AuroraCO.gpkg");
        }

        private void CreateLayout()
        {
            // Create a new vertical layout for the app
            LinearLayout layout = new LinearLayout(this) { Orientation = Orientation.Vertical };

            // Add a map view to the layout
            _myMapView = new MapView(this);
            layout.AddView(_myMapView);

            // Show the layout in the app
            SetContentView(layout);
        }
    }
}
Examples

Xamarin Forms Android

Example Name: RasterLayerGeoPackage

Open a `GeoPackage`, obtain a raster from the package, and display the table as a `RasterLayer`.

Code example screen shot.

C#
// 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: http://www.apache.org/licenses/LICENSE-2.0
// 
// 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 Esri.ArcGISRuntime.Rasters;
using System.Linq;
using Xamarin.Forms;

namespace ArcGISRuntime.Samples.RasterLayerGeoPackage
{
    [ArcGISRuntime.Samples.Shared.Attributes.Sample(
        "Raster layer (GeoPackage)",
        "Data",
        "This sample demonstrates how to open a GeoPackage and show a GeoPackage raster in a raster layer.",
        "The GeoPackage will be downloaded from an ArcGIS Online portal automatically.")]
    [ArcGISRuntime.Samples.Shared.Attributes.OfflineData("68ec42517cdd439e81b036210483e8e7")]
    public partial class RasterLayerGeoPackage : ContentPage
    {
        public RasterLayerGeoPackage()
        {
            InitializeComponent();

            // Read data from the GeoPackage
            Initialize();
        }

        private async void Initialize()
        {
            // Create a new map
            MyMapView.Map = new Map(Basemap.CreateLightGrayCanvas());

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

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

                // Read the raster images and get the first one
                Raster gpkgRaster = myGeoPackage.GeoPackageRasters.FirstOrDefault();

                // Make sure an image was found in the package
                if (gpkgRaster == null) { return; }

                // Create a layer to show the raster
                RasterLayer newLayer = new RasterLayer(gpkgRaster);
                await newLayer.LoadAsync();

                // Set the viewpoint
                await MyMapView.SetViewpointAsync(new Viewpoint(newLayer.FullExtent));

                // Add the image as a raster layer to the map (with default symbology)
                MyMapView.Map.OperationalLayers.Add(newLayer);
            }
            catch (Exception e)
            {
                await Application.Current.MainPage.DisplayAlert("Error", e.ToString(), "OK");
            }
        }

        private static string GetGeoPackagePath()

        {
            return DataManager.GetDataFolder("68ec42517cdd439e81b036210483e8e7", "AuroraCO.gpkg");
        }
    }
}
XAML
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"             
             xmlns:esriUI="clr-namespace:Esri.ArcGISRuntime.Xamarin.Forms;assembly=Esri.ArcGISRuntime.Xamarin.Forms"
             xmlns:mapping="clr-namespace:Esri.ArcGISRuntime.Mapping;assembly=Esri.ArcGISRuntime" 
             x:Class="ArcGISRuntime.Samples.RasterLayerGeoPackage.RasterLayerGeoPackage">
    <esriUI:MapView x:Name="MyMapView"/>
</ContentPage>
See Also
Additional Examples
Hyperlink to ExampleDescription
RasterLayerGeoPackageOpen a `GeoPackage`, obtain a raster from the package, and display the table as a `RasterLayer`.
ReadGeoPackageAdd rasters and feature tables from GeoPackages to a map.