Advertisement
Advertisement
| 07.18.2008 at 07:18PM PDT, ID: 23578644 |
|
[x]
Attachment Details
|
||
|
[x]
The Solution Rating System
|
||
With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.
Your Input Matters If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support. Thank you! |
||
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: |
# Multi_Output_Map_Algebra_sample.py
# Description:
# Runs an expression built with the Map Algebra language.
# Requirements: None
import arcgisscripting
import glob
import os
gisworkDir = 'c:\Giswork'
def log(s):
f = open("C:/tester.txt","w")
f.write(s)
f.close()
def allLandcoverDonutAndIdSuffix(gisworkDir):
'''Generates all tuples (landcover, donut, idSuffix) from the gisworkDir.'''
##log("1\n")
# Prepare the path to the donuts.
donutDir = os.path.join(gisworkDir, 'landcoverprep', 'Donut')
assert os.path.isdir(donutDir)
##log("2\n")
# Iterate through sequence of top-level landcover subdirectories.
mask = os.path.normpath(os.path.join(gisworkDir, 'Landcoverprep\landcover*'))
##log(mask)
for LDir in glob.glob(mask): # full paths to LandcoverA, LandcoverB, etc.
subdir = os.path.basename(LDir)
##log("3\n")
# Iterate through all numbered landcover subdirs inside.
mask2 = os.path.join(LDir, '*')
for LnumDir in glob.glob(mask2):
# Separate the counter part, the idSuffix and construct
# the related donut numbered directory name.
numSuffix = LnumDir[-2:] # last 2 chars
idSuffix = LnumDir[-4:] # last 4 chars
DnumDir = os.path.normpath(
os.path.join(donutDir, 'DONUT_' + numSuffix))
assert os.path.isdir(DnumDir)
##log("4")
# Generate another output tuple.
yield (LnumDir, DnumDir, idSuffix)
# Create the Geoprocessor object
gp = arcgisscripting.create()
expTemplate = 'CON(ISNULL(%s), %s, %s * -1)'
log("\n===== Output below: ====\n")
for landcover, donut, idSuffix in allLandcoverDonutAndIdSuffix(gisworkDir):
# Construct the expression and the output directory name.
outDir = os.path.join(gisworkDir, 'landcoverprep', 'Results', idSuffix)
log("\n" + outDir)
InExpression = expTemplate % (donut, landcover, landcover)
log(" " + InExpression)
# Check out Spatial Analyst extension license
gp.CheckOutExtension("Spatial")
# Process: MapAlgebra
gp.SingleOutputMapAlgebra_sa(InExpression, outDir)
log("Msg: " + gp.GetMessages())
|