Using GDAL from Unity

Hello,

I want to read a raster map from my Unity application. I planned to use Geospatial Data Abstraction Library(GDAL) for this task. This is a C++ library but it has a C# wrapper which handles C++ calls. I tried to use its C# wrapper from the unity. However, I could not achieve. Finally, I got the error below:

Failed to load ‘Assets/GDAL/gdal_wrap.dll’ with error '%1 is not a valid Win32 application.
', GetDllDirectory returned ‘’. If GetDllDirectory returned non empty path, check that you’re using SetDirectoryDll correctly.
GameController:Start() (at Assets/Scripts/GameController.cs:58)
GameController:Start() (at Assets/Scripts/GameController.cs:15)

Is there anyone who achieved to use GDAL from Unity?
Or, is there anyone who read raster map from Unity application? If yes, how?
I am waiting for help.

Thanks…

1 Like

In case it helps anyone, here’s the steps I followed:

  1. Navigate in your browser to https://www.gisinternals.com/
  2. Download stable x64 version (e.g. I got release-1911-x64-gdal-3-0-0-mapserver-7-4-0.zip) and unpack to a folder. This assumes you are using 64-bit build. For 32-bit there’s an x86 version available instead, but I haven’t tried it.
  3. Create a Plugins/GDAL folder under your Assets folder in Unity
  4. In unpacked folder, go to bin/ and copy any .dll file to Assets/Plugins/GDAL folder
  5. Go to bin/gdal/csharp/ and copy any .dll file to Assets/Plugins/GDAL folder
  6. Go to bin/ms/csharp/ and copy any .dll file to Assets/Plugins/GDAL folder

And that should pretty much do it.