<?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 Extract by Mask Problem in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/extract-by-mask-problem/m-p/554411#M43347</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi all,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm having a bit of trouble with using the Extract by Mask functionality. I have a Python code that creates a file GDB and then I import shapefiles to the GDB. I then create a new raster dataset within the file GDB and then mosaic 4 .tiff into it. The problem occurs when I try to 'Extract by Mask' using the new raster dataset as the input and a polygon as the mask. I get an error stating that: &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;'AttributeError: 'module' object has no attribute 'ExtractByMask''&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I have imported the spatial analyst extension and below is the code that I'm trying to use:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;# Set local variables in_raster = "C:/Users/D/Prog_Assign.gdb/R_Dataset" in_mask_data = "C:/Users/D/Prog_Assign.gdb/Study_area_extent_shp" #Extract by Mask arcpy.ExtractByMask (in_raster, in_mask_data) # Save the output outExtractByMask.save("C:/Users/D/Prog_Assign.gdb/T_Mask")&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Any help or advice would be greatly appreciated!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 11 Jul 2013 20:14:46 GMT</pubDate>
    <dc:creator>DonalCasey</dc:creator>
    <dc:date>2013-07-11T20:14:46Z</dc:date>
    <item>
      <title>Extract by Mask Problem</title>
      <link>https://community.esri.com/t5/python-questions/extract-by-mask-problem/m-p/554411#M43347</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi all,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm having a bit of trouble with using the Extract by Mask functionality. I have a Python code that creates a file GDB and then I import shapefiles to the GDB. I then create a new raster dataset within the file GDB and then mosaic 4 .tiff into it. The problem occurs when I try to 'Extract by Mask' using the new raster dataset as the input and a polygon as the mask. I get an error stating that: &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;'AttributeError: 'module' object has no attribute 'ExtractByMask''&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I have imported the spatial analyst extension and below is the code that I'm trying to use:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;# Set local variables in_raster = "C:/Users/D/Prog_Assign.gdb/R_Dataset" in_mask_data = "C:/Users/D/Prog_Assign.gdb/Study_area_extent_shp" #Extract by Mask arcpy.ExtractByMask (in_raster, in_mask_data) # Save the output outExtractByMask.save("C:/Users/D/Prog_Assign.gdb/T_Mask")&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Any help or advice would be greatly appreciated!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 11 Jul 2013 20:14:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/extract-by-mask-problem/m-p/554411#M43347</guid>
      <dc:creator>DonalCasey</dc:creator>
      <dc:date>2013-07-11T20:14:46Z</dc:date>
    </item>
    <item>
      <title>Re: Extract by Mask Problem</title>
      <link>https://community.esri.com/t5/python-questions/extract-by-mask-problem/m-p/554412#M43348</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;The error is saying that you are trying to call a module (ExtractByMask) that does not exist in arcpy. That is because ExtractByMask lives in Spatial Analyst, which is arcpy.sa&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I noticed that you have missed a step in your code, that is setting outExtractByMask to ExtractByMask(). This will cause errors too, see code below for the fix.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;You have two options to fix your initial problem:&lt;/SPAN&gt;&lt;BR /&gt;&lt;OL&gt; &lt;BR /&gt; &lt;LI&gt;adding from arcpy.sa import * to the top of your code (just below import arcpy) - this is what ESRI does &lt;STRONG&gt;but it is generally not recommended&lt;/STRONG&gt;. Then you can just use ExtractByMask(), not arcpy.ExtractByMask()&lt;/LI&gt; &lt;BR /&gt; &lt;LI&gt;call ExtractByMask directly by using arcpy.sa.ExtractByMask(), so your posted code would become (changes in red):&lt;/LI&gt; &lt;BR /&gt;&lt;/OL&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;# Set local variables
in_raster = "C:/Users/D/Prog_Assign.gdb/R_Dataset"
in_mask_data = "C:/Users/D/Prog_Assign.gdb/Study_area_extent_shp"
#Extract by Mask
outExtractByMask = arcpy.&lt;STRONG&gt;sa.&lt;/STRONG&gt;ExtractByMask (in_raster, in_mask_data)
# Save the output
outExtractByMask.save("C:/Users/D/Prog_Assign.gdb/T_Mask")&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 16:37:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/extract-by-mask-problem/m-p/554412#M43348</guid>
      <dc:creator>StacyRendall1</dc:creator>
      <dc:date>2021-12-12T16:37:30Z</dc:date>
    </item>
    <item>
      <title>Re: Extract by Mask Problem</title>
      <link>https://community.esri.com/t5/python-questions/extract-by-mask-problem/m-p/554413#M43349</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thanks very much, that worked a treat, I couldn't figure out where I was going wrong!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 12 Jul 2013 08:21:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/extract-by-mask-problem/m-p/554413#M43349</guid>
      <dc:creator>DonalCasey</dc:creator>
      <dc:date>2013-07-12T08:21:13Z</dc:date>
    </item>
  </channel>
</rss>

