Geoprocessing: Difference between revisions

From Wildsong
Jump to navigationJump to search
Brian Wilson (talk | contribs)
Brian Wilson (talk | contribs)
Line 60: Line 60:
==== Trying the Pypi ====
==== Trying the Pypi ====


First install the installer. Get the Windows version for Python 2.6 and run it.
See http://pypi.python.org/pypi/GDAL/
See http://pypi.python.org/pypi/setuptools


Add "C:\Python26\ArcGIS10.0;C:\Python26\ArcGIS10.0\Scripts" to your PATH. That allows your command shell to find and run easy_install. Make sure it's ahead of OSGeo4W so that it does not find Python2.5 instead.
Add "C:\Python26\ArcGIS10.0;C:\Python26\ArcGIS10.0\Scripts" to your PATH. Make sure it's ahead of OSGeo4W so that it does not find Python2.5 instead.


You have to have gdal 1.7 installed before you install Python gdal.
You have to have gdal 1.7 installed before you install Python gdal.
Turns out that's part of the OSGeo4W installation done in the previous section, so now all I have to do is figure out how to reference those files.
Turns out that's part of the OSGeo4W installation done in the previous section, so now all I have to do is figure out how to reference those files.


You have to manually edit the config file!
I could not use "easy_install". I had to run build and install steps so that the compiler could find the right include and lib files.
Here is mine:
 
I downloaded and unpacked the source file from the PyPi link above.
Then I edited the config file! Here is mine:


  [egg_info]
  [egg_info]
Line 81: Line 82:
  '''library_dirs = C:/OSGeo4W/lib'''
  '''library_dirs = C:/OSGeo4W/lib'''


I added the last two lines.
I added the last two lines, to tell it where I put the OSGeo4W files.


Next step WOULD be to go install the Python packages using the installer.
After that I was able to type this
The easy_install GDAL" fails because it can't find the cpl_ports.h file that's installed with gdal in C:\OSGeo4W\


See http://pypi.python.org/pypi/GDAL/
python setup.py build
python setup.py install
 
and it WORKED. Then I was able to do this:
 
python
import osgeo.osr


=== FWTools ===
=== FWTools ===


[http://fwtools.maptools.org/ FWtools] installs a GUI called OpenEV_FW and a shell environment. It comes with python 2.3.4 which is old. I think Frank does this because it's stable and test with his tools. Going to a newer version means the DLL won't work so you'd need to compile your own.
[http://fwtools.maptools.org/ FWtools] installs a GUI called OpenEV_FW and a shell environment. It comes with python 2.3.4 which is old. I think Frank does this because it's stable and test with his tools. Going to a newer version means the DLL won't work so you'd need to compile your own.

Revision as of 19:53, 27 June 2011


Online help: http://webhelp.esri.com/arcgisdesktop/9.1/index.cfm

Different ways to do geoprocessing in ArcGIS

  1. Basic stuff the buffering in ArcMap
  2. From ArcToolbox in either ArcMap or ArcCatalog
  3. Command line, either a shell or from a command window in ArcCatalog; if you run it in an ArcCatalog window it helps you type the right args. Not quite sure why anyone would want to use the command line this way...
  4. Model Builder can be used to invoke standard tools or to call your scripts.
  5. Scripting usually with Python, then calling scripts from one of the above methods.

TIPS

ArcCatalog Tools->Options->Geoprocessing

Check the box to allow overwriting of files, so that you don't end up creating numbered files like water_1 and allstreets_3

Set your default tools directory to something reasonable.

ESRI

See also Model Builder

27-Jun-2011 At ArcGIS release 10 they have a thing called ArcPy. Have to look at that now.

31-Dec-2007 update: ArcGIS Desktop 9.3 includes a new python wrapper module that makes working with ArcObjects a lot easier. I am using ActiveState 2.4.3 with it with good results. It breaks if you try to move up to 2.5.1.

You now just use the python line "import arcgisscripting" instead of directly invoking the COM dispatch thing.

Old notes from ArcGIS 9.1

This guy seems to have slogged through a lot of development with it and collected useful notes: http://www.ollivier.co.nz/support/python.shtm

I can add a new one to his list. I was getting error messages on setting gp.workspace = 'foo' where foo is a valid path. It's because the gp object was hanging around in pythonwin's memory. You should be able to say 'del gp' but I gave up and restarted pythonwin to fix it.

When working with ArcToolbox 9.1 and Python 2.1 I have been having lots of crashes in PythonWin. Using it on a computer with ActiveState 2.4.3 I have not been experiencing the same problems. I am going to try installing 2.4x without removing 2.1 so I can fall back on it... I followed the instructions above.

It still crashes. Oh joy. It does not even crash faster.

Open source

ESRI has broken down and started to use http://www.gdal.org OGR/GDAL] for some things. I need to get the Python bindings installed...

23-Aug-2006 Python+OGR probably not worth messing with right now. From the OGR site: The Python API isn't really well documented at this time, but parallels the C/C++ APIs. The interface classes can be browsed in the pymod/ogr.py (simple features) and pymod/osr.py (coordinate systems) python modules. The pymod/samples/assemblepoly.py sample script is one demonstration of using the python API.

ArcGIS 10 + Python + GDAL

Not using OSGeo4W

I am looking at using OSGeo4W for this. See http://trac.osgeo.org/osgeo4w/

I am installing their version of Python and the GDAL bindings for gdal 1.7 They have 1.8 but no python bindings for it. Typical for Windows stuff. Always incomplete.

OH GRAND. OSGeo4W is built on Python 2.5. I don't understand why Windows has not withered away and died. :-)

Trying the Pypi

See http://pypi.python.org/pypi/GDAL/

Add "C:\Python26\ArcGIS10.0;C:\Python26\ArcGIS10.0\Scripts" to your PATH. Make sure it's ahead of OSGeo4W so that it does not find Python2.5 instead.

You have to have gdal 1.7 installed before you install Python gdal. Turns out that's part of the OSGeo4W installation done in the previous section, so now all I have to do is figure out how to reference those files.

I could not use "easy_install". I had to run build and install steps so that the compiler could find the right include and lib files.

I downloaded and unpacked the source file from the PyPi link above. Then I edited the config file! Here is mine:

[egg_info]
tag_build =
tag_date = 0
tag_svn_revision = 0

[build_ext]
gdal_config = ../../apps/gdal-config
include_dirs = C:/OSGeo4W/include
library_dirs = C:/OSGeo4W/lib

I added the last two lines, to tell it where I put the OSGeo4W files.

After that I was able to type this

python setup.py build
python setup.py install

and it WORKED. Then I was able to do this:

python
import osgeo.osr

FWTools

FWtools installs a GUI called OpenEV_FW and a shell environment. It comes with python 2.3.4 which is old. I think Frank does this because it's stable and test with his tools. Going to a newer version means the DLL won't work so you'd need to compile your own.