<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Unsupported operand error in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/unsupported-operand-error/m-p/352949#M27702</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;If NPP and ZforCDF are rasters on disk, shouldn't they be referenced to Raster objects before all that long calculation?&lt;BR /&gt;Like :&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
NPP = arcpy.Raster(r"D:\PROGRAMMES\LFP_Source_Rocks\ArcGIS\00_LFP_GLOBAL_MODEL\LFP_GLOBAL_Python\OUTPUT.gdb\NPP")
&lt;/PRE&gt;&lt;BR /&gt;etc&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;You beat me to it, but this definitely necessary. Otherwise NPP is a string and that would be why the unsupported operand error comes up with * and / operators. The reason that + works is that strings support +. For example &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
folder = 'C:\\'
file = 'a_file.txt'
full_path = folder + file
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Because you use getParameterAsText(), they are being set to strings. You might be able to use &lt;/SPAN&gt;&lt;A href="http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//000v00000013000000" rel="nofollow noopener noreferrer" target="_blank"&gt;arcpy.getParameter(#)&lt;/A&gt;&lt;SPAN&gt; instead. This would grab the parameter as an object and may work in your case.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 11 Dec 2021 16:33:51 GMT</pubDate>
    <dc:creator>DouglasSands</dc:creator>
    <dc:date>2021-12-11T16:33:51Z</dc:date>
    <item>
      <title>Unsupported operand error</title>
      <link>https://community.esri.com/t5/python-questions/unsupported-operand-error/m-p/352944#M27697</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hello,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm getting an error in my script that I cannot quite understand (I'm pretty new to python).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Please see below code (simplified version) and error (image).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The error comes from the "Calculation of Parameter 5". I've tested the Conditional statement in raster calculator and it works fine. &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I've actually used even more complex Conditional statements within the same script (I'm showing a simplified version here) with no problems at all.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The other thing I'm not sure about is how to use the "OutLocation" variable (Parameter 0) within the save Method for the output of Parameter 5 (CDF). In the Help they only mention the use of the full path for the output.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I've tried with this: &lt;/SPAN&gt;&lt;STRONG&gt;CDF.save(OutLocation) + "CDF3"&lt;/STRONG&gt;&lt;SPAN&gt; but there is obviously something wrong. Using ArcView 10.0&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;ERROR:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;[ATTACH=CONFIG]30072[/ATTACH]&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;CODE:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;import arcpy import string from arcpy import env arcpy.env.overwriteOutput=True from arcpy.sa import * arcpy.CheckOutExtension("Spatial")&amp;nbsp;&amp;nbsp; # Set the output location and extent&amp;nbsp; OutLocation = arcpy.GetParameterAsText(0)&amp;nbsp; arcpy.env.extent = arcpy.Extent(-180.0, -90.0, 180.0, 90.0)&amp;nbsp;&amp;nbsp; # Input strings, variables and mask&amp;nbsp; StageAge = str(arcpy.GetParameterAsText(1))&amp;nbsp; BSS = arcpy.Raster(arcpy.GetParameterAsText(2))&amp;nbsp; InputLatitude = arcpy.Raster(arcpy.GetParameterAsText(3))&amp;nbsp; InputZ = arcpy.GetParameterAsText(4)&amp;nbsp; InputCountrylines = arcpy.GetParameterAsText(5)&amp;nbsp; NPPEquation = str(arcpy.GetParameterAsText(6))&amp;nbsp; CDFEquation = str(arcpy.GetParameterAsText(7))&amp;nbsp; env.mask = InputZ&amp;nbsp; # Calculate latitude North/South, offshore distance and Z for CDF Equations; also set the "0" values from Offshoredistance and Bathymetry to "1"&amp;nbsp; LatNorth = Con((InputLatitude &amp;gt; 0),(InputLatitude)) LatSouth = Con((InputLatitude &amp;lt; 0),(InputLatitude)) Offshoredistancemin0 = EucDistance(InputCountrylines, "", 0.5, "") Offshoredistance = Con((Offshoredistancemin0 == 0),1,(Offshoredistancemin0)) InputZ = Con((InputZ == 0),1,(InputZ)) ZforCDF = Con((InputZ) &amp;gt;50, (InputZ))&amp;nbsp;&amp;nbsp; # Calculation of Parameter 4 - Net Primary Productivity (NPP). Check the NPP Equation Name and follow the appropiate branch&amp;nbsp; if NPPEquation == "Min NPP":&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; rasterNorth = (-1.9875 * (LatNorth) + 194) &amp;nbsp;&amp;nbsp;&amp;nbsp; rasterSouth = (2.3377 * (LatSouth) + 200)&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; NPP = arcpy.MosaicToNewRaster_management([(rasterNorth), (rasterSouth)], OutLocation, (StageAge) + "_MinNPP", "", "32_BIT_FLOAT", "", "1", "LAST", "FIRST")&amp;nbsp; elif NPPEquation == "Max NPP":&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; rasterNorth = (-8.0488 * (LatNorth) + 840) &amp;nbsp;&amp;nbsp;&amp;nbsp; rasterSouth = (9.6104 * (LatSouth) + 840)&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; NPP = arcpy.MosaicToNewRaster_management([(rasterNorth), (rasterSouth)], OutLocation, (StageAge) + "_MaxNPP", "", "32_BIT_FLOAT", "", "1", "LAST", "FIRST")&amp;nbsp;&amp;nbsp; # Calculation of Parameter 5 - Carbon Delivery Flux (CDF). Check the CDF Equation Name and follow the appropiate branch&amp;nbsp; if CDFEquation == "1. Suess 1980":&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; CDF = Con((ZforCDF &amp;gt;= 50) &amp;amp; (ZforCDF &amp;lt; 100), ((0.049 * (Power((NPP), 1.41)) + (NPP) / ((0.0238 * 50) + (0.212))) / 2) - ((((0.049 * (Power((NPP), 1.41)) + &amp;nbsp;&amp;nbsp;&amp;nbsp; (NPP) / ((0.0238 * 50) + (0.212))) / 2) - ((NPP) / ((0.0238 * 100) + (0.212)))) / 50)&amp;nbsp; * ((ZforCDF) - 50), (NPP) / ((0.0238 * (ZforCDF)) + (0.212)))&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; CDF.save(OutLocation)&amp;nbsp; elif CDFEquation == "2. Suess 1980 mod":&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; CDF = Con((ZforCDF &amp;gt;= 50) &amp;amp; (ZforCDF &amp;lt; 100),&amp;nbsp; (0.049 * (Power((NPP), 1.41))) - ((((0.049 * (Power((NPP),1.41))) - (27.1 * (Power((NPP) / 100,0.935)))) / 50) * &amp;nbsp;&amp;nbsp;&amp;nbsp; ((ZforCDF) - 50)), 27.1 * (Power((NPP) / (ZforCDF),0.935)))&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; CDF.save(OutLocation)&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Many thanks for your help&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Toni&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 23 Dec 2013 12:45:26 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/unsupported-operand-error/m-p/352944#M27697</guid>
      <dc:creator>anTonialcaraz</dc:creator>
      <dc:date>2013-12-23T12:45:26Z</dc:date>
    </item>
    <item>
      <title>Re: Unsupported operand error</title>
      <link>https://community.esri.com/t5/python-questions/unsupported-operand-error/m-p/352945#M27698</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;The error means that somewhere in the code, you are combining a string with the output of a function. However I can't specifically see where you are doing this. You said the code provided is simplified?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Also you don't need to do this:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
NPPEquation = str(arcpy.GetParameterAsText(6))
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
NPPEquation = arcpy.GetParameterAsText(6)
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Is the same. Can you identify what line is causing the error? Perhaps try hard-coding all of the parameters and see if this works to help find the source.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 16:33:42 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/unsupported-operand-error/m-p/352945#M27698</guid>
      <dc:creator>DouglasSands</dc:creator>
      <dc:date>2021-12-11T16:33:42Z</dc:date>
    </item>
    <item>
      <title>Re: Unsupported operand error</title>
      <link>https://community.esri.com/t5/python-questions/unsupported-operand-error/m-p/352946#M27699</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi Doug,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks a lot for your comments, I'm taking note.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The code I'm showing is simplified in terms of not including all the "elif" statements (different NPP and CDF equations) so there is nothing "extra" that may cause the error in the rest of the code (I should think).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm getting the error in the line AFTER "if CDFEquation == "1. Suess 1980":", that is in the first Con calculation.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;ZforCDF and NPP have been previously defined so I don't quite understand this error.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm not sure either how to use the OutLocation variable to define the output path and name of that Con calculation.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I'll hard code the variables and see what happen.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks a lot.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Toni&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 23 Dec 2013 20:15:41 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/unsupported-operand-error/m-p/352946#M27699</guid>
      <dc:creator>anTonialcaraz</dc:creator>
      <dc:date>2013-12-23T20:15:41Z</dc:date>
    </item>
    <item>
      <title>Re: Unsupported operand error</title>
      <link>https://community.esri.com/t5/python-questions/unsupported-operand-error/m-p/352947#M27700</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I've hard coded and simplified the script to facilitate readability.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm still getting the same kind of errors with the Con calculation. This calculation works in raster calculator. In fact, it works also as a separate script that I had been using within Model Builder. Consequently, I'm lost!!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Please see below images and code.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;IMAGES:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Image "errorA": Apparently the error may seem to be related to the operand "/"&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Image "errorB": If I change that "/" operand by "*" (just to try something) I get this error&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Image "errorC": If I change that "/" operand by "+" the error goes to the next line until encounters the next "/" operand&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;[ATTACH=CONFIG]30093[/ATTACH]&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;[ATTACH=CONFIG]30094[/ATTACH]&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;[ATTACH=CONFIG]30095[/ATTACH]&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;CODE:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcpy
import string
from arcpy import env
arcpy.env.overwriteOutput=True
from arcpy.sa import *
arcpy.CheckOutExtension("Spatial")


# Inputs / Output

NPP = r"D:\PROGRAMMES\LFP_Source_Rocks\ArcGIS\00_LFP_GLOBAL_MODEL\LFP_GLOBAL_Python\OUTPUT.gdb\NPP"
ZforCDF = r"D:\PROGRAMMES\LFP_Source_Rocks\ArcGIS\00_LFP_GLOBAL_MODEL\LFP_GLOBAL_Python\OUTPUT.gdb\ZforCDF"


OutRasterlayer = r"D:\PROGRAMMES\LFP_Source_Rocks\ArcGIS\00_LFP_GLOBAL_MODEL\LFP_GLOBAL_Python\OUTPUT.gdb\CDF_NEW"


# Calculate CDF

CDF = Con((ZforCDF &amp;gt;= 50) &amp;amp; (ZforCDF &amp;lt; 100), ((0.049 * (Power ((NPP), 1.41)) + (NPP) / ((0.0238 * 50) + (0.212))) / 2) - ((((0.049 * (Power ((NPP), 1.41)) +
&amp;nbsp;&amp;nbsp;&amp;nbsp; (NPP) / ((0.0238 * 50) + (0.212))) / 2) - ((NPP) / ((0.0238 * 100) + (0.212)))) / 50)&amp;nbsp; * ((ZforCDF) - 50), (NPP) / ((0.0238 * (ZforCDF)) + (0.212)))

CDF.save(OutRasterlayer)&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Any help will be greatly appreciated&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 16:33:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/unsupported-operand-error/m-p/352947#M27700</guid>
      <dc:creator>anTonialcaraz</dc:creator>
      <dc:date>2021-12-11T16:33:45Z</dc:date>
    </item>
    <item>
      <title>Re: Unsupported operand error</title>
      <link>https://community.esri.com/t5/python-questions/unsupported-operand-error/m-p/352948#M27701</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;If NPP and ZforCDF are rasters on disk, shouldn't they be referenced to Raster objects before all that long calculation?&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Like :&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
NPP = arcpy.Raster(r"D:\PROGRAMMES\LFP_Source_Rocks\ArcGIS\00_LFP_GLOBAL_MODEL\LFP_GLOBAL_Python\OUTPUT.gdb\NPP")
&lt;/PRE&gt;&lt;BR /&gt;&lt;SPAN&gt;etc&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 16:33:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/unsupported-operand-error/m-p/352948#M27701</guid>
      <dc:creator>NeilAyres</dc:creator>
      <dc:date>2021-12-11T16:33:49Z</dc:date>
    </item>
    <item>
      <title>Re: Unsupported operand error</title>
      <link>https://community.esri.com/t5/python-questions/unsupported-operand-error/m-p/352949#M27702</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;If NPP and ZforCDF are rasters on disk, shouldn't they be referenced to Raster objects before all that long calculation?&lt;BR /&gt;Like :&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
NPP = arcpy.Raster(r"D:\PROGRAMMES\LFP_Source_Rocks\ArcGIS\00_LFP_GLOBAL_MODEL\LFP_GLOBAL_Python\OUTPUT.gdb\NPP")
&lt;/PRE&gt;&lt;BR /&gt;etc&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;You beat me to it, but this definitely necessary. Otherwise NPP is a string and that would be why the unsupported operand error comes up with * and / operators. The reason that + works is that strings support +. For example &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
folder = 'C:\\'
file = 'a_file.txt'
full_path = folder + file
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Because you use getParameterAsText(), they are being set to strings. You might be able to use &lt;/SPAN&gt;&lt;A href="http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//000v00000013000000" rel="nofollow noopener noreferrer" target="_blank"&gt;arcpy.getParameter(#)&lt;/A&gt;&lt;SPAN&gt; instead. This would grab the parameter as an object and may work in your case.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 16:33:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/unsupported-operand-error/m-p/352949#M27702</guid>
      <dc:creator>DouglasSands</dc:creator>
      <dc:date>2021-12-11T16:33:51Z</dc:date>
    </item>
    <item>
      <title>Re: Unsupported operand error</title>
      <link>https://community.esri.com/t5/python-questions/unsupported-operand-error/m-p/352950#M27703</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi there,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks a lot for your comments. Still pretty much lost though...&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Please see below two versions of the same code. I'm just changing the calculation in "Calculation of Parameter 5".&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;CODE A works. CODE B does NOT. In CODE B I'm getting the "Operand Error". Any ideas?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;CODE A:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcpy
import string
from arcpy import env
arcpy.env.overwriteOutput=True
from arcpy.sa import *
arcpy.CheckOutExtension("Spatial")


# Set the output location and extent

OutLocation = arcpy.GetParameterAsText(0)

arcpy.env.extent = arcpy.Extent(-180.0, -90.0, 180.0, 90.0)


# Input strings, variables and mask

StageAge = arcpy.GetParameterAsText(1)

BSS = arcpy.Raster(arcpy.GetParameterAsText(2))

InputLatitude = arcpy.Raster(arcpy.GetParameterAsText(3))

InputZ = arcpy.GetParameterAsText(4)

InputCountrylines = arcpy.GetParameterAsText(5)

NPPEquation = arcpy.GetParameterAsText(6)

CDFEquation = arcpy.GetParameterAsText(7)

env.mask = InputZ

# Calculate latitude North/South and offshore distance; also set the "0" values from Offshoredistance and Bathymetry to "1"

LatNorth = Con((InputLatitude &amp;gt; 0),(InputLatitude))
LatSouth = Con((InputLatitude &amp;lt; 0),(InputLatitude))
Offshoredistancemin0 = EucDistance(InputCountrylines, "", 0.5, "")
Offshoredistance = Con((Offshoredistancemin0 == 0),1,(Offshoredistancemin0))
InputZ1 = Con((InputZ == 0),1,(InputZ))
ZforCDF = Con((InputZ1) &amp;gt;50, (InputZ1))


# Calculation of Parameter 3 - Background Total Organic Carbon (TOC)

range1 = Con(((BSS) &amp;lt; 0.0378), (BSS))
range1phi = Con((range1), 6.11)

range2 = Con(((BSS) &amp;gt;= 0.0378) &amp;amp; ((BSS) &amp;lt;= 0.47), (BSS))
range2mm = 0.0593-(1.7714*(range2))+(18.7109*Power((range2),2))-(22.7289*Power((range2),3))
range2phi = -3.3219*Log10((range2mm))

range3 = Con(((BSS) &amp;gt; 0.47), (BSS))
range3mm = 0.8381 + (1.2188*(range3)) - (0.0007*Power((range3),2))
range3phi = -3.3219*Log10((range3mm))

GrainSizephi = arcpy.MosaicToNewRaster_management([(range1phi), (range2phi), (range3phi)], OutLocation, (StageAge) + "_Grain_Size_phi", "", "32_BIT_FLOAT", "", "1", "LAST", "FIRST")


# Calculation of Parameter 4 - Net Primary Productivity (NPP).

if NPPEquation == "Min NPP":

&amp;nbsp;&amp;nbsp;&amp;nbsp; rasterNorth = (-1.9875 * (LatNorth) + 194)
&amp;nbsp;&amp;nbsp;&amp;nbsp; rasterSouth = (2.3377 * (LatSouth) + 200)

&amp;nbsp;&amp;nbsp;&amp;nbsp; NPP = arcpy.MosaicToNewRaster_management([(rasterNorth), (rasterSouth)], OutLocation, (StageAge) + "_MinNPP", "", "32_BIT_FLOAT", "", "1", "LAST", "FIRST")


# Calculation of Parameter 5 - Carbon Delivery Flux (CDF).

if CDFEquation == "1. Suess 1980":

&amp;nbsp;&amp;nbsp;&amp;nbsp; CDF = (NPP * ZforCDF / 100) * 4

&amp;nbsp;&amp;nbsp;&amp;nbsp; CDF.save(r"Q:\LFP_GLOBAL_Python\OUTPUT.gdb\CDF")
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;CODE B:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcpy
import string
from arcpy import env
arcpy.env.overwriteOutput=True
from arcpy.sa import *
arcpy.CheckOutExtension("Spatial")


# Set the output location and extent

OutLocation = arcpy.GetParameterAsText(0)

arcpy.env.extent = arcpy.Extent(-180.0, -90.0, 180.0, 90.0)


# Input strings, variables and mask

StageAge = arcpy.GetParameterAsText(1)

BSS = arcpy.Raster(arcpy.GetParameterAsText(2))

InputLatitude = arcpy.Raster(arcpy.GetParameterAsText(3))

InputZ = arcpy.GetParameterAsText(4)

InputCountrylines = arcpy.GetParameterAsText(5)

NPPEquation = arcpy.GetParameterAsText(6)

CDFEquation = arcpy.GetParameterAsText(7)

env.mask = InputZ

# Calculate latitude North/South and offshore distance; also set the "0" values from Offshoredistance and Bathymetry to "1"

LatNorth = Con((InputLatitude &amp;gt; 0),(InputLatitude))
LatSouth = Con((InputLatitude &amp;lt; 0),(InputLatitude))
Offshoredistancemin0 = EucDistance(InputCountrylines, "", 0.5, "")
Offshoredistance = Con((Offshoredistancemin0 == 0),1,(Offshoredistancemin0))
InputZ1 = Con((InputZ == 0),1,(InputZ))
ZforCDF = Con((InputZ1) &amp;gt;50, (InputZ1))


# Calculation of Parameter 3 - Background Total Organic Carbon (TOC)

range1 = Con(((BSS) &amp;lt; 0.0378), (BSS))
range1phi = Con((range1), 6.11)

range2 = Con(((BSS) &amp;gt;= 0.0378) &amp;amp; ((BSS) &amp;lt;= 0.47), (BSS))
range2mm = 0.0593-(1.7714*(range2))+(18.7109*Power((range2),2))-(22.7289*Power((range2),3))
range2phi = -3.3219*Log10((range2mm))

range3 = Con(((BSS) &amp;gt; 0.47), (BSS))
range3mm = 0.8381 + (1.2188*(range3)) - (0.0007*Power((range3),2))
range3phi = -3.3219*Log10((range3mm))

GrainSizephi = arcpy.MosaicToNewRaster_management([(range1phi), (range2phi), (range3phi)], OutLocation, (StageAge) + "_Grain_Size_phi", "", "32_BIT_FLOAT", "", "1", "LAST", "FIRST")


# Calculation of Parameter 4 - Net Primary Productivity (NPP). Check the NPP Equation Name and follow the appropiate branch

if NPPEquation == "Min NPP":

&amp;nbsp;&amp;nbsp;&amp;nbsp; rasterNorth = (-1.9875 * (LatNorth) + 194)
&amp;nbsp;&amp;nbsp;&amp;nbsp; rasterSouth = (2.3377 * (LatSouth) + 200)

&amp;nbsp;&amp;nbsp;&amp;nbsp; NPP = arcpy.MosaicToNewRaster_management([(rasterNorth), (rasterSouth)], OutLocation, (StageAge) + "_MinNPP", "", "32_BIT_FLOAT", "", "1", "LAST", "FIRST")


# Calculation of Parameter 5 - Carbon Delivery Flux (CDF). Check the CDF Equation Name and follow the appropiate branch

if CDFEquation == "1. Suess 1980":

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; CDF = Con((ZforCDF &amp;gt;= 50) &amp;amp; (ZforCDF &amp;lt; 100), NPP * 2, NPP * 4)

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; CDF.save(r"Q:\LFP_GLOBAL_Python\OUTPUT.gdb\CDF")
&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 16:33:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/unsupported-operand-error/m-p/352950#M27703</guid>
      <dc:creator>anTonialcaraz</dc:creator>
      <dc:date>2021-12-11T16:33:54Z</dc:date>
    </item>
    <item>
      <title>Re: Unsupported operand error</title>
      <link>https://community.esri.com/t5/python-questions/unsupported-operand-error/m-p/352951#M27704</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Just in case anyone's interested I just found out where the problem was:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;In the calculation of Parameter 5 (CDF) NPP is used. NPP is the output of Parameter 4 and the result of Mosaic to New Raster.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;As far as I can see NPP is not quite recognised as a raster object within the Parameter 5 calculation (not really sure why).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;So I added "arcpy.Raster" in front of the "arcpy.MosaicToNewRaster_management" like this:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;NPP = arcpy.Raster(arcpy.MosaicToNewRaster_management([(rasterNorth), (rasterSouth)], OutLocation, (StageAge) + "_MinNPP", "", "32_BIT_FLOAT", "", "1", "LAST", "FIRST"))&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;(The other option is to just add Raster in front of (NPP) in the CDF calculation equation).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Now it works.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks for your help anyway.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 27 Dec 2013 09:20:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/unsupported-operand-error/m-p/352951#M27704</guid>
      <dc:creator>anTonialcaraz</dc:creator>
      <dc:date>2013-12-27T09:20:13Z</dc:date>
    </item>
  </channel>
</rss>

