Select to view content in your preferred language

useing tools with Python

812
3
03-24-2011 01:41 AM
ManuelBeck
New Contributor
Hello,
I just started the Spatial Analyst training and got a problem already. I cant start tools in the command line of python. The instruction says "Only tools that are in ArcToolbox can be run from the command line". So, the spatial analyst extension is enabled and the tools work fine in the toolbox, but when I type the tool in the command line he cant find it (for slope e.g. he only finds sys). Do I have to connect Python with my toolbox in some way?
I^ve reinstalled ArcInfo allready (my whole system) but nothing changed.
I hope someone could help.
Thanks

Greetings

m
Tags (2)
0 Kudos
3 Replies
DanPatterson_Retired
MVP Emeritus
If you are using version 10 of ArcMap, see the code examples here
http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//009z000000v2000000.htm
0 Kudos
ManuelBeck
New Contributor
Thanks for the help. I´ve found a free training (Using Python in ArcGIS Desktop 10) ,too. But I totally got no clue about programming and python. Therefore I need some help to find a starting point.

So e.g. I want to slope my input Raster (Elev) into a output (SlpDeg) and the unit is Degree. This is the code from ArcGis10 Help:

import arcpy
from arcpy import env
from arcpy.sa import *
env.workspace = "C:/sapyexamples/data"
outSlope = Slope("elevation", "DEGREE", 0.3043)
outSlope.save("C:/sapyexamples/output/outslope01")

And I modified it this way

import arcpy
from arcpy import env
from arcpy.sa import *
env.workspace = "Elev"

outSlope = Slope("elevation", "DEGREE", 0.3043) ???

outSlope.save("SlpDeg")

How to modify the outSlope?

Thanks
Greetings
m
0 Kudos
DanPatterson_Retired
MVP Emeritus
you need to specify a workspace for the grid to go to
import arcpy
from arcpy import env
from arcpy.sa import *
env.workspace = "c:/putYourFolderNameHereAsInTheExample")
outSlope = Slope("Elev","DEGREE", 0.3043)
outSlope.save("c:/putYourFolderNameHereAsInTheExample/SlpDeg")


0 Kudos