<?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: Setting Mask from Parameter in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/setting-mask-from-parameter/m-p/396723#M31315</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi again Jake,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;It works like this:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.env.mask = str(InputZ)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Many thanks again&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Toni&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 20 Dec 2013 10:31:52 GMT</pubDate>
    <dc:creator>anTonialcaraz</dc:creator>
    <dc:date>2013-12-20T10:31:52Z</dc:date>
    <item>
      <title>Setting Mask from Parameter</title>
      <link>https://community.esri.com/t5/python-questions/setting-mask-from-parameter/m-p/396720#M31312</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi everyone,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This may seem like an easy one but I cannot quite find the way:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;When setting the environments, I want to use one of the parameters ("InputZ") as a mask for the different processes within the script. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;It works fine like this:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.env.mask = r"D:\PROGRAMMES\LFP_Source_Rocks\ArcGIS\00_LFP_GLOBAL_MODEL\INPUT.gdb\Maas_Bathymetry"&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;but I want this:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.env.mask = (InputZ)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;using ArcView 10.0&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;here is the beginning of the 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; # Set the output location, extent and Mask&amp;nbsp; OutLocation = arcpy.GetParameterAsText(0)&amp;nbsp; arcpy.env.extent = arcpy.Extent(-180.0, -90.0, 180.0, 90.0)&amp;nbsp; arcpy.env.mask = (InputZ)&amp;nbsp; # Input strings and variables&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.Raster(arcpy.GetParameterAsText(4))&amp;nbsp; InputCountrylines = arcpy.GetParameterAsText(5)&amp;nbsp; NPPEquation = str(arcpy.GetParameterAsText(6))&lt;/PRE&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;Many thanks&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 20 Dec 2013 07:34:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/setting-mask-from-parameter/m-p/396720#M31312</guid>
      <dc:creator>anTonialcaraz</dc:creator>
      <dc:date>2013-12-20T07:34:45Z</dc:date>
    </item>
    <item>
      <title>Re: Setting Mask from Parameter</title>
      <link>https://community.esri.com/t5/python-questions/setting-mask-from-parameter/m-p/396721#M31313</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Try passing the raster as a string rather than a raster object.&amp;nbsp; Ex:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;arcpy.env.mask = InputZ

InputZ = arcpy.GetParameterAsText(4)&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I also removed the parentheses for the env.mask.&amp;nbsp; Not sure if this matters, but adding the parentheses will create a tuple rather than a string.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 18:08:43 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/setting-mask-from-parameter/m-p/396721#M31313</guid>
      <dc:creator>JakeSkinner</dc:creator>
      <dc:date>2021-12-11T18:08:43Z</dc:date>
    </item>
    <item>
      <title>Re: Setting Mask from Parameter</title>
      <link>https://community.esri.com/t5/python-questions/setting-mask-from-parameter/m-p/396722#M31314</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thanks Jake,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I just tried that with and without parentheses for the env.mask but I'm getting the message "InputZ is not defined"&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Cannot find the way really...&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Many thanks&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Toni&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 20 Dec 2013 10:04:22 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/setting-mask-from-parameter/m-p/396722#M31314</guid>
      <dc:creator>anTonialcaraz</dc:creator>
      <dc:date>2013-12-20T10:04:22Z</dc:date>
    </item>
    <item>
      <title>Re: Setting Mask from Parameter</title>
      <link>https://community.esri.com/t5/python-questions/setting-mask-from-parameter/m-p/396723#M31315</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi again Jake,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;It works like this:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.env.mask = str(InputZ)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Many thanks again&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Toni&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 20 Dec 2013 10:31:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/setting-mask-from-parameter/m-p/396723#M31315</guid>
      <dc:creator>anTonialcaraz</dc:creator>
      <dc:date>2013-12-20T10:31:52Z</dc:date>
    </item>
    <item>
      <title>Re: Setting Mask from Parameter</title>
      <link>https://community.esri.com/t5/python-questions/setting-mask-from-parameter/m-p/396724#M31316</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Toni,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Did you remove the 'arcpy.Raster' from the arcpy.GetParameterAsText?&amp;nbsp; Also, what data type are you setting for this parameter in your script tool?&amp;nbsp; For example, I had the following script:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;import arcpy arcpy.CheckOutExtension("Spatial") from arcpy import env env.workspace = r"C:\data\raster\dem"&amp;nbsp; InputZ = arcpy.GetParameterAsText(0)&amp;nbsp; env.mask = InputZ&amp;nbsp; arcpy.Slope_3d("example","Slope","DEGREE","1")&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I then added this to a toolbox and set the parameter to a Raster Dataset:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;[ATTACH=CONFIG]30030[/ATTACH]&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;When running the tool, the slope masked the raster I chose.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 20 Dec 2013 10:42:12 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/setting-mask-from-parameter/m-p/396724#M31316</guid>
      <dc:creator>JakeSkinner</dc:creator>
      <dc:date>2013-12-20T10:42:12Z</dc:date>
    </item>
    <item>
      <title>Re: Setting Mask from Parameter</title>
      <link>https://community.esri.com/t5/python-questions/setting-mask-from-parameter/m-p/396725#M31317</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi Jake,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;It does work your way also.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I did remove the "arcpy.Raster". In my toolbox I set the data as "Raster Layer". I guess it doesn't make any difference compared to"Raster Dataset" in this case (I've tried and both work).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;When I tried when you first suggested I had env.mask = InputZ written before InputZ = arcpy.GetParameterAsText(0) when it should go after.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;It works also like this: env.mask = str(InputZ)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Many thanks&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Toni&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 20 Dec 2013 11:55:32 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/setting-mask-from-parameter/m-p/396725#M31317</guid>
      <dc:creator>anTonialcaraz</dc:creator>
      <dc:date>2013-12-20T11:55:32Z</dc:date>
    </item>
    <item>
      <title>Re: Setting Mask from Parameter</title>
      <link>https://community.esri.com/t5/python-questions/setting-mask-from-parameter/m-p/396726#M31318</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Glad this is working.&amp;nbsp; Also, wanted to point out, in case you were wondering, the difference between Raster Layer and Raster Dataset is that Raster Layer will allow your tool to have a dropdown and choose a raster within your current map document.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 20 Dec 2013 12:32:16 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/setting-mask-from-parameter/m-p/396726#M31318</guid>
      <dc:creator>JakeSkinner</dc:creator>
      <dc:date>2013-12-20T12:32:16Z</dc:date>
    </item>
    <item>
      <title>Re: Setting Mask from Parameter</title>
      <link>https://community.esri.com/t5/python-questions/setting-mask-from-parameter/m-p/396727#M31319</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thanks a lot Jake. Really useful indeed.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I actually have another issue with the same script related to strings.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I'll explain that in a new post.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Many thanks&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 20 Dec 2013 13:04:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/setting-mask-from-parameter/m-p/396727#M31319</guid>
      <dc:creator>anTonialcaraz</dc:creator>
      <dc:date>2013-12-20T13:04:07Z</dc:date>
    </item>
  </channel>
</rss>

