Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question
up vote 3 down vote accepted

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

import arcpy
from import *

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

output = con((direction > 0) & (direction <= 180), direction + 180, direction)"conned.tif")
share|improve this answer
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 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 posting your answer, you agree to the privacy policy and terms of service.

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