13 Haz

Set the GDAL_DATA Environment Variable Programmatically in C#

You can set programmatically to the GDAL_DATA environment variable as follow.

Sample code:


string path = @"C:\gdal\";
SetValueNewVariable("GDAL_DATA", path + "\\data");
SetValueNewVariable("GEOTIFF_CSV", path + "\\data");
SetValueNewVariable("GDAL_DRIVER_PATH", path + "\\gdalplugins");

private static void SetValueNewVariable(string var, string value)
{
    if (System.Environment.GetEnvironmentVariable(var) == null)
       System.Environment.SetEnvironmentVariable(var, value);
}