• Stars
    star
    115
  • Rank 305,916 (Top 7 %)
  • Language
    C#
  • License
    MIT License
  • Created over 5 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

GDAL 3.x C# bindings for .NET apps

gdal.netcore Mentioned in Awesome Geospatial Packages CI

A simple (as is) build engine of GDAL 3.7.0 library for .NET.

Packages (NuGet)

MaxRev.Gdal.Core
MaxRev.Gdal.LinuxRuntime.Minimal
MaxRev.Gdal.WindowsRuntime.Minimal
MaxRev.Gdal.MacosRuntime.Minimal.x64
MaxRev.Gdal.MacosRuntime.Minimal.arm64

Table Of Contents

Table of contents generated with markdown-toc

About this library

What is this library

  • Only generates assemblies and binds everything into one package.
  • Provides easy access to GDAL by installing only core and runtime package
  • DOES NOT require installation of GDAL. From 3.7.0 version GDAL_DATA is also shipped. While it contains the proj.db database you can require proj-data grid shifts.

What is not

  • Does not compile all drivers. Only configured, they are listed below. By default GDAL has a lot of internal drivers.
  • Does not change GDAL source code.
  • Does not extend GDAL methods.

How to use

  1. Install core package - MaxRev.Gdal.Core
Install-Package MaxRev.Gdal.Core
  1. Install libraries for your runtime. You can install one of them or all with no conflicts.
Install-Package MaxRev.Gdal.WindowsRuntime.Minimal
Install-Package MaxRev.Gdal.LinuxRuntime.Minimal
Install-Package MaxRev.Gdal.MacosRuntime.Minimal.arm64
Install-Package MaxRev.Gdal.MacosRuntime.Minimal.x64
  1. Initialize libraries in runtime
using MaxRev.Gdal.Core;
...
// call it once, before using GDAL
// this will initialize all GDAL drivers and set PROJ6 shared library paths
GdalBase.ConfigureAll();
  1. Profit! Use it in ordinary flow

Using GDAL functions

If you're struggling using GDAL functions. Here's a good place to start:

Development

How to compile on Windows

Enter win directory to find out how.

How to compile on Unix

Detailed guide is here - unix.

How to compile on macOS

Detailed guide is here - osx.

About build configuration

The current version targets GDAL 3.7.0 with minimal drivers. What stands for 'minimal' - drivers that require no additional dependencies (mainly boost). For example, MySQL driver is not included, because it requires 15+ boost deps. Same goes for Poppler driver. They can be packaged upon request.

Drivers included PROJ(9.2.0), GEOS(3.11.1), and more than 200 other drivers. To view full list of drivers, To view the complete list of drivers, you can view the full list with GDAL's API or see property DriversInCurrentVersion here.

NOTE: Runtime drivers availability may differ. Ask me about a specific driver for runtime. Please issue if I need to mention any packages.

Building runtime libraries

Current version is targeting GDAL 3.7.0 version. 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.

FAQ

Q: Packages does not work on CentOS 7, Ubuntu 18.04

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.

Q: Can I compile it on Ubuntu or another Unix-based system?

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).

Q: Projections are not working as expected

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.

Q: Some drivers complain about missing data files

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.

Q: Missing {some} drivers, can you add more?

A: Feel free to contribute and I will help you you to add them. Here's the my additional answer.

Q: GDAL functions are not working as expected

A: Try to search an issue on github. In 98% of cases, they are working fine.

Q: Some types throw exceptions from SWIG on Windows

A: Yes, currently there are some redundant types in OGR namespace. This will be fixed in the next builds.

Q: In some methods performance is slower on Unix

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.

Q: OSGeo.OGR.SpatialReference throws System.EntryPointNotFoundException exception

A: That's a problem with swig bindings. Please, use SpatialReference type from OSR namespace. More info here and here.

Q: Packages does not work on MacOS Monterey or Big Sur

A: The current version of packages was compiled on MacOS Ventura and 13.3 SDK respectively. In future, this can be changed to build upon a lower SDK version starting version 11 but not below.

About and Contacts

This work is based on GDAL and GDAL bindings by jgoday.

Contact me in Telegram - MaxRev.

Enjoy!

Acknowledgements

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.