MapPiloteGeopackageHelper 1.2.1
There is a newer version of this package available.
See the version list below for details.
See the version list below for details.
dotnet add package MapPiloteGeopackageHelper --version 1.2.1
NuGet\Install-Package MapPiloteGeopackageHelper -Version 1.2.1
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="MapPiloteGeopackageHelper" Version="1.2.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="MapPiloteGeopackageHelper" Version="1.2.1" />
<PackageReference Include="MapPiloteGeopackageHelper" />
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add MapPiloteGeopackageHelper --version 1.2.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: MapPiloteGeopackageHelper, 1.2.1"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package MapPiloteGeopackageHelper@1.2.1
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=MapPiloteGeopackageHelper&version=1.2.1
#tool nuget:?package=MapPiloteGeopackageHelper&version=1.2.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
MapPiloteGeopackageHelper
Modern .NET library for creating, reading, and bulk-loading GeoPackage (GPKG) data using SQLite and NetTopologySuite. Note that in version 1.2.1 I have split the repository on github into two, hope it simplifies understanding:
- MapPiloteGeopackageHelper The core library with tests.
- MapPiloteGeopackageHelperExamples Example projects that uses the latest published Nuget package.
Quick Start - Modern Fluent API
// Create/open GeoPackage with fluent API
using var geoPackage = await GeoPackage.OpenAsync("data.gpkg", srid: 3006);
// Create layer with schema
var layer = await geoPackage.EnsureLayerAsync("cities", new Dictionary<string, string>
{
["name"] = "TEXT",
["population"] = "INTEGER",
["area_km2"] = "REAL"
});
// Bulk insert with progress
var progress = new Progress<BulkProgress>(p =>
Console.WriteLine($"Progress: {p.PercentComplete:F1}%"));
await layer.BulkInsertAsync(features,
new BulkInsertOptions(BatchSize: 1000, CreateSpatialIndex: true),
progress);
// Query with async streaming
await foreach (var city in layer.ReadFeaturesAsync(
new ReadOptions(WhereClause: "population > 100000", Limit: 10)))
{
Console.WriteLine($"City: {city.Attributes["name"]} - {city.Attributes["population"]} people");
}
// Count and delete operations
var count = await layer.CountAsync("population < 50000");
var deleted = await layer.DeleteAsync("population < 10000");
WAL Mode Support (New!)
Enable WAL (Write-Ahead Logging) mode for better concurrency and performance:
// Create GeoPackage with WAL mode enabled
CMPGeopackageCreateHelper.CreateGeoPackage(
"data.gpkg",
srid: 3006,
walMode: true,
onStatus: Console.WriteLine);
// WAL mode with default SRID (3006)
CMPGeopackageCreateHelper.CreateGeoPackage("data.gpkg", walMode: true);
// Backward compatible - existing code continues to work
CMPGeopackageCreateHelper.CreateGeoPackage("data.gpkg", 3006);
WAL Mode Benefits:
- Better Concurrency: Multiple readers can access the database while a writer is active
- Improved Performance: Better performance for write-heavy workloads
- Atomic Commits: Better crash recovery and data integrity
- No Manual PRAGMA: No need to manually execute
PRAGMA journal_mode = WAL
Modern Features
| Feature | Description | Example |
|---|---|---|
| Async/Await | Proper async support with CancellationToken | await layer.BulkInsertAsync(...) |
| Fluent API | Chain operations naturally | GeoPackage.OpenAsync().EnsureLayerAsync() |
| Progress Reporting | Track long-running operations | IProgress<BulkProgress> |
| Options Objects | Clean configuration, no parameter soup | BulkInsertOptions(BatchSize: 1000) |
| Streaming | IAsyncEnumerable for large datasets |
await foreach (var item in ...) |
| Rich Queries | WHERE, LIMIT, ORDER BY support | ReadOptions(WhereClause: "pop > 1000") |
| Conflict Handling | Insert policies (Abort/Ignore/Replace) | ConflictPolicy.Ignore |
| CRUD Operations | Count, Delete with conditions | await layer.DeleteAsync("status = 'old'") |
| WAL Mode | Write-Ahead Logging for concurrency | CreateGeoPackage(path, walMode: true) |
API Comparison
Modern API (Recommended)
// One-liner with progress and options
using var gp = await GeoPackage.OpenAsync("data.gpkg");
var layer = await gp.EnsureLayerAsync("places", schema);
await layer.BulkInsertAsync(features, options, progress);
Traditional API (Still Supported)
// Multi-step process with optional WAL mode
CMPGeopackageCreateHelper.CreateGeoPackage(path, srid, walMode: true);
GeopackageLayerCreateHelper.CreateGeopackageLayer(path, name, schema);
CGeopackageAddDataHelper.BulkInsertFeatures(path, name, features);
Available CreateGeoPackage Overloads
// Basic creation
CMPGeopackageCreateHelper.CreateGeoPackage("path.gpkg");
// With custom SRID
CMPGeopackageCreateHelper.CreateGeoPackage("path.gpkg", srid: 4326);
// With status callback
CMPGeopackageCreateHelper.CreateGeoPackage("path.gpkg", onStatus: Console.WriteLine);
// With SRID and callback
CMPGeopackageCreateHelper.CreateGeoPackage("path.gpkg", 4326, Console.WriteLine);
// With WAL mode (default SRID)
CMPGeopackageCreateHelper.CreateGeoPackage("path.gpkg", walMode: true);
// Full control: SRID + WAL + callback
CMPGeopackageCreateHelper.CreateGeoPackage("path.gpkg", 4326, true, Console.WriteLine);
Reference Links (GeoPackage Specification)
- GeoPackage Encoding Standard - https://www.geopackage.org/spec/
- OGC Standard page - https://www.ogc.org/standard/geopackage/
- Core tables (spec sections)
- gpkg_contents: https://www.geopackage.org/spec/#_contents
- gpkg_spatial_ref_sys: https://www.geopackage.org/spec/#_spatial_ref_sys
- gpkg_geometry_columns: https://www.geopackage.org/spec/#_geometry_columns
- Binary geometry format - https://www.geopackage.org/spec/#gpb_format
What This Library Does
- Creates GeoPackages with required core tables
- Creates layers (tables) with geometry + custom attribute columns
- Bulk writes features with validation and progress tracking
- Streams features back with filtering and paging
- Modern async patterns with cancellation support
- Schema inspection and validation
- Optional WAL mode for improved concurrency and performance
Getting Started
- Install:
dotnet add package MapPiloteGeopackageHelper - Explore: Check out
FluentApiExampleproject - Inspect: Use
MapPiloteGeopackageHelperSchemaBrowserfor unknown files - Learn: Traditional patterns in
MapPiloteGeopackageHelperHelloWorld
Open the generated .gpkg files in QGIS, ArcGIS, or any GIS software!
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net8.0
- Microsoft.Data.Sqlite.Core (>= 9.0.8)
- NetTopologySuite (>= 2.6.0)
- SQLitePCLRaw.bundle_e_sqlite3 (>= 3.0.1)
-
net9.0
- Microsoft.Data.Sqlite.Core (>= 9.0.8)
- NetTopologySuite (>= 2.6.0)
- SQLitePCLRaw.bundle_e_sqlite3 (>= 3.0.1)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
New Fluent API