Indexof

IndexofMaxRev.Gdal & PROJ-Data: Enabling High-Precision Datum Grid Shifts in .NET › Last update: Mar 18, 2026@jackcoolAbout › #MaxRevGdalPROJ-Data

Precision Mapping: Configuring MaxRev.Gdal with PROJ Datum Grid Shifts

In high-precision Geographic Information Systems, standard 3-parameter or 7-parameter transformations often fall short, leaving errors of several meters. For sub-decimetric accuracy, datum grid shifts (using .gsb for horizontal or .gtx for vertical) are the industry standard. While the popular MaxRev.Gdal NuGet package for .NET simplifies GDAL deployment by bundling proj.db, it does not include the massive multi-gigabyte proj-data repository by default. Without these grids, PROJ falls back to less accurate mathematical approximations. This guide explains how to bridge this gap by manually integrating proj-data and ensuring the underlying PROJ engine recognizes your grid files at runtime.

Table of Content

Purpose

The primary goal of this configuration is to:

  • Eliminate Transformation Error: Shift from ~5m error margins to <0.1m by using localized distortion grids.
  • Enable Vertical Transformations: Allow for "Ellipsoid to Geoid" height conversions (e.g., using EGM96 or NAVD88).
  • Standardize Environments: Ensure that your .NET application behaves identically on Windows, Linux, and macOS by controlling the PROJ search path.

The Mechanism: How PROJ Locates Grids

When you call GdalBase.ConfigureAll() in a MaxRev-powered app, the library sets an internal environment variable called PROJ_LIB to point to the bundled proj.db. However, PROJ can look in multiple directories for assets. To use grid shifts, you must provide the proj-data files (like ntv2_0.gsb) and tell PROJ to look in their specific directory in addition to the bundled database path.

Step-by-Step: Linking proj-data to MaxRev.Gdal

1. Acquire the Grid Files

Download the specific grids for your region or the entire collection from the official PROJ-data repository. Place these files in a predictable folder in your project output, for example: [AppPath]/proj-data/.

2. Initialize MaxRev.Gdal

Call the standard configuration method first to load native binaries.

using MaxRev.Gdal.Core;
GdalBase.ConfigureAll();

3. Override PROJ_LIB at Runtime

You must append your custom path to the existing search paths. In .NET, use OSGeo.GDAL.Gdal.SetConfigOption to ensure the setting reaches the underlying C++ PROJ context.

// Get the path where your grid files are stored
string customProjData = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "proj-data");

// Set the PROJ_LIB (or PROJ_DATA in newer versions) configuration option
OSGeo.GDAL.Gdal.SetConfigOption("PROJ_LIB", customProjData);

4. Force PROJ Search Path (Optional but Recommended)

If using very complex transformations, you can explicitly set the search path via the OSR (Spatial Reference) engine:

OSGeo.OSR.Osr.SetPROJSearchPaths(new[] { customProjData });

Use Case: Converting Local Datums

A developer is building a .NET 8 utility to convert old Canadian survey data (NAD27) to modern WGS84.

  • The Problem: Without the ntv2_0.gsb grid file, the transformation is off by several meters because the "mathematical" shift doesn't account for local crustal distortions.
  • The Fix: The developer adds the 13MB ntv2_0.gsb to their project and sets the PROJ_LIB path in C#.
  • The Result: The transformation accuracy improves to within 10cm, matching official government survey results.

Best Results

Configuration Recommendation Benefit
Path Separator Use semicolon (;) on Win, colon (:) on Linux Allows multi-directory searching.
PROJ_DEBUG Set to "ON" during dev Console will log if a grid was successfully loaded or skipped.
File Naming Lower-case only Prevents Linux/Unix case-sensitivity issues.

FAQ

Does MaxRev.Gdal.Universal include these grids?

No. The Universal package includes the runtime binaries for all platforms, but it keeps the data payload small to avoid massive NuGet download sizes. You must always provide supplemental grids manually.

How do I know if the grid is actually being used?

Set Gdal.SetConfigOption("PROJ_DEBUG", "ON");. When you perform a transformation, watch the standard output. You should see a line saying: PROJ: +proj=gridshift: open grid ntv2_0.gsb.

Should I use PROJ_LIB or PROJ_DATA?

PROJ version 7+ renamed the variable to PROJ_DATA, but GDAL and MaxRev still frequently look for PROJ_LIB for backward compatibility. Setting both is the safest approach in 2026.

Disclaimer

MaxRev.Gdal is a community-maintained wrapper. Always verify that your NuGet version matches the PROJ version of your grid files. Grid shift files are often subject to specific national licensing; ensure compliance before redistributing proj-data with your software. March 2026.

Tags: MaxRev_Gdal, PROJ_Data, Grid_Shifts, DotNet_GIS



What’s new

Close [x]
Loading special offers...