Add rasters and feature tables from a GeoPackage to a map.
Use case
The OGC GeoPackage specification defines an open standard for sharing raster and vector data. You may want to use GeoPackage files to support file-based sharing of geographic data.
How to use the sample
When the sample loads, the feature tables and rasters from the GeoPackage will be shown on the map.
How it works
Create a GeoPackage object using the path the local geoPackage.
Connect to the GeoPackage.loadStatusChanged signal.
Load the geoPackage geoPackage.load(), then iterate through the available rasters, exposed by geopackage.geoPackageRasters.
For each raster, create a raster layer then add it to the map.
Iterate through available feature tables, exposed by geopackage.geoPackageFeatureTables.
For each feature table, create a feature layer then add it to the map.
Relevant API
GeoPackage
GeoPackage.loadStatusChanged
GeoPackage.geoPackageFeatureTables
GeoPackage.geoPackageRasters
GeoPackageFeatureTable
GeoPackageRaster
Offline data
Read more about how to set up the sample's offline data here.
This sample features a GeoPackage with datasets that cover Aurora, Colorado: Public art (points), Bike trails (lines), Subdivisions (polygons), Airport noise (raster), and liquour license density (raster).
Additional information
GeoPackage uses a single SQLite file (.gpkg) that conforms to the OGC GeoPackage Standard. You can create a GeoPackage file (.gpkg) from your own data using the create a SQLite Database tool in ArcGIS Pro.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
// [WriteFile Name=ReadGeoPackage, Category=Maps]// [Legal]// Copyright 2018 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.// [Legal]import QtQuick 2.6import Esri.ArcGISRuntime 100.14import Esri.ArcGISExtras 1.1Rectangle {
id: rootRectangleclip: truewidth: 800height: 600 readonly property string dataPath: System.userHomePath + "/ArcGIS/Runtime/Data/gpkg/"MapView {
id: mapViewanchors.fill: parentComponent.onCompleted: {
// Set the focus on MapView to initially enable keyboard navigation forceActiveFocus();
}
Map {
id: mapinitialViewpoint: vc
Basemap {
initStyle: Enums.BasemapStyleArcGISTopographic
}
}
ViewpointCenter {
id: vccenter: Point {
x: -104.8319y: 39.7294spatialReference: SpatialReference {
wkid: 4326 }
}
targetScale: 500000 }
}
// Load and read the GeoPackageGeoPackage {
id: gpkgpath: dataPath + "AuroraCO.gpkg"// Initial check to see if GeoPackage is loaded and not emptyonLoadStatusChanged: {
if (loadStatus !== Enums.LoadStatusLoaded)
return;
if (!gpkg.geoPackageRasters.length > 0 && !gpkg.geoPackageFeatureTables.length > 0)
return;
// For each raster, create a raster layer and add the layer to the mapfor (let k = 0; k < gpkg.geoPackageRasters.length; k++){
const raster = gpkg.geoPackageRasters[k];
const rasterLayer = ArcGISRuntimeEnvironment.createObject("RasterLayer", {raster: raster}, gpkg);
rasterLayer.opacity = 0.55;
map.operationalLayers.append(rasterLayer);
}
// For each feature table, create a feature layer and add the layer to the mapfor (let i = 0; i < gpkg.geoPackageFeatureTables.length; i++){
const featureLayer = ArcGISRuntimeEnvironment.createObject("FeatureLayer", {featureTable: gpkg.geoPackageFeatureTables[i]}, gpkg);
map.operationalLayers.append(featureLayer);
}
}
Component.onCompleted: load()
}
}