Quantcast
Channel: ArcMap Raster Calculator with Python code - Geographic Information Systems Stack Exchange
Viewing all articles
Browse latest Browse all 2

ArcMap Raster Calculator with Python code

$
0
0

I'm trying use raster calculator that can export a raster to do different average values for for multiple layers. For example, I want to do averages for only the values and layers that are greater than 0. I'm trying to input Python code but it keeps failing. Here is a video where I try and explain my project if you need more context. https://www.youtube.com/watch?v=bt6ecPGjjDA&t=24s

I've also tried putting single quotes on the line but there is still a syntax error.

>>> import arcpy... from arcpy.sa import *... f1 = arcpy.Raster("S:/npenme2/Faunalyze\Feature_KB3_Right_Radius_14497/value")... f2 = arcpy.Raster("S:/npenme2/Faunalyze\Feature_KB1_Right_Radius_14471_RC11/value")... f3 = arcpy.Raster("S:/npenme2/Faunalyze\Feature_KB4_Right_Radius_14510/value")... if value > 1:...     outraster = (f1 + f2 + f3)/3... else:...     outraster = (f1 + f2 +f3)/3 - 1...     f123 = f1 + f2 + f3... outraster = Con(f123 > 0, f123 / 3, f123 / 3 - 1)... outraster.save(S:/npenme2/Faunalyze/rasterCalc)... Parsing error SyntaxError: invalid syntax (line 12)>>> 

I've also tried SQL on the actual raster calculator tool with this query. But it too does not work:

Con("Feature_KB3_Right_Radius_14497"+"Feature_KB4_Right_Radius_14510"+"Feature_KB1_Right_Radius_14471_RC11">0,(("Feature_KB3_Right_Radius_14497"+"Feature_KB4_Right_Radius_14510"+"Feature_KB1_Right_Radius_14471_RC11")/3), ("Feature_KB3_Right_Radius_14497"+"Feature_KB4_Right_Radius_14510"+"Feature_KB1_Right_Radius_14471_RC11")/3-1)) 

Viewing all articles
Browse latest Browse all 2

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>