Archive for December, 2009

Using FWTools in Powershell

December 14, 2009 Leave a comment

FWTools is a great tool when working with geographical data. When installed in provides a FWTools command prompt (in the same way as Visual Studio provides a Visual Studio command promt), However, this does not work when using Powershell, ofcouse, and we all prefer Powershell – right? Luckily the setfw.bat that is used to setup the FWTools environment is not that complicated. So here is the powershell equivalent:

$ftdir = "C:\Program Files (x86)\FWTools2.4.6"
[Environment]::SetEnvironmentVariable("FWTOOLS_DIR", $ftdir)

$env:path += ";" + (join-path $ftdir bin)
$env:path += ";" + (join-path $ftdir python)

$temp = join-path $ftdir "proj_lib"
[Environment]::SetEnvironmentVariable("PROJ_LIB", $temp)

$temp = join-path $ftdir "pymod"
[Environment]::SetEnvironmentVariable("PYTHONPATH", $temp);

$temp = join-path $ftdir "data"
[Environment]::SetEnvironmentVariable("GEOTIFF_CSV", $temp);
[Environment]::SetEnvironmentVariable("GDAL_DATA", $temp);

$temp = join-path $ftdir "gdal_plugins"
[Environment]::SetEnvironmentVariable("GDAL_DRIVER_PATH", $temp);

Save the code in a file (i.e. setfw.ps1) and put it in a folder that is added to the path and you will have a powershell command that enables FWTools commands.

Categories: Uncategorized