<?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 Why are the environment settings not honored in my python script? in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/why-are-the-environment-settings-not-honored-in-my/m-p/1294886#M67774</link>
    <description>&lt;P&gt;&lt;SPAN class=""&gt;I am testing a workflow in python (3.9) with a couple of raster calculations that require environment settings like the mask, output coordinate system and cellSize settings. While it respects the output coordinate system in one part of the script, it ignores the cellSize as well as the mask in the next function. When I am running the raster calculator tool in ArcGIS Pro with the environment settings I am getting the expected outcome. I tried using with arcpy.EnvManager(...) and setting arcpy.env.cellSize etc. but it seems to just ignore me. I also tried using ResetEnvironments() to make sure that it is not using other settings but no change. I tried giving the cellSize as a number (100) or as reference to a raster dataset. Also tried to run the script as script tool and neither from the script nor from the tool the environment settings seem to be honored. Syntax itself seems to be correct as I don't get any errors in pyScripter. Any idea? Happy to share them full script if someone wants to have a look...&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;This is one of the calculations: &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;with arcpy.EnvManager(cellSize=100):
        raster2=[rainday,"C:/data/EWIS.gdb/land100"]
        landslidealarm=RasterCalculator(
            rasters=raster2,
            input_names=["raster1","raster2"],
            expression="raster1 * raster2"
            )&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 01 Jun 2023 11:04:18 GMT</pubDate>
    <dc:creator>Nicole_Ueberschär</dc:creator>
    <dc:date>2023-06-01T11:04:18Z</dc:date>
    <item>
      <title>Why are the environment settings not honored in my python script?</title>
      <link>https://community.esri.com/t5/python-questions/why-are-the-environment-settings-not-honored-in-my/m-p/1294886#M67774</link>
      <description>&lt;P&gt;&lt;SPAN class=""&gt;I am testing a workflow in python (3.9) with a couple of raster calculations that require environment settings like the mask, output coordinate system and cellSize settings. While it respects the output coordinate system in one part of the script, it ignores the cellSize as well as the mask in the next function. When I am running the raster calculator tool in ArcGIS Pro with the environment settings I am getting the expected outcome. I tried using with arcpy.EnvManager(...) and setting arcpy.env.cellSize etc. but it seems to just ignore me. I also tried using ResetEnvironments() to make sure that it is not using other settings but no change. I tried giving the cellSize as a number (100) or as reference to a raster dataset. Also tried to run the script as script tool and neither from the script nor from the tool the environment settings seem to be honored. Syntax itself seems to be correct as I don't get any errors in pyScripter. Any idea? Happy to share them full script if someone wants to have a look...&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;This is one of the calculations: &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;with arcpy.EnvManager(cellSize=100):
        raster2=[rainday,"C:/data/EWIS.gdb/land100"]
        landslidealarm=RasterCalculator(
            rasters=raster2,
            input_names=["raster1","raster2"],
            expression="raster1 * raster2"
            )&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 01 Jun 2023 11:04:18 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/why-are-the-environment-settings-not-honored-in-my/m-p/1294886#M67774</guid>
      <dc:creator>Nicole_Ueberschär</dc:creator>
      <dc:date>2023-06-01T11:04:18Z</dc:date>
    </item>
    <item>
      <title>Re: Why are the environment settings not honored in my python script?</title>
      <link>https://community.esri.com/t5/python-questions/why-are-the-environment-settings-not-honored-in-my/m-p/1295372#M67781</link>
      <description>&lt;P&gt;This is a head scratcher.&lt;/P&gt;&lt;P&gt;You could print out all the env settings with the Listenvironments() method to see if its setting as a before and after as a peek into the env values:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import arcpy

environments = arcpy.ListEnvironments()

# Sort the environment names
environments.sort()

for environment in environments:
    print(f"{environment}:\t{arcpy.env[environment]}")

arcpy.env.cellSize = 100
arcpy.env.workspace = 'Hello!'

environments = arcpy.ListEnvironments()

# Sort the environment names
environments.sort()

for environment in environments:
    print(f"{environment}:\t{arcpy.env[environment]}")

with arcpy.EnvManager(workspace='Hi Back'):
    environments = arcpy.ListEnvironments()

    # Sort the environment names
    environments.sort()

    for environment in environments:
        print(f"{environment}:\t{arcpy.env[environment]}")&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 02 Jun 2023 14:11:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/why-are-the-environment-settings-not-honored-in-my/m-p/1295372#M67781</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2023-06-02T14:11:50Z</dc:date>
    </item>
    <item>
      <title>Re: Why are the environment settings not honored in my python script?</title>
      <link>https://community.esri.com/t5/python-questions/why-are-the-environment-settings-not-honored-in-my/m-p/1295699#M67787</link>
      <description>&lt;P&gt;Thanks for the hint and for including directly the code. Very helpful!&lt;/P&gt;&lt;P&gt;Unfortunately considering the prints I still can't see why the output is wrong. Before my function the environment settings show&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;cellSize: MAXOF&lt;/SPAN&gt; and&lt;/DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;mask: None&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;within my function it shows&lt;/DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;cellSize: 100 and &lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;mask: C:/data/2023/MINEMA_NECC/EWIS/EWIS.gdb/Country_boundary_TMRwanda&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;which is as expected but not represented in the output. Any other idea?&lt;BR /&gt;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Mon, 05 Jun 2023 07:56:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/why-are-the-environment-settings-not-honored-in-my/m-p/1295699#M67787</guid>
      <dc:creator>Nicole_Ueberschär</dc:creator>
      <dc:date>2023-06-05T07:56:34Z</dc:date>
    </item>
    <item>
      <title>Re: Why are the environment settings not honored in my python script?</title>
      <link>https://community.esri.com/t5/python-questions/why-are-the-environment-settings-not-honored-in-my/m-p/1295721#M67788</link>
      <description>&lt;P&gt;I did some more testing with the two settings separately but both seem to be ignored. I also tried a different layer as mask, setting the cellSize as file and as number - no change &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 05 Jun 2023 09:46:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/why-are-the-environment-settings-not-honored-in-my/m-p/1295721#M67788</guid>
      <dc:creator>Nicole_Ueberschär</dc:creator>
      <dc:date>2023-06-05T09:46:48Z</dc:date>
    </item>
    <item>
      <title>Re: Why are the environment settings not honored in my python script?</title>
      <link>https://community.esri.com/t5/python-questions/why-are-the-environment-settings-not-honored-in-my/m-p/1338700#M68976</link>
      <description>&lt;P&gt;Did you ever find a solution to this issue? I am running in to the same problem, unfortunately.&lt;/P&gt;</description>
      <pubDate>Tue, 17 Oct 2023 16:17:12 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/why-are-the-environment-settings-not-honored-in-my/m-p/1338700#M68976</guid>
      <dc:creator>melissaur1039</dc:creator>
      <dc:date>2023-10-17T16:17:12Z</dc:date>
    </item>
  </channel>
</rss>

