1

I have a problem with Map Algebra in ArcMap 10 to convert some codes made by VB, so i need to convert it to python to work in arcmap 10 without problem. and can any one help me how do i deal with map algebra in arcmap10?

the code:

con([Direction to univer] > 0 & [Direction to univer] <= 180,[Direction to univer] + 180,[Direction to univer] - 180) 

Thank you.

3

You should be able to do the processing directly in python without much fuss:

import arcpy
from arcpy.sa import *

direction = Raster("direction-to-univer.tif")

output = con((direction > 0) & (direction <= 180), direction + 180, direction)
output.save("conned.tif")
6
  • Thanks SCW, but i have a problem with line 4, arcmap crashed!!!!!
    – GIS Man
    Feb 17 '11 at 3:13
  • GIS Man: did it return an error? You'll also need to set the working environment with 'arcpy.env.workspace' which includes your raster, and change the 'direction-to-univer.tif' to the file you're trying to analyze.
    – scw
    Feb 17 '11 at 4:34
  • OK, thank you very much, i followed all steps but i have the same problem which arcmap crashed.this is all steps which i followed it:*Open ArcMap with raster layersopen python windowwrite code/ (import arcpy/arcpy.env.workspace = "E:/data/myproject/....."/from arcpy.sa import */direction = Raster("direction to univer")/output = con(direction > 0 && direction <= 180, direction + 180, direction), so the problem is here with finish output line specified 'last word "direction"'.
    – GIS Man
    Feb 18 '11 at 18:43
  • Unfortunately, the same error is exist!!!!!,i do not know, what can i do with this problem,i do all steps but the same error is exist.thanks
    – GIS Man
    Feb 18 '11 at 21:35
  • Could you try it again? I've updated the code to change how Con() is run as it doesn't seem to follow standard python syntax.
    – scw
    Feb 18 '11 at 23:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.