GeoPackage Support

With the recent 14.2 release, ThinkGeo Desktop and Web now have support for GeoPackage .gpkg files!

The GeoPackage file format is an open specification defined by the Open Geospatial Consortium (OGC) and has seen widespread support from various government, commercial, and open source organizations.

In this post, we’ll dig into an example using a public GeoPackage file of Olympic National Park and demonstrate how to render and style the vector features contained in the .gpkg.

Tip

To see the new GeoPackage functdionality in action, just clone the HowDoI samples, run the solution and then click on the ‘Display a GeoPackage File’ under the ‘Map Offline Data’ section of the samples.

While the sample below is using ThinkGeo Desktop for WPF, the GdalFeatureLayer will also work the same in ThinkGeo Web (WebApi and Blazor).

Sample Overview

A sample GeoPackage dataset of Olympic National Park rendered  in the Desktop 'HowDoI' samples.

In the ‘Display a GeoPackage File’ sample, we use a public .gpkg file that contains a vector-based dataset of polygons, lines and points.

To style the polygon (park area), an semi-transparent light green style is used. A light blue style is used for all line features and a red style is used for all points.

While the styling in this sample is very simple, there are endless other styling options that are discussed more thoroughly in this older blog post on Styling Your Maps.

Code Walkthrough

The code below shows the minimum required to create a new GdalFeatuyreLayer using a .gpkg file and styling the vector data using a PointStyle, LineStyle and AreaStyle:

  
            // Create the gdalFeatureLayers
            var gdalFeatureLayer = new GdalFeatureLayer(@"./Data/GeoPackage/mora_surficial_geology.gpkg");
            gdalFeatureLayer.FeatureSource.ProjectionConverter = projectionConverter;
            gdalFeatureLayer.ZoomLevelSet.ZoomLevel01.DefaultPointStyle = PointStyle.CreateSimplePointStyle(PointSymbolType.Circle,GeoColors.LightRed,4);
            gdalFeatureLayer.ZoomLevelSet.ZoomLevel01.DefaultLineStyle = LineStyle.CreateSimpleLineStyle(GeoColor.FromArgb(128,GeoColors.LightSteelBlue), 2F, GeoColors.Black, 2F, false);
            gdalFeatureLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle = AreaStyle.CreateSimpleAreaStyle(GeoColor.FromArgb(64,GeoColors.LightGreen), GeoColors.Black, 1);
            gdalFeatureLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
            layerOverlay.Layers.Add(gdalFeatureLayer);
  

It’s also worth noting that the dataset in this sample is in EPSG:26910 (NAD83 / UTM Zone 10N). And because our basemap is in EPSG:3857(Spherical Mercator), we apply a ProjectionConverter to the LayerOverlay so the .gpkg features are properly reprojected on the map. This can be done with the 3 lines of code below:

  
            // Creat a new layerOverlay to hold the gdalFeatureLayers
            var layerOverlay = new LayerOverlay();
            var projectionConverter = new ProjectionConverter(26910, 3857);
            projectionConverter.Open();
  

Summary

We hope today’s post has been helpful. If you have any questions or if you have a topic you would like to learn more about, please email sales@thinkgeo.com or schedule a meeting to talk in person.


About ThinkGeo

We are a GIS software company founded in 2004 and located in Frisco, TX. Our clients are in more than 40 industries including agriculture, energy, transportation, government, engineering, IT, and defense. We pride ourselves on our excellent service and transparency. ThinkGeo offers a variety of products and services to meet almost any GIS application need. We can even help you develop your next project - anywhere from a few hours of consulting to outsourcing an entire project. To learn more, email us at sales@thinkgeo.com, or call us direct at 1-214-449-0330.

Previous
Previous

Device Geolocation in MAUI

Next
Next

ThinkGeo UI 14.2 Released