A simple (as is) build engine of GDAL library for .NET.
Provides a minimal setup without requirements to install heavy GDAL binaries into your system.
MaxRev.Gdal.WindowsRuntime.Minimal
MaxRev.Gdal.LinuxRuntime.Minimal
MaxRev.Gdal.MacosRuntime.Minimal
* [Packages (NuGet)](#packages-nuget) * [Table Of Contents](#table-of-contents) * [**About this library**](#about-this-library) + [What is this library](#what-is-this-library) + [What is not](#what-is-not) * [**How to use**](#how-to-use) + [Universal package](#universal-package) + [Separate core and runtime packages](#separate-core-and-runtime-packages) + [Initialize libraries in runtime](#initialize-libraries-in-runtime) * [Supported runtimes](#supported-runtimes) * [**Using GDAL functions**](#using-gdal-functions) * [**Development**](#development) * [How to compile on Windows](#how-to-compile-on-windows) * [How to compile on Unix](#how-to-compile-on-unix) * [About build configuration](#about-build-configuration) * [Building runtime libraries](#building-runtime-libraries) * [FAQ](#faq) - [Q: Packages does not work on CentOS 7, Ubuntu 18.04](#q-packages-does-not-work-on-centos-7-ubuntu-1804) - [Q: Can I compile it on Ubuntu or another Unix-based system?](#q-can-i-compile-it-on-ubuntu-or-another-unix-based-system) - [Q: Projections are not working as expected](#q-projections-are-not-working-as-expected) - [Q: Some drivers complain about missing data files](#q-some-drivers-complain-about-missing-data-files) - [Q: Missing {some} drivers, can you add more?](#q-missing-some-drivers-can-you-add-more) - [Q: GDAL functions are not working as expected](#q-gdal-functions-are-not-working-as-expected) - [Q: Some types throw exceptions from SWIG on Windows](#q-some-types-throw-exceptions-from-swig-on-windows) - [Q: In some methods performance is slower on Unix](#q-in-some-methods-performance-is-slower-on-unix) - [Q: OSGeo.OGR.SpatialReference throws System.EntryPointNotFoundException exception](#q-osgeoogrspatialreference-throws-systementrypointnotfoundexception-exception) - [Q: Packages does not work on MacOS Catalina or lower](#q-packages-does-not-work-on-macos-catalina-or-lower) - [Q: The first run on MacOS is slow and takes more than 3 seconds](#q-the-first-run-on-macos-is-slow-and-takes-more-than-3-seconds) - [Q: BadImageFormatException on Windows](#q-badimageformatexception-on-windows) - [Q: Publishing the project with runtime packages](#q-publishing-the-project-with-runtime-packages) * [About and Contacts](#about-and-contacts) * [Acknowledgements](#acknowledgements) Table of contents generated with markdown-toc
proj.db
database you may require proj-data
grid shifts.dotnet add package MaxRev.Gdal.Universal
dotnet add package MaxRev.Gdal.Core
# windows supported only for x64
dotnet add package MaxRev.Gdal.WindowsRuntime.Minimal
dotnet add package MaxRev.Gdal.LinuxRuntime.Minimal
dotnet add package MaxRev.Gdal.LinuxRuntime.Minimal.arm64 dotnet add package MaxRev.Gdal.LinuxRuntime.Minimal.x64
dotnet add package MaxRev.Gdal.MacosRuntime.Minimal
dotnet add package MaxRev.Gdal.MacosRuntime.Minimal.arm64 dotnet add package MaxRev.Gdal.MacosRuntime.Minimal.x64
### Initialize libraries in runtime
```csharp
using MaxRev.Gdal.Core;
// call it once, before using GDAL
// this will initialize all GDAL drivers and set PROJ6 shared library paths
GdalBase.ConfigureAll();
This means you can build .NET Framework applications on Linux/MacOS using Mono. Also, any project based on NET Standard 2.0 or higher can utilize this library.
If you're struggling using GDAL functions. Here's a good place to start:
Enter win directory to find out how.
Detailed guide is here - unix.
Detailed guide is here - osx.
The package configuration is marked as minimal. That means you don't have to install GDAL binaries. Also, some uncommon drivers are not available (were not built).
Drivers included PROJ, GEOS, and more than 200 other drivers.
To view the complete list of drivers, see: tests/gdal-formats/supported_drivers.md.
NOTE: Runtime drivers availability may differ. Ask me about a specific driver for runtime. Please issue if I need to mention any packages.
Starting version 3.9.0 the packages can be compiled and run on .NET Framework 4.6.1+. The libraries and gdal-data will be automatically copied to the output directory. See tests/MaxRev.Gdal.Core.Tests.NetFramework for more info.
Each runtime has to be build separately, but this can be done concurrently as they are using different contexts (build folders). Primary operating bindings (in gdal.core package) are build from windows. Still, the resulting core bindings are the same on each runtime package (OS).
To make everything work smoothly, each configuration targets the same drivers and their versions, respectively.
To start building for a specific runtime, see the README.md in a respective directory.
A: These are old distros and are out of support (EOL). Use docker (see this Dockerfile how to package your app) or a newer distro (GLIBC 2.31+). Packages for older systems are difficult to maintain. From 3.6.x version the Debian 11 distro is used. See this for more info.
A: Yes, you can (see unix folder for readme). All you have to do, is to choose one of the latest distros like Ubuntu 22.04 or Debian 11 (recommended). From the 3.6.x version the Debian 11 distro is used by default. It was changed because of EOL of the previous distro (see answer above). Prior to 3.6.x version packages were built on CentOS - glibc of version 2.17. It's the lowest version (in my opinion) that suits all common systems (Ubuntu, Debian, Fedora).
A: This package only contains the proj.db
database. Make sure you have installed proj-data
package. It contains aditional grid shifts and other data required for projections. Add path to your data folder with MaxRev.Gdal.Core.Proj.Configure()
. See this for more info.
A: This is related to the previous package versions (prior to 3.7.0). From 3.7.0 version, GDAL_DATA
folder is also shipped with core package.
A: Feel free to contribute and I will help you you to add them. Here's the my additional answer.
A: Try to search an issue on github. In 98% of cases, they are working fine.
A: Yes, currently there are some redundant types in OGR namespace. This will be fixed in the next builds.
A: Apparently, it's not a fault of the build engine. I did not face this issue and I use this packages in several production environments.
A: That's a problem with swig bindings. Please, use SpatialReference type from OSR namespace. More info here and here.
A: The current version of packages was compiled on MacOS Ventura and 11.3 SDK respectively. Consider updating your system to at least MacOS 13. The systems that reached EOL (end-of-life) won't be supported.
A: It's a known issue related to the linking of the shared libraries. If you find any solution/workaround, please let me know.
Currently, linker tries to find all shared libraries in the @loader_path/
. It should point to the executable directory.
A: Ensure that you are using the same architecture for your project and the runtime package. If you are using AnyCPU, you should use only the x64 runtime package. See the sample project for details in tests/MaxRev.Gdal.Core.Tests.NetFramework.
A: There are several ways to publish. One important thing to keep in mind, that you have to ensure the output folder contains either runtimes/<os>-<arch>/native
path, gdal-data
folder and maxrev.gdal.core.libshared/proj.db
. In most cases this should be handled automatically by dotnet. Usually, we release a runtime-dependent binary. The end user will have to install the .NET runtime, but the size of the app will be small and the build time is faster. Otherwise, you can publish a self-contained app which will include all required .NET runtime libraries. More details on publishing can be found here. Also, see the sample dockerized project for details in tests/MaxRev.Gdal.Core.Tests/Dockerfile.
This work is based on GDAL and GDAL bindings by jgoday.
Contact me in Telegram - MaxRev.
Enjoy!
As the maintainer of this repository, I want to express my heartfelt thanks to Verge Agriculture Inc.. They generously provided the necessary resources that made compiling the macOS bindings and the latest versions of GDAL possible.