[FWTools] Using GDAL in Python IDE

Matt Wilkie matt.wilkie at gov.yk.ca
Thu Sep 28 17:59:35 EDT 2006


I've managed to get ESRI geoprocessing and gdal available in Interactive 
  Python[0], at least to the point of being able to import and do a 
couple of 5 line scripts. I don't know if this is the right or the best 
way (probably not), but it seems to work.

I have python installed in 3 locations (listed in the order installed). 
When I installed ipy and it's dependencies I told it to use the arcgis 
python install as it's home. I haven't been brave enough to try and get 
arc and gdal to use the same python install, but I imagine it possible 
as they both use the same version (at present).

  - c:\python32	: from ArcGIS 9.1 devkit
    Python 2.3.5 (#62, Feb  8 2005, 16:23:02) [MSC v.1200 32 bit 
(Intel)] on win32
  - c:\local\fwtools\python	: fwtools 1.0.5
    Python 2.3.5 (#62, Feb  8 2005, 16:23:02) [MSC v.1200 32 bit 
(Intel)] on win32
  - c:\cygwin\bin	:
    Python 2.4.3 (#1, May 18 2006, 07:40:45) [GCC 3.3.3 (cygwin 
special)] on cygwin

My windows registry pythonpath is (set by python install program):
	[HKEY_LOCAL_MACHINE\SOFTWARE\Python\PythonCore\2.3\PythonPath]
	@="C:\\Python23\\Lib;C:\\Python23\\DLLs;C:\\Python23\\Lib\\lib-tk"

I've modified the fwtools shell slightly, These are the relevant 
environment vars:
	FWTOOLS_DIR=c:\local\fwtools
	GDAL_DATA=c:\local\fwtools\data
	GDAL_DRIVER_PATH=c:\local\fwtools\gdal_plugins
	GEOTIFF_CSV=c:\local\fwtools\data
	PROJ_LIB=c:\local\fwtools\proj_lib
	PYTHONPATH=c:\local\fwtools\pymod

	Path=c:\local\fwtools\bin;c:\local\fwtools\python;c:\utils;c:\cygwin\bin;C:\arcgis\arcexe9x\bin;%path%
	:: note fwtools comes before cygwin and arcgis

ipy.bat:
	C:\Python23\python.exe C:\Python23\scripts\ipython %*


Sample session: {{ Start > Programs > FWTools }}
--------------------------------
d:\>ipy

d:\>C:\Python23\python.exe C:\Python23\scripts\ipython
Python 2.3.5 (#62, Feb  8 2005, 16:23:02) [MSC v.1200 32 bit (Intel)]
Type "copyright", "credits" or "license" for more information.

IPython 0.7.2 -- An enhanced Interactive Python.
?       -> Introduction to IPython's features.
%magic  -> Information about IPython's 'magic' % functions.
help    -> Python's own help system.
object? -> Details about 'object'. ?object also works, ?? prints more.

In [1]: import gdal

In [2]: import win32com.client

In [3]: gp = win32com.client.Dispatch("esriGeoprocessing.GpDispatch.1")

In [4]: 
gp.AddToolbox("C:/ArcGIS/desktop/ArcGIS/ArcToolbox/Toolboxes/Data Manage
ment Tools.tbx")
In [5]:
Do you really want to exit ([y]/n)?

d:\>
--------------------------------

My big wish is to somehow hook up ipy's command line completion with 
esri's tool tips[1], but I don't know if that is even possible.

[0] http://ipython.scipy.org/moin
[1] 
http://webhelp.esri.com/arcgisdesktop/9.1/published_images/tool_usage.gif

cheers,

-- 
matt wilkie
--------------------------------------------
Geographic Information,
Information Management and Technology,
Yukon Department of Environment
10 Burns Road * Whitehorse, Yukon * Y1A 4Y9
867-667-8133 Tel * 867-393-7003 Fax
http://environmentyukon.gov.yk.ca/geomatics/
--------------------------------------------



More information about the FWTools mailing list