ArcMap Raster Calculator with Python codeArcpy how to conduct addition in a script, function needed?How to...
Why "had" in "[something] we would have made had we used [something]"?
Multiplicative persistence
Mixing PEX brands
The IT department bottlenecks progress. How should I handle this?
Why does AES have exactly 10 rounds for a 128-bit key, 12 for 192 bits and 14 for a 256-bit key size?
What should you do when eye contact makes your subordinate uncomfortable?
What happens if you are holding an Iron Flask with a demon inside and walk into an Antimagic Field?
How do apertures which seem too large to physically fit work?
Plot of a tornado-shaped surface
Mimic lecturing on blackboard, facing audience
Is aluminum electrical wire used on aircraft?
Why can Carol Danvers change her suit colours in the first place?
Why is the "ls" command showing permissions of files in a FAT32 partition?
What is Cash Advance APR?
Are Captain Marvel's powers affected by Thanos' actions in Infinity War
Unexpected behavior of the procedure `Area` on the object 'Polygon'
putting logo on same line but after title, latex
How to rewrite equation of hyperbola in standard form
Can disgust be a key component of horror?
Strong empirical falsification of quantum mechanics based on vacuum energy density
How to hide some fields of struct in C?
Yosemite Fire Rings - What to Expect?
Does Doodling or Improvising on the Piano Have Any Benefits?
Does the Linux kernel need a file system to run?
ArcMap Raster Calculator with Python code
Arcpy how to conduct addition in a script, function needed?How to extract values of one point dataset to second point dataset based on proximity using R?Getting the majority value for a number of rasters in a conditional statementStandardising DEM raster for a MCEWhy does SAGA raster calculator interpolate between cell values?GRASS 7 raster map calculatorReclass or other if/then logic expression in field calculatorAdding building footprints to DEM in ArcGIS Desktop?Alternatives to QGIS raster calculator?Raster calculator ERROR000732, python scripter
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 guys need more context. https://www.youtube.com/watch?v=bt6ecPGjjDA&t=24s
Here is the Python code that won't work. Maybe this is too simple for what I'm trying to accomplish.
>>> import arcpy
... from arcpy.sa import *
... f1 = arcpy.Raster("S:/npenme2/FaunalyzeFeature_KB3_Right_Radius_14497/value")
... f2 = arcpy.Raster("S:/npenme2/FaunalyzeFeature_KB1_Right_Radius_14471_RC11/value")
... f3 = arcpy.Raster("S:/npenme2/FaunalyzeFeature_KB4_Right_Radius_14510/value")
... if value > 1:
... outraster = (f1 + f2 + f3)/3
... else:
... outraster = (f1 + f2 +f3)/3 - 1
...
...
... outraster.save("S:/npenme2/Faunalyze/rasterCalc")
...
Parsing error IndentationError: expected an indented block (line 7)
>>>
arcgis-desktop arcpy raster-calculator
New contributor
add a comment |
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 guys need more context. https://www.youtube.com/watch?v=bt6ecPGjjDA&t=24s
Here is the Python code that won't work. Maybe this is too simple for what I'm trying to accomplish.
>>> import arcpy
... from arcpy.sa import *
... f1 = arcpy.Raster("S:/npenme2/FaunalyzeFeature_KB3_Right_Radius_14497/value")
... f2 = arcpy.Raster("S:/npenme2/FaunalyzeFeature_KB1_Right_Radius_14471_RC11/value")
... f3 = arcpy.Raster("S:/npenme2/FaunalyzeFeature_KB4_Right_Radius_14510/value")
... if value > 1:
... outraster = (f1 + f2 + f3)/3
... else:
... outraster = (f1 + f2 +f3)/3 - 1
...
...
... outraster.save("S:/npenme2/Faunalyze/rasterCalc")
...
Parsing error IndentationError: expected an indented block (line 7)
>>>
arcgis-desktop arcpy raster-calculator
New contributor
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))
– Neharika Penmetcha
52 mins ago
1
Please don't use comments to add additional information, edit your question instead so the info is all in the one place.
– user2856
12 mins ago
add a comment |
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 guys need more context. https://www.youtube.com/watch?v=bt6ecPGjjDA&t=24s
Here is the Python code that won't work. Maybe this is too simple for what I'm trying to accomplish.
>>> import arcpy
... from arcpy.sa import *
... f1 = arcpy.Raster("S:/npenme2/FaunalyzeFeature_KB3_Right_Radius_14497/value")
... f2 = arcpy.Raster("S:/npenme2/FaunalyzeFeature_KB1_Right_Radius_14471_RC11/value")
... f3 = arcpy.Raster("S:/npenme2/FaunalyzeFeature_KB4_Right_Radius_14510/value")
... if value > 1:
... outraster = (f1 + f2 + f3)/3
... else:
... outraster = (f1 + f2 +f3)/3 - 1
...
...
... outraster.save("S:/npenme2/Faunalyze/rasterCalc")
...
Parsing error IndentationError: expected an indented block (line 7)
>>>
arcgis-desktop arcpy raster-calculator
New contributor
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 guys need more context. https://www.youtube.com/watch?v=bt6ecPGjjDA&t=24s
Here is the Python code that won't work. Maybe this is too simple for what I'm trying to accomplish.
>>> import arcpy
... from arcpy.sa import *
... f1 = arcpy.Raster("S:/npenme2/FaunalyzeFeature_KB3_Right_Radius_14497/value")
... f2 = arcpy.Raster("S:/npenme2/FaunalyzeFeature_KB1_Right_Radius_14471_RC11/value")
... f3 = arcpy.Raster("S:/npenme2/FaunalyzeFeature_KB4_Right_Radius_14510/value")
... if value > 1:
... outraster = (f1 + f2 + f3)/3
... else:
... outraster = (f1 + f2 +f3)/3 - 1
...
...
... outraster.save("S:/npenme2/Faunalyze/rasterCalc")
...
Parsing error IndentationError: expected an indented block (line 7)
>>>
arcgis-desktop arcpy raster-calculator
arcgis-desktop arcpy raster-calculator
New contributor
New contributor
edited 1 min ago
Vince
14.7k32749
14.7k32749
New contributor
asked 54 mins ago
Neharika PenmetchaNeharika Penmetcha
1
1
New contributor
New contributor
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))
– Neharika Penmetcha
52 mins ago
1
Please don't use comments to add additional information, edit your question instead so the info is all in the one place.
– user2856
12 mins ago
add a comment |
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))
– Neharika Penmetcha
52 mins ago
1
Please don't use comments to add additional information, edit your question instead so the info is all in the one place.
– user2856
12 mins ago
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))
– Neharika Penmetcha
52 mins ago
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))
– Neharika Penmetcha
52 mins ago
1
1
Please don't use comments to add additional information, edit your question instead so the info is all in the one place.
– user2856
12 mins ago
Please don't use comments to add additional information, edit your question instead so the info is all in the one place.
– user2856
12 mins ago
add a comment |
1 Answer
1
active
oldest
votes
The error tells you exactly what is wrong and where IndentationError: expected an indented block (line 7)
. You need to indent lines in your if clause:
if value > 1:
outraster = (f1 + f2 + f3)/3
else:
outraster = (f1 + f2 +f3)/3 - 1
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "79"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Neharika Penmetcha is a new contributor. Be nice, and check out our Code of Conduct.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fgis.stackexchange.com%2fquestions%2f316420%2farcmap-raster-calculator-with-python-code%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
The error tells you exactly what is wrong and where IndentationError: expected an indented block (line 7)
. You need to indent lines in your if clause:
if value > 1:
outraster = (f1 + f2 + f3)/3
else:
outraster = (f1 + f2 +f3)/3 - 1
add a comment |
The error tells you exactly what is wrong and where IndentationError: expected an indented block (line 7)
. You need to indent lines in your if clause:
if value > 1:
outraster = (f1 + f2 + f3)/3
else:
outraster = (f1 + f2 +f3)/3 - 1
add a comment |
The error tells you exactly what is wrong and where IndentationError: expected an indented block (line 7)
. You need to indent lines in your if clause:
if value > 1:
outraster = (f1 + f2 + f3)/3
else:
outraster = (f1 + f2 +f3)/3 - 1
The error tells you exactly what is wrong and where IndentationError: expected an indented block (line 7)
. You need to indent lines in your if clause:
if value > 1:
outraster = (f1 + f2 + f3)/3
else:
outraster = (f1 + f2 +f3)/3 - 1
answered 13 mins ago
user2856user2856
30.5k258106
30.5k258106
add a comment |
add a comment |
Neharika Penmetcha is a new contributor. Be nice, and check out our Code of Conduct.
Neharika Penmetcha is a new contributor. Be nice, and check out our Code of Conduct.
Neharika Penmetcha is a new contributor. Be nice, and check out our Code of Conduct.
Neharika Penmetcha is a new contributor. Be nice, and check out our Code of Conduct.
Thanks for contributing an answer to Geographic Information Systems Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fgis.stackexchange.com%2fquestions%2f316420%2farcmap-raster-calculator-with-python-code%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
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))
– Neharika Penmetcha
52 mins ago
1
Please don't use comments to add additional information, edit your question instead so the info is all in the one place.
– user2856
12 mins ago